Skip to content

Commit afc66a7

Browse files
committed
Improve restart test
1 parent 779890e commit afc66a7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

tests/e2e/test_operator.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,15 @@ def test_operator_restart(self, manifest, service, version=None):
259259
wait_for_cluster(chi, cluster, shards, replicas)
260260

261261
with Then("Create tables"):
262-
for h in [f"chi-{chi}-{cluster}-0-0-0", f"chi-{chi}-{cluster}-1-0-0"]:
263-
clickhouse.query(
264-
chi,
265-
"CREATE TABLE IF NOT EXISTS test_local (a UInt32) Engine = Log",
266-
host=h,
267-
)
268-
clickhouse.query(
269-
chi,
270-
"CREATE TABLE IF NOT EXISTS test_dist as test_local Engine = Distributed('{cluster}', default, test_local, a)",
271-
host=h,
272-
)
262+
for s in range(shards):
263+
for r in range(replicas):
264+
h = f"chi-{chi}-{cluster}-{s}-{r]-0"
265+
clickhouse.query(
266+
chi, "CREATE TABLE IF NOT EXISTS test_local (a UInt32) Engine = Log", host=h,
267+
)
268+
clickhouse.query(
269+
chi, "CREATE TABLE IF NOT EXISTS test_dist as test_local Engine = Distributed('{cluster}', default, test_local, a)", host=h,
270+
)
273271

274272
trigger_event = threading.Event()
275273

@@ -323,9 +321,9 @@ def test_operator_restart(self, manifest, service, version=None):
323321
# shell = get_shell()
324322
# self.context.shell = shell
325323

326-
with Then("Local tables should have exactly the same number of rows"):
327-
cnt0 = clickhouse.query(chi, "select count() from test_local", host=f'chi-{chi}-{cluster}-0-0-0')
328-
cnt1 = clickhouse.query(chi, "select count() from test_local", host=f'chi-{chi}-{cluster}-1-0-0')
324+
with Then("Data in shards should be evenly distributed"):
325+
cnt0 = clickhouse.query(chi, "select count() from clusterAllReplicas('{cluster}', default.test_local) where _shard_num=1")
326+
cnt1 = clickhouse.query(chi, "select count() from clusterAllReplicas('{cluster}', default.test_local) where _shard_num=2")
329327
print(f"{cnt0} {cnt1}")
330328
assert cnt0 == cnt1 and cnt0 != "0"
331329

0 commit comments

Comments
 (0)