Skip to content

Commit 779890e

Browse files
committed
Improve restart tests
1 parent 6d31457 commit 779890e

File tree

4 files changed

+10
-95
lines changed

4 files changed

+10
-95
lines changed

tests/e2e/manifests/chi/test-008-operator-restart-2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
spec:
6565
containers:
6666
- name: clickhouse-pod
67-
image: clickhouse/clickhouse-server:24.3
67+
image: clickhouse/clickhouse-server:25.3
6868
ports:
6969
- name: http
7070
containerPort: 8123

tests/e2e/manifests/chi/test-008-operator-restart-3-1.yaml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,12 @@ apiVersion: "clickhouse.altinity.com/v1"
22
kind: "ClickHouseInstallation"
33
metadata:
44
name: "test-008-3"
5-
labels:
6-
test: test
75
spec:
86
useTemplates:
9-
- name: persistent-volume
7+
- name: clickhouse-version
108
configuration:
11-
zookeeper:
12-
nodes:
13-
- host: zookeeper
14-
port: 2181
159
clusters:
1610
- name: test-008-3
1711
layout:
1812
shardsCount: 2
19-
replicasCount: 2
20-
users:
21-
test_008/password: test_008
22-
test_008/networks/ip: 0.0.0.0/0
23-
defaults:
24-
templates:
25-
dataVolumeClaimTemplate: default
26-
podTemplate: default
27-
templates:
28-
podTemplates:
29-
- name: default
30-
spec:
31-
containers:
32-
- name: clickhouse-pod
33-
image: clickhouse/clickhouse-server:24.8
13+
replicasCount: 2

tests/e2e/manifests/chi/test-008-operator-restart-3-2.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/e2e/test_operator.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ def test_operator_restart(self, manifest, service, version=None):
309309
check_operator_restart(
310310
chi=chi,
311311
wait_objects={
312-
"statefulset": 2,
313-
"pod": 2,
314-
"service": 3,
312+
"statefulset": shards * replicas,
313+
"pod": shards * replicas,
314+
"service": shards * replicas + 1,
315315
},
316316
pod=f"chi-{chi}-{cluster}-0-0-0"
317317
)
@@ -334,10 +334,11 @@ def test_operator_restart(self, manifest, service, version=None):
334334
kubectl.delete_chi(chi)
335335

336336

337-
def get_replicas_from_remote_servers(chi, cluster):
337+
def get_replicas_from_remote_servers(chi, cluster, shell=None):
338338
if cluster == "":
339339
cluster = chi
340-
remote_servers = kubectl.get("configmap", f"chi-{chi}-common-configd")["data"]["chop-generated-remote_servers.xml"]
340+
341+
remote_servers = kubectl.get("configmap", f"chi-{chi}-common-configd", shell=shell)["data"]["chop-generated-remote_servers.xml"]
341342

342343
chi_start = remote_servers.find(f"<{cluster}>")
343344
chi_end = remote_servers.find(f"</{cluster}>")
@@ -422,12 +423,9 @@ def test_010008_3(self):
422423
create_shell_namespace_clickhouse_template()
423424

424425
manifest = "manifests/chi/test-008-operator-restart-3-1.yaml"
425-
manifest_2 = "manifests/chi/test-008-operator-restart-3-2.yaml"
426426
chi = yaml_manifest.get_name(util.get_full_path(manifest))
427427
cluster = chi
428428

429-
util.require_keeper(keeper_type=self.context.keeper_type)
430-
431429
full_cluster = {"statefulset": 4, "pod": 4, "service": 5}
432430

433431
with Given("4-node CHI creation started"):
@@ -436,7 +434,7 @@ def test_010008_3(self):
436434
manifest,
437435
check={
438436
"apply_templates": {
439-
"manifests/chit/tpl-persistent-volume-100Mi.yaml",
437+
current().context.clickhouse_template,
440438
},
441439
"pod_count": 2,
442440
"do_not_delete": 1,
@@ -456,36 +454,6 @@ def test_010008_3(self):
456454
kubectl.wait_objects(chi, full_cluster)
457455
kubectl.wait_chi_status(chi, "Completed")
458456

459-
with Then("Upgrade ClickHouse version to run a reconcile"):
460-
kubectl.create_and_check(manifest_2, check={"do_not_delete": 1, "chi_status": "InProgress"})
461-
462-
trigger_event = threading.Event()
463-
464-
with When("I create new shells"):
465-
shell_1 = get_shell()
466-
shell_2 = get_shell()
467-
468-
Check("Check that cluster definition does not change during restart", test=check_remote_servers, parallel=True)(
469-
chi=chi,
470-
check_shards = True,
471-
check_replicas = False,
472-
trigger_event=trigger_event,
473-
shell=shell_1
474-
)
475-
# Just wait for restart operator. After restart it will update cluster with new ClickHouse version
476-
wait_operator_restart(
477-
chi=chi,
478-
wait_objects={"statefulset": 4, "pod": 4, "service": 5},
479-
shell=shell_2
480-
)
481-
trigger_event.set()
482-
time.sleep(5) # let threads to finish
483-
join()
484-
485-
# with Then("I recreate shell"):
486-
# shell = get_shell()
487-
# self.context.shell = shell
488-
489457
with Finally("I clean up"):
490458
delete_test_namespace()
491459

0 commit comments

Comments
 (0)