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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion test/test-lib-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ django-postgresql-persistent.json"
if [[ "${VERSION}" == "3.11" ]] || [[ "${VERSION}" == "3.12" ]]; then
postgresql_image="quay.io/sclorg/postgresql-12-c8s|postgresql:12"
postgresql_version="12"
branch="4.2.x"
else
postgresql_image="quay.io/centos7/postgresql-10-centos7:centos7|postgresql:10"
postgresql_version="10"
branch="2.2.x"
fi
for template in $EPHEMERAL_TEMPLATES; do
branch="2.2.x"

ct_os_test_template_app "$IMAGE_NAME" \
"https://raw.githubusercontent.com/sclorg/django-ex/${branch}/openshift/templates/${template}" \
python \
Expand Down
2 changes: 1 addition & 1 deletion test/test_deploy_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class TestDeployTemplate:

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

def teardown_method(self):
Expand Down
77 changes: 41 additions & 36 deletions test/test_helm_python_django_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@

test_dir = Path(os.path.abspath(os.path.dirname(__file__)))

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

TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}
TAG = TAGS.get(OS, None)
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 = "master"
if VERSION == "3.11" or VERSION == "3.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,31 +44,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):
def test_django_application_curl_output(self):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "python-imagestreams"
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"
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 All @@ -55,29 +68,21 @@ def test_django_application_curl_output(self, version, branch):
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):
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
68 changes: 32 additions & 36 deletions test/test_helm_python_django_psql_persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@

test_dir = Path(os.path.abspath(os.path.dirname(__file__)))

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

TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}
TAG = TAGS.get(OS, None)
BRANCH_TO_TEST = "master"
if VERSION == "3.11" or VERSION == "3.12":
BRANCH_TO_TEST = "4.2.x"

class TestHelmPythonDjangoPsqlTemplate:

def setup_method(self):
package_name = "django-psql-persistent"
package_name = "redhat-django-psql-persistent"
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,34 +35,24 @@ 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_psql_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 = "postgresql-imagestreams"
self.hc_api.package_name = "redhat-postgresql-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "python-imagestreams"
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 = "django-psql-persistent"
self.hc_api.package_name = "redhat-django-psql-persistent"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"python_version": version,
"python_version": f"{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-psql")
Expand All @@ -58,32 +61,25 @@ def test_django_psql_curl_output(self, version, branch):
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_psql_helm_test(self, version, branch):
self.hc_api.package_name = "postgresql-imagestreams"
new_version = VERSION
if "minimal" in VERSION:
new_version = VERSION.replace("-minimal", "")
if OS == "rhel10":
pytest.skip("Do NOT test on rhel10. Imagestreams are not ready yet.")
self.hc_api.package_name = "redhat-postgresql-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "python-imagestreams"
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 = "django-psql-persistent"
self.hc_api.package_name = "redhat-django-psql-persistent"
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-psql")
Expand Down
4 changes: 2 additions & 2 deletions test/test_helm_python_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class TestHelmRHELPythonImageStreams:

def setup_method(self):
package_name = "python-imagestreams"
package_name = "redhat-python-imagestreams"
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 Down
7 changes: 5 additions & 2 deletions test/test_imagestreams_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

TAGS = {
"rhel8": "-ubi8",
"rhel9": "-ubi9"
"rhel9": "-ubi9",
"rhel10": "-ubi10",
}

TAG = TAGS.get(OS, None)
Expand All @@ -40,7 +41,7 @@
class TestImagestreamsQuickstart:

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

def teardown_method(self):
Expand All @@ -54,6 +55,8 @@ def teardown_method(self):
]
)
def test_python_template_inside_cluster(self, template):
if OS == "rhel10":
pytest.skip("Do not test on RHEL10. Imagestreams are not ready yet.")
service_name = "python-testing"
template_url = self.oc_api.get_raw_url_for_json(
container="django-ex", dir="openshift/templates", filename=template, branch=BRANCH_TO_TEST
Expand Down
2 changes: 1 addition & 1 deletion test/test_python_ex_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class TestPythonExTemplate:

def setup_method(self):
self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION)
self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION, shared_cluster=True)

def teardown_method(self):
self.oc_api.delete_project()
Expand Down
2 changes: 1 addition & 1 deletion test/test_python_ex_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class TestPythonExTemplate:

def setup_method(self):
self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION)
self.oc_api = OpenShiftAPI(pod_name_prefix="python-testing", version=VERSION, shared_cluster=True)

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