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
1 change: 1 addition & 0 deletions 2.4-micro/test/conftest.py
1 change: 0 additions & 1 deletion 2.4-micro/test/constants.py

This file was deleted.

1 change: 1 addition & 0 deletions 2.4/test/conftest.py
1 change: 0 additions & 1 deletion 2.4/test/constants.py

This file was deleted.

38 changes: 38 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import sys

from pathlib import Path
from collections import namedtuple

from container_ci_suite.utils import check_variables

if not check_variables():
sys.exit(1)

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

TEST_DIR = Path(__file__).parent.absolute()
Vars = namedtuple(
"Vars",
[
"OS",
"TAG",
"VERSION",
"IMAGE_NAME",
"TEST_DIR",
],
)
OS = os.getenv("TARGET").lower()
VERSION = os.getenv("VERSION")

VARS = Vars(
OS=OS,
TAG=TAGS.get(OS),
VERSION=VERSION,
IMAGE_NAME=os.getenv("IMAGE_NAME"),
TEST_DIR=TEST_DIR,
)
5 changes: 0 additions & 5 deletions test/constants.py

This file was deleted.

26 changes: 9 additions & 17 deletions test/test_ocp_ex_template.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
import os
import sys

from pathlib import Path

from container_ci_suite.openshift import OpenShiftAPI
from container_ci_suite.utils import get_service_image, check_variables

if not check_variables():
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
sys.exit(1)
from container_ci_suite.utils import get_service_image


TEST_DIR = Path(os.path.abspath(os.path.dirname(__file__)))
VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
from conftest import VARS


class TestHTTPDExExampleRepo:
def setup_method(self):
self.template_name = get_service_image(IMAGE_NAME)
self.oc_api = OpenShiftAPI(pod_name_prefix=self.template_name, version=VERSION)
self.template_name = get_service_image(VARS.IMAGE_NAME)
self.oc_api = OpenShiftAPI(
pod_name_prefix=self.template_name,
version=VARS.VERSION,
shared_cluster=True,
)

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

def test_httpd_ex_template_inside_cluster(self):
assert self.oc_api.deploy_s2i_app(
image_name=IMAGE_NAME,
image_name=VARS.IMAGE_NAME,
app="https://github.com/sclorg/httpd-ex#master",
context=".",
)
Expand Down
26 changes: 10 additions & 16 deletions test/test_ocp_imagestream_s2i.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import os
import sys

from container_ci_suite.openshift import OpenShiftAPI
from container_ci_suite.utils import get_service_image, check_variables

from container_ci_suite.utils import get_service_image

if not check_variables():
print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
sys.exit(1)

IMAGE_NAME = os.getenv("IMAGE_NAME")
OS = os.getenv("OS")
VERSION = os.getenv("VERSION")
from conftest import VARS


class TestHTTPDImagestreamS2I:
def setup_method(self):
self.template_name = get_service_image(IMAGE_NAME)
self.oc_api = OpenShiftAPI(pod_name_prefix=self.template_name, version=VERSION)
self.template_name = get_service_image(VARS.IMAGE_NAME)
self.oc_api = OpenShiftAPI(
pod_name_prefix=self.template_name,
version=VARS.VERSION,
shared_cluster=True
)

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

def test_inside_cluster(self):
os_name = "".join(i for i in OS if not i.isdigit())
os_name = "".join(i for i in VARS.OS if not i.isdigit())
assert self.oc_api.deploy_imagestream_s2i(
imagestream_file=f"imagestreams/httpd-{os_name}.json",
image_name=IMAGE_NAME,
image_name=VARS.IMAGE_NAME,
app="https://github.com/sclorg/httpd-container.git",
context="examples/sample-test-app",
service_name=self.template_name,
Expand Down
16 changes: 3 additions & 13 deletions test/test_ocp_imagestreams.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import os
import sys

from pathlib import Path

from container_ci_suite.imagestreams import ImageStreamChecker
from container_ci_suite.utils import check_variables

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

if not check_variables():
print("At least one variable from IMAGE_NAME, OS, SINGLE_VERSION is missing.")
sys.exit(1)
from conftest import VARS


class TestLatestImagestreams:

def setup_method(self):
self.isc = ImageStreamChecker(working_dir=TEST_DIR.parent.parent)
self.isc = ImageStreamChecker(working_dir=VARS.TEST_DIR.parent.parent)

def test_latest_imagestream(self):
self.latest_version = self.isc.get_latest_version()
assert self.latest_version != ""
assert self.latest_version
self.isc.check_imagestreams(self.latest_version)
22 changes: 7 additions & 15 deletions test/test_ocp_integration.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import os
import sys

from container_ci_suite.openshift import OpenShiftAPI
from container_ci_suite.utils import get_service_image, check_variables


if not check_variables():
print("At least one variable from IMAGE_NAME, OS, VERSION is missing.")
sys.exit(1)
from container_ci_suite.utils import get_service_image


VERSION = os.getenv("VERSION")
IMAGE_NAME = os.getenv("IMAGE_NAME")
from conftest import VARS


class TestHTTPDIntegrationTemplate:
def setup_method(self):
self.template_name = get_service_image(IMAGE_NAME)
self.oc_api = OpenShiftAPI(pod_name_prefix=self.template_name, version=VERSION)
self.template_name = get_service_image(VARS.IMAGE_NAME)
self.oc_api = OpenShiftAPI(
pod_name_prefix=self.template_name, version=VARS.VERSION, shared_cluster=True
)

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

def test_httpd_ex_template_inside_cluster(self):
assert self.oc_api.deploy_s2i_app(
image_name=IMAGE_NAME,
image_name=VARS.IMAGE_NAME,
app="https://github.com/sclorg/httpd-container.git",
context="examples/sample-test-app",
)
Expand Down
16 changes: 9 additions & 7 deletions test/test_ocp_shared_helm_imagestreams.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import os

import pytest
from pathlib import Path

from container_ci_suite.helm import HelmChartsAPI

test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
from conftest import VARS


class TestHelmRHELHttpdImageStreams:

def setup_method(self):
package_name = "redhat-httpd-imagestreams"
path = test_dir
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True)
self.hc_api = HelmChartsAPI(
path=VARS.TEST_DIR,
package_name=package_name,
tarball_dir=VARS.TEST_DIR,
shared_cluster=True
)
self.hc_api.clone_helm_chart_repo(
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
repo_url="https://github.com/sclorg/helm-charts",
repo_name="helm-charts",
subdir="charts/redhat"
)

Expand Down
43 changes: 15 additions & 28 deletions test/test_ocp_shared_helm_template.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,42 @@
import os
import sys

from pathlib import Path

from container_ci_suite.helm import HelmChartsAPI
from container_ci_suite.utils import check_variables

from constants import TAGS


if not check_variables():
print("At least one variable from OS, VERSION is missing.")
sys.exit(1)

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

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

TAG = TAGS.get(OS)
from conftest import VARS


class TestHelmHTTPDTemplate:

def setup_method(self):
package_name = "redhat-httpd-template"
path = test_dir
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True)
self.hc_api = HelmChartsAPI(
path=VARS.TEST_DIR, package_name=package_name,
tarball_dir=VARS.TEST_DIR,
shared_cluster=True
)
self.hc_api.clone_helm_chart_repo(
repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts",
repo_url="https://github.com/sclorg/helm-charts",
repo_name="helm-charts",
subdir="charts/redhat"
)

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

def test_package_persistent_by_helm_chart_test(self):
new_version = VERSION
if "micro" in VERSION:
new_version = VERSION.replace("-micro", "")
new_version = VARS.VERSION
if "micro" in VARS.VERSION:
new_version = VARS.VERSION.replace("-micro", "")
self.hc_api.package_name = "redhat-httpd-imagestreams"
self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "redhat-httpd-template"
self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"httpd_version": f"{new_version}{TAG}",
"httpd_version": f"{new_version}{VARS.TAG}",
"namespace": self.hc_api.namespace
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="httpd-example")
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your static httpd application on OpenShift"])
assert self.hc_api.test_helm_chart(
expected_str=["Welcome to your static httpd application on OpenShift"]
)