Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added tests/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions tests/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}

def is_test_allowed(os, version):
if os == "rhel8" and version == "5.26":
return True
if os == "rhel9" and version == "5.32":
return True
if os == "rhel10" and version == "5.40":
return True
return False
41 changes: 19 additions & 22 deletions tests/test_dancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

from container_ci_suite.openshift import OpenShiftAPI

from constants import TAGS, is_test_allowed
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))

VERSION=os.getenv("SINGLE_VERSION")
if not VERSION:
VERSION="5.32-ubi8"
OS=os.getenv("OS")

TAG = TAGS.get(OS)

class TestDancerAppExTemplate:

Expand All @@ -18,52 +20,47 @@ def setup_method(self):
json_raw_file = self.oc_api.get_raw_url_for_json(
container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json"
)
self.oc_api.import_is(path=json_raw_file, name="perl")
self.oc_api.import_is(path=json_raw_file, name="perl", skip_check=True)

def teardown_method(self):
self.oc_api.delete_project()


def test_local_template_inside_cluster(self):
if not is_test_allowed(OS, VERSION):
pytest.skip(f"Local templates are not supported for {OS} and {VERSION}")
expected_output = "Welcome to your Dancer application"
template_json = "../openshift/templates/dancer.json"
assert self.oc_api.deploy_template(
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
template=template_json,
name_in_template="dancer-example",
expected_output=expected_output,
openshift_args=[
"SOURCE_REPOSITORY_REF=master",
f"PERL_VERSION={VERSION}",
f"PERL_VERSION={VERSION}{TAG}",
"NAME=dancer-example"
]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.is_template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_inside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)

def test_template_inside_cluster(self):
if not is_test_allowed(OS, VERSION):
pytest.skip(f"Local templates are not supported for {OS} and {VERSION}")
expected_output = "Welcome to your Dancer application"
template_json = self.oc_api.get_raw_url_for_json(
container="dancer-ex", dir="openshift/templates", filename="dancer.json"
)
assert self.oc_api.deploy_template(
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
openshift_args=["SOURCE_REPOSITORY_REF=master", f"PERL_VERSION={VERSION}", "NAME=dancer-example"]
openshift_args=[
"SOURCE_REPOSITORY_REF=master",
f"PERL_VERSION={VERSION}{TAG}",
"NAME=dancer-example"]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.is_template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_inside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)

def test_template_by_request(self):
expected_output = "Welcome to your Dancer application"
template_json = self.oc_api.get_raw_url_for_json(
container="dancer-ex", dir="openshift/templates", filename="dancer.json"
)
assert self.oc_api.deploy_template(
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
openshift_args=["SOURCE_REPOSITORY_REF=master", f"PERL_VERSION={VERSION}", "NAME=dancer-example"]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_outside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)
41 changes: 14 additions & 27 deletions tests/test_dancer_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

from container_ci_suite.openshift import OpenShiftAPI

from constants import TAGS, is_test_allowed
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))

VERSION=os.getenv("SINGLE_VERSION")
if not VERSION:
VERSION="5.32-ubi8"
OS=os.getenv("OS")

TAG = TAGS.get(OS)

class TestDancerAppMySQLExTemplate:

Expand All @@ -18,33 +20,37 @@ def setup_method(self):
json_raw_file = self.oc_api.get_raw_url_for_json(
container="s2i-perl-container", dir="imagestreams", filename="perl-rhel.json"
)
self.oc_api.import_is(path=json_raw_file, name="perl")
self.oc_api.import_is(path=json_raw_file, name="perl", skip_check=True)
json_raw_file = self.oc_api.get_raw_url_for_json(
container="mysql-container", dir="imagestreams", filename="mysql-rhel.json"
)
self.oc_api.import_is(path=json_raw_file, name="mysql")
self.oc_api.import_is(path=json_raw_file, name="mysql", skip_check=True)

def teardown_method(self):
self.oc_api.delete_project()

def test_local_template_inside_cluster(self):
if not is_test_allowed(OS, VERSION):
pytest.skip(f"Local templates are not supported for {OS} and {VERSION}")
expected_output = "Welcome to your Dancer application"
template_json = "../openshift/templates/dancer-mysql-persistent.json"
assert self.oc_api.deploy_template(
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
openshift_args=[
"SOURCE_REPOSITORY_REF=master",
f"PERL_VERSION={VERSION}",
f"PERL_VERSION={VERSION}{TAG}",
"NAME=dancer-example",
"MYSQL_VERSION=8.0-el8"
]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.is_template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_inside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)

def test_template_inside_cluster(self):
if not is_test_allowed(OS, VERSION):
pytest.skip(f"Local templates are not supported for {OS} and {VERSION}")
expected_output = "Welcome to your Dancer application"
template_json = self.oc_api.get_raw_url_for_json(
container="dancer-ex", dir="openshift/templates", filename="dancer-mysql-persistent.json"
Expand All @@ -53,31 +59,12 @@ def test_template_inside_cluster(self):
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
openshift_args=[
"SOURCE_REPOSITORY_REF=master",
f"PERL_VERSION={VERSION}",
f"PERL_VERSION={VERSION}{TAG}",
"NAME=dancer-example",
"MYSQL_VERSION=8.0-el8"
]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.is_template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_inside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)

def test_template_by_request(self):
expected_output = "Welcome to your Dancer application"
template_json = self.oc_api.get_raw_url_for_json(
container="dancer-ex", dir="openshift/templates", filename="dancer-mysql-persistent.json"
)
assert self.oc_api.deploy_template(
template=template_json, name_in_template="dancer-example", expected_output=expected_output,
openshift_args=[
"SOURCE_REPOSITORY_REF=master",
f"PERL_VERSION={VERSION}",
"NAME=dancer-example",
"MYSQL_VERSION=8.0-el8"
]
)
assert self.oc_api.template_deployed(name_in_template="dancer-example")
assert self.oc_api.check_response_outside_cluster(
name_in_template="dancer-example", expected_output=expected_output
)