Skip to content

OpenShift 4 tests for for shared_cluster #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
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
1 change: 1 addition & 0 deletions 3.11-minimal/test/__init__.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/constants.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_deploy_templates.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_helm_python_django_app.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_helm_python_imagestreams.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_imagestreams_quickstart.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_python_ex_standalone.py
1 change: 1 addition & 0 deletions 3.11-minimal/test/test_python_ex_template.py
1 change: 1 addition & 0 deletions 3.11/test/__init__.py
1 change: 1 addition & 0 deletions 3.11/test/constants.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/__init__.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/constants.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_deploy_templates.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_helm_python_django_app.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_helm_python_imagestreams.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_imagestreams_quickstart.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_python_ex_standalone.py
1 change: 1 addition & 0 deletions 3.12-minimal/test/test_python_ex_template.py
1 change: 1 addition & 0 deletions 3.12/test/__init__.py
1 change: 1 addition & 0 deletions 3.12/test/constants.py
1 change: 1 addition & 0 deletions 3.13/test/__init__.py
1 change: 1 addition & 0 deletions 3.13/test/constants.py
1 change: 1 addition & 0 deletions 3.6/test/__init__.py
1 change: 1 addition & 0 deletions 3.6/test/constants.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/__init__.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/constants.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_deploy_templates.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_helm_python_django_app.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_helm_python_imagestreams.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_imagestreams_quickstart.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_python_ex_standalone.py
1 change: 1 addition & 0 deletions 3.9-minimal/test/test_python_ex_template.py
1 change: 1 addition & 0 deletions 3.9/test/__init__.py
1 change: 1 addition & 0 deletions 3.9/test/constants.py
30 changes: 30 additions & 0 deletions manifest-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,36 @@ SYMLINK_RULES:
- src: ../../test/run-openshift-remote-cluster
dest: test/run-openshift-remote-cluster

- src: ../../test/run-openshift-pytest
dest: test/run-openshift-pytest

- src: ../../test/test_deploy_templates.py
dest: test/test_deploy_templates.py

- src: ../../test/test_imagestreams_quickstart.py
dest: test/test_imagestreams_quickstart.py

- src: ../../test/test_python_ex_standalone.py
dest: test/test_python_ex_standalone.py

- src: ../../test/test_python_ex_template.py
dest: test/test_python_ex_template.py

- src: ../../test/test_helm_python_django_app.py
dest: test/test_helm_python_django_app.py

- src: ../../test/test_helm_python_django_psql_persistent.py
dest: test/test_helm_python_django_psql_persistent.py

- src: ../../test/test_helm_python_imagestreams.py
dest: test/test_helm_python_imagestreams.py

- src: ../../test/constants.py
dest: test/constants.py

- src: ../../test/__init__.py
dest: test/__init__.py

- src: ../../common/test-lib.sh
dest: test/test-lib.sh

Expand Down
6 changes: 6 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ SYMLINK_RULES:
- src: ../../test/test_helm_python_imagestreams.py
dest: test/test_helm_python_imagestreams.py

- src: ../../test/constants.py
dest: test/constants.py

- src: ../../test/__init__.py
dest: test/__init__.py

- src: ../../common/test-lib.sh
dest: test/test-lib.sh

Expand Down
Empty file added test/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions test/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}

BRANCH_TO_TEST = "master"
13 changes: 8 additions & 5 deletions test/test_deploy_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
OS = os.getenv("TARGET")
OS = os.getenv("TARGET").lower()


BRANCH_TO_TEST = "2.2.x"
Expand All @@ -27,14 +27,14 @@
DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
IMAGE_TAG = "postgresql:12"
PSQL_VERSION = "12"
SHORT_VERSION = VERSION.replace(".", "")


# Replacement with 'test_python_s2i_templates'
class TestDeployTemplate:

def setup_method(self):
self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION)
assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG)
self.oc_api = OpenShiftAPI(pod_name_prefix=f"python-{SHORT_VERSION}-test", version=VERSION, shared_cluster=True)

def teardown_method(self):
self.oc_api.delete_project()
Expand All @@ -47,7 +47,10 @@ def teardown_method(self):
]
)
def test_python_template_inside_cluster(self, template):
service_name = "python-testing"
if OS == "rhel10":
pytest.skip("Do NOT test on rhel10. It is not released yet.")
assert self.oc_api.upload_image(DEPLOYED_PSQL_IMAGE, IMAGE_TAG)
service_name = f"python-{SHORT_VERSION}-test"
template_url = self.oc_api.get_raw_url_for_json(
container="django-ex", dir="openshift/templates", filename=template, branch=BRANCH_TO_TEST
)
Expand All @@ -62,7 +65,7 @@ def test_python_template_inside_cluster(self, template):
f"POSTGRESQL_VERSION={PSQL_VERSION}"
]
)
assert self.oc_api.template_deployed(name_in_template=service_name)
assert self.oc_api.is_template_deployed(name_in_template=service_name)
assert self.oc_api.check_response_inside_cluster(
name_in_template=service_name, expected_output="Welcome to your Django application on OpenShift"
)
79 changes: 27 additions & 52 deletions test/test_helm_python_django_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,30 @@

from container_ci_suite.helm import HelmChartsAPI

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

VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
OS = os.getenv("TARGET").lower()

TAG = TAGS.get(OS)
DEPLOYED_PSQL_IMAGE = "quay.io/centos7/postgresql-10-centos7:centos7"
IMAGE_TAG = "postgresql:10"
PSQL_VERSION = "10"

if VERSION == "3.11" or VERSION == "3.12":
DEPLOYED_PSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
IMAGE_TAG = "postgresql:12"
PSQL_VERSION = "12"
BRANCH_TO_TEST = "4.2.x"

class TestHelmPythonDjangoAppTemplate:

def setup_method(self):
package_name = "python-django-application"
package_name = "redhat-python-django-application"
path = test_dir
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, remote=True)
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True)
self.hc_api.clone_helm_chart_repo(
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
subdir="charts/redhat"
Expand All @@ -22,62 +37,22 @@ def setup_method(self):
def teardown_method(self):
self.hc_api.delete_project()

@pytest.mark.parametrize(
"version,branch",
[
("3.12-ubi9", "4.2.x"),
("3.12-ubi8", "4.2.x"),
("3.11-ubi9", "4.2.x"),
("3.11-ubi8", "4.2.x"),
("3.9-ubi9", "master"),
("3.9-ubi8", "master"),
("3.6-ubi8", "master"),
],
)
def test_django_application_curl_output(self, version, branch):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "python-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "python-django-application"
self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"python_version": version,
"namespace": self.hc_api.namespace,
"source_repository_ref": branch,
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example")
assert self.hc_api.test_helm_curl_output(
route_name="django-example",
expected_str="Welcome to your Django application"
)

@pytest.mark.parametrize(
"version,branch",
[
("3.12-ubi9", "4.2.x"),
("3.12-ubi8", "4.2.x"),
("3.11-ubi9", "4.2.x"),
("3.11-ubi8", "4.2.x"),
("3.9-ubi9", "master"),
("3.9-ubi8", "master"),
("3.6-ubi8", "master"),
],
)
def test_django_application_helm_test(self, version, branch):
self.hc_api.package_name = "python-imagestreams"
def test_django_application_helm_test(self):
if OS == "rhel10":
pytest.skip("Do NOT test on rhel10. It is not released yet.")
new_version = VERSION
if "minimal" in VERSION:
new_version = VERSION.replace("-minimal", "")
self.hc_api.package_name = "redhat-python-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "python-django-application"
self.hc_api.package_name = "redhat-python-django-application"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"python_version": version,
"python_version": f"{new_version}{TAG}",
"namespace": self.hc_api.namespace,
"source_repository_ref": branch,
"source_repository_ref": BRANCH_TO_TEST,
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="django-example")
Expand Down
Loading