Skip to content

Commit

Permalink
Stabilize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-zaitsev committed Dec 18, 2024
1 parent 9b72b02 commit 6e02d53
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: test-030
name: test-099
spec:
useTemplates:
- name: clickhouse-version
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/manifests/chopconf/test-034-chopconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ spec:
# Port where to connect to ClickHouse instances to
scheme: https
port: 8443
reconcile:
statefulSet:
update:
timeout: 90
31 changes: 20 additions & 11 deletions tests/e2e/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3191,12 +3191,15 @@ def test_029(self):


@TestScenario
@Name("test_030. Test CRD deletion")
@Name("test_099. Test CRD deletion. Should be executed at the end")
@Tags("NO_PARALLEL")
def test_030(self):
def test_099(self):
create_shell_namespace_clickhouse_template()

manifest = "manifests/chi/test-030.yaml"
# delete existing chis if any in order to avoid side effects
cleanup_chis(self)

manifest = "manifests/chi/test-099.yaml"
chi = yaml_manifest.get_name(util.get_full_path(manifest))
object_counts = {"statefulset": 2, "pod": 2, "service": 3}

Expand Down Expand Up @@ -3537,9 +3540,12 @@ def test_034(self):

with And("Re-create operator pod in order to restart metrics exporter to update the configuration [1]"):
util.restart_operator()
kubectl.wait_chi_status(chi, "Completed")

out = kubectl.launch("get pods -l app=clickhouse-operator", ns=current().context.operator_namespace).splitlines()[1]
operator_pod = re.split(r"[\t\r\n\s]+", out)[0]


with Then("check for `chi_clickhouse_metric_fetch_errors` is not zero"):
check_metrics_monitoring(
operator_namespace=operator_namespace,
Expand Down Expand Up @@ -5184,6 +5190,16 @@ def test_054(self):
with Finally("I clean up"):
delete_test_namespace()

def cleanup_chis(self):
with Given("Cleanup CHIs"):
ns = kubectl.get("ns", name="", ns="--all-namespaces")
if "items" in ns:
for n in ns["items"]:
ns_name = n["metadata"]["name"]
if ns_name.startswith("test") and ns_name != self.context.test_namespace:
with Then(f"Delete ns {ns_name}"):
util.delete_namespace(namespace = ns_name, delete_chi=True)

@TestModule
@Name("e2e.test_operator")
@Requirements(RQ_SRS_026_ClickHouseOperator_CustomResource_APIVersion("1.0"),
Expand All @@ -5196,14 +5212,7 @@ def test(self):
shell = get_shell()
self.context.shell = shell

with Given("Cleanup CHIs"):
ns = kubectl.get("ns", name="", ns="--all-namespaces")
if "items" in ns:
for n in ns["items"]:
ns_name = n["metadata"]["name"]
if ns_name.startswith("test"):
with Then(f"Delete ns {ns_name}"):
util.delete_namespace(namespace = ns_name, delete_chi=True)
cleanup_chis(self)

# Placeholder for selective test running
# run_tests = [test_008, test_009]
Expand Down

0 comments on commit 6e02d53

Please sign in to comment.