Skip to content

Commit

Permalink
Add container-ci-suite for testing ruby-container in Openshift 4 (#551)
Browse files Browse the repository at this point in the history
* Add PyTest suite for testing ruby container in OpenShift 4

* Add symlinks to each versions

* Get rid of testing OpenShift 3

* Get rid of conu. It is not used at all. Remove test_s2i.py from version 3.3 as well.

---------

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
  • Loading branch information
phracek authored Jul 4, 2024
1 parent 1582b56 commit 71aac15
Show file tree
Hide file tree
Showing 49 changed files with 336 additions and 98 deletions.
1 change: 0 additions & 1 deletion 2.5/test/run-conu

This file was deleted.

1 change: 0 additions & 1 deletion 2.5/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 2.5/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 2.5/test/test_ruby_ex_standalone.py
1 change: 1 addition & 0 deletions 2.5/test/test_ruby_latest_imagestreams.py
1 change: 0 additions & 1 deletion 2.5/test/test_s2i.py

This file was deleted.

1 change: 1 addition & 0 deletions 2.5/test/test_s2i_imagestreams.py
1 change: 1 addition & 0 deletions 2.5/test/test_s2i_integration.py
1 change: 1 addition & 0 deletions 2.5/test/test_s2i_local_templates.py
1 change: 1 addition & 0 deletions 2.5/test/test_s2i_rails_ex_templates.py
1 change: 0 additions & 1 deletion 3.0/test/run-conu

This file was deleted.

1 change: 0 additions & 1 deletion 3.0/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 3.0/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.0/test/test_ruby_ex_standalone.py
1 change: 1 addition & 0 deletions 3.0/test/test_ruby_latest_imagestreams.py
1 change: 0 additions & 1 deletion 3.0/test/test_s2i.py

This file was deleted.

1 change: 1 addition & 0 deletions 3.0/test/test_s2i_imagestreams.py
1 change: 1 addition & 0 deletions 3.0/test/test_s2i_integration.py
1 change: 1 addition & 0 deletions 3.0/test/test_s2i_local_templates.py
1 change: 1 addition & 0 deletions 3.0/test/test_s2i_rails_ex_templates.py
1 change: 0 additions & 1 deletion 3.1/test/run-conu

This file was deleted.

1 change: 0 additions & 1 deletion 3.1/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 3.1/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.1/test/test_ruby_ex_standalone.py
1 change: 1 addition & 0 deletions 3.1/test/test_ruby_latest_imagestreams.py
1 change: 0 additions & 1 deletion 3.1/test/test_s2i.py

This file was deleted.

1 change: 1 addition & 0 deletions 3.1/test/test_s2i_imagestreams.py
1 change: 1 addition & 0 deletions 3.1/test/test_s2i_integration.py
1 change: 1 addition & 0 deletions 3.1/test/test_s2i_local_templates.py
1 change: 1 addition & 0 deletions 3.1/test/test_s2i_rails_ex_templates.py
1 change: 0 additions & 1 deletion 3.3/test/run-conu

This file was deleted.

1 change: 0 additions & 1 deletion 3.3/test/run-openshift

This file was deleted.

1 change: 1 addition & 0 deletions 3.3/test/run-openshift-pytest
1 change: 1 addition & 0 deletions 3.3/test/test_ruby_ex_standalone.py
1 change: 1 addition & 0 deletions 3.3/test/test_ruby_latest_imagestreams.py
1 change: 0 additions & 1 deletion 3.3/test/test_s2i.py

This file was deleted.

1 change: 1 addition & 0 deletions 3.3/test/test_s2i_imagestreams.py
1 change: 1 addition & 0 deletions 3.3/test/test_s2i_integration.py
1 change: 1 addition & 0 deletions 3.3/test/test_s2i_local_templates.py
1 change: 1 addition & 0 deletions 3.3/test/test_s2i_rails_ex_templates.py
2 changes: 0 additions & 2 deletions test/run-conu

This file was deleted.

11 changes: 11 additions & 0 deletions test/run-openshift-pytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
# VERSION specifies the major version of the MariaDB in format of X.Y
# OS specifies RHEL version (e.g. OS=rhel7)
#

THISDIR=$(dirname ${BASH_SOURCE[0]})

cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_*.py
41 changes: 41 additions & 0 deletions test/test_ruby_ex_standalone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import sys

import pytest

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

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


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


# Replacement with 'test_python_s2i_app_ex'
class TestS2IRailsExTemplate:

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

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

def test_dancer_ex_template_inside_cluster(self):
service_name = "ruby-testing"
rails_ex_branch = "master"
if VERSION == "3.3":
rails_ex_branch = VERSION
assert self.oc_api.deploy_s2i_app(
image_name=IMAGE_NAME, app=f"https://github.com/sclorg/rails-ex#{rails_ex_branch}",
context=".",
service_name=service_name
)
assert self.oc_api.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 Rails application"
)
27 changes: 27 additions & 0 deletions test/test_ruby_latest_imagestreams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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)

VERSION = os.getenv("SINGLE_VERSION")


# Replacement with 'test_latest_imagestreams'
class TestLatestImagestreams:

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

def test_latest_imagestream(self):
self.latest_version = self.isc.get_latest_version()
assert self.latest_version != ""
self.isc.check_imagestreams(self.latest_version)
84 changes: 0 additions & 84 deletions test/test_s2i.py

This file was deleted.

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

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


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


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

SHORT_VERSION = "".join(VERSION.split("."))


class TestRubyImagestreams:

def setup_method(self):
self.oc_api = OpenShiftAPI(pod_name_prefix="ruby", version=VERSION)

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

def ruby(self):
service_name = f"ruby-{SHORT_VERSION}-testing"
assert self.oc_api.deploy_imagestream_s2i(
imagestream_file=f"{VERSION}/imagestreams/ruby-rhel.json",
image_name=IMAGE_NAME,
app="https://github.com/sclorg/s2i-ruby-container.git",
context=f"{VERSION}/test/puma-test-app"
)
assert self.oc_api.template_deployed(name_in_template=service_name)
assert self.oc_api.check_response_inside_cluster(
name_in_template=service_name, expected_output="Hello world!"
)
36 changes: 36 additions & 0 deletions test/test_s2i_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import sys

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

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


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


# Replacement with 'test_python_s2i_app_ex'
class TestS2IRubyTemplate:

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

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

def test_rails_template_inside_cluster(self):
service_name = "ruby-testing"
assert self.oc_api.deploy_s2i_app(
image_name=IMAGE_NAME, app=f"https://github.com/sclorg/s2i-ruby-container.git",
context=f"{VERSION}/test/puma-test-app",
service_name=service_name
)
assert self.oc_api.template_deployed(name_in_template=service_name)
assert self.oc_api.check_response_inside_cluster(
name_in_template=service_name, expected_output="Hello world!"
)
Loading

0 comments on commit 71aac15

Please sign in to comment.