Skip to content

Commit

Permalink
Install imagestreams in test directly not in constructor.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
phracek committed Nov 4, 2024
1 parent 39f428d commit ebc7288
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
10 changes: 6 additions & 4 deletions tests/test_mariadb_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"])
13 changes: 7 additions & 6 deletions tests/test_mysql_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"])
7 changes: 6 additions & 1 deletion tests/test_postgresql_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
7 changes: 3 additions & 4 deletions tests/test_redis_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand Down

0 comments on commit ebc7288

Please sign in to comment.