From ebc7288cbf19d8897f518116f6f2cc3aa0c1f9b9 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 4 Nov 2024 09:39:21 +0100 Subject: [PATCH] Install imagestreams in test directly not in constructor. In case of failure during construct, then 'teardown_methon' is not called and project is not deleted The postgresql helm-chart is updated as well Signed-off-by: Petr "Stone" Hracek --- tests/test_mariadb_template.py | 10 ++++++---- tests/test_mysql_template.py | 13 +++++++------ tests/test_postgresql_template.py | 7 ++++++- tests/test_redis_template.py | 7 +++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tests/test_mariadb_template.py b/tests/test_mariadb_template.py index f82d72b..75759aa 100644 --- a/tests/test_mariadb_template.py +++ b/tests/test_mariadb_template.py @@ -14,9 +14,6 @@ def setup_method(self): package_name = "mariadb-persistent" path = test_dir / "../charts/redhat" self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) - self.hc_api.package_name = "mariadb-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() def teardown_method(self): self.hc_api.delete_project() @@ -32,13 +29,18 @@ def teardown_method(self): ], ) def test_package_persistent(self, version): + self.hc_api.package_name = "mariadb-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() self.hc_api.package_name = "mariadb-persistent" assert self.hc_api.helm_package() + pod_name = f"mariadb-{version}".replace(".", "") assert self.hc_api.helm_installation( values={ "mariadb_version": version, "namespace": self.hc_api.namespace, + "name": pod_name } ) - assert self.hc_api.is_pod_running(pod_name_prefix="mariadb") + assert self.hc_api.is_pod_running(pod_name_prefix=pod_name) assert self.hc_api.test_helm_chart(expected_str=["42", "testval"]) diff --git a/tests/test_mysql_template.py b/tests/test_mysql_template.py index 9b019ab..b400e10 100644 --- a/tests/test_mysql_template.py +++ b/tests/test_mysql_template.py @@ -14,9 +14,6 @@ def setup_method(self): package_name = "mysql-persistent" path = test_dir / "../charts/redhat" self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) - self.hc_api.package_name = "mysql-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() def teardown_method(self): self.hc_api.delete_project() @@ -29,14 +26,18 @@ def teardown_method(self): ], ) def test_package_persistent(self, version): - + self.hc_api.package_name = "mysql-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() self.hc_api.package_name = "mysql-persistent" assert self.hc_api.helm_package() + pod_name = f"mysql-{version}".replace(".", "") assert self.hc_api.helm_installation( values={ "mysql_version": version, - "namespace": self.hc_api.namespace + "namespace": self.hc_api.namespace, + "name": pod_name } ) - assert self.hc_api.is_pod_running(pod_name_prefix="mysql") + assert self.hc_api.is_pod_running(pod_name_prefix=pod_name) assert self.hc_api.test_helm_chart(expected_str=["42", "testval"]) diff --git a/tests/test_postgresql_template.py b/tests/test_postgresql_template.py index 221f4c4..864f987 100644 --- a/tests/test_postgresql_template.py +++ b/tests/test_postgresql_template.py @@ -35,6 +35,11 @@ def test_package_persistent(self, version): assert self.hc_api.helm_installation() self.hc_api.package_name = "postgresql-persistent" assert self.hc_api.helm_package() - assert self.hc_api.helm_installation(values={".image.tag": version, ".namespace": self.hc_api.namespace}) + assert self.hc_api.helm_installation( + values={ + "image.tag": version, + "namespace": self.hc_api.namespace + } + ) assert self.hc_api.is_pod_running(pod_name_prefix="postgresql-persistent") assert self.hc_api.test_helm_chart(expected_str=["accepting connection"]) diff --git a/tests/test_redis_template.py b/tests/test_redis_template.py index 12b0043..7a47cac 100644 --- a/tests/test_redis_template.py +++ b/tests/test_redis_template.py @@ -14,9 +14,6 @@ def setup_method(self): package_name = "redis-persistent" path = test_dir / "../charts/redhat" self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir) - self.hc_api.package_name = "redis-imagestreams" - assert self.hc_api.helm_package() - assert self.hc_api.helm_installation() def teardown_method(self): self.hc_api.delete_project() @@ -29,7 +26,9 @@ def teardown_method(self): ], ) def test_package_persistent(self, version): - + self.hc_api.package_name = "redis-imagestreams" + assert self.hc_api.helm_package() + assert self.hc_api.helm_installation() self.hc_api.package_name = "redis-persistent" assert self.hc_api.helm_package() assert self.hc_api.helm_installation(