Skip to content

Conversation

@phracek
Copy link
Member

@phracek phracek commented Nov 6, 2025

Add Container PyTest suite to s2i-ruby container.
Migration matrix is following:

For db, puma, rack applications are classes:
db -> TestRubyHelloWorldContainer
puma -> TestRubyPumaTestAppContainer
rack -> TestRubyRackTestAppContainer

test_docker_run_usage -> test_container_basics.py->TestS2IRubyContainer(test_docker_run_usage)
test_application -> test_application in each class
test_connection -> test_application in each class in assert
test_response -> test_application in each class in assert
test_scl_usage -> test_container_basics.py->TestS2IRubyContainer(test_scl_usage)
test_npm_functionality -> test_container_basics.py->TestRubyNPMtestContainer
test_ruby_fips_mode -> test_container_fips.py->TestRubyFipsModeContainer(test_fips_mode)
test_ruby_fips_s2i_app -> test_container_fips.TestRubyFipsApplicationContainer(test_application)
test_from_dockerfile -> test_container_basics.py -> TestS2IRubyContainer(test_dockerfiles)
test_from_dockerfile.s2i -> test_container_basics.py -> TestS2IRubyContainer(test_dockerfiles)

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Pull Request validation

Failed

🔴 Review - Missing review from a member (1 required)

Success

🟢 CI - All checks have passed

@phracek
Copy link
Member Author

phracek commented Nov 6, 2025

[test-pytest][test-openshift-pytest]

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Testing Farm results

namecomposearchstatusstarted (UTC)timelogs
Fedora - PyTest - 3.3Fedora-latestx86_64✅ passed17.12.2025 09:08:0310min 6stest pipeline
RHEL10 - PyTest - OpenShift 4 - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:30:5623min 55stest pipeline
CentOS Stream 10 - PyTest - 3.3CentOS-Stream-10x86_64✅ passed17.12.2025 09:08:1310min 20stest pipeline
RHEL8 - PyTest - OpenShift 4 - 2.5RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:28:4034min test pipeline
RHEL8 - PyTest - OpenShift 4 - 3.3RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:29:1522min 25stest pipeline
RHEL9 - PyTest - OpenShift 4 - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:33:2128min 42stest pipeline
RHEL8 - PyTest - 3.3RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:08:1419min 57stest pipeline
RHEL9 - PyTest - OpenShift 4 - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:28:4342min 47stest pipeline
RHEL9 - PyTest - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0524min 43stest pipeline
RHEL8 - PyTest - 2.5RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:20:4618min 42stest pipeline
RHEL9 - PyTest - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0432min 7stest pipeline
RHEL10 - PyTest - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:08:4519min 25stest pipeline
Fedora - 3.3Fedora-latestx86_64✅ passed17.12.2025 09:08:0510min 34stest pipeline
CentOS Stream 10 - 3.3CentOS-Stream-10x86_64✅ passed17.12.2025 09:21:0410min 19stest pipeline
RHEL10 - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:08:1720min 11stest pipeline
RHEL8 - 3.3RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:08:0419min 30stest pipeline
RHEL10 - FIPS Enabled - 3.3RHEL-10-Nightlyx86_64✅ passed18.11.2025 15:35:1220min 46stest pipeline
RHEL8 - OpenShift 4 - 3.3RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:29:0622min 53stest pipeline
RHEL9 - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0325min 25stest pipeline
RHEL8 - 2.5RHEL-8.10.0-Nightlyx86_64✅ passed18.11.2025 15:35:1522min 13stest pipeline
RHEL9 - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:2033min 15stest pipeline
RHEL9 - FIPS Enabled - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0534min 30stest pipeline
RHEL9 - OpenShift 4 - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:32:3527min 38stest pipeline
RHEL9 - FIPS Enabled - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0441min 52stest pipeline
RHEL10 - OpenShift 4 - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:32:2923min 25stest pipeline
RHEL8 - OpenShift 4 - 2.5RHEL-8.10.0-Nightlyx86_64✅ passed17.12.2025 09:32:3730min 49stest pipeline
RHEL9 - OpenShift 4 - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:29:0736min 28stest pipeline
RHEL10 - Unsubscribed host - PyTest - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:08:1518min 55stest pipeline
RHEL10 - Unsubscribed host - 3.3RHEL-10-Nightlyx86_64✅ passed17.12.2025 09:08:5019min 58stest pipeline
RHEL9 - Unsubscribed host - PyTest - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:0623min 59stest pipeline
RHEL9 - Unsubscribed host - 3.3RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:1923min 46stest pipeline
RHEL9 - Unsubscribed host - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:08:1930min 49stest pipeline
RHEL9 - Unsubscribed host - PyTest - 3.0RHEL-9.6.0-Nightlyx86_64✅ passed17.12.2025 09:20:4525min 56stest pipeline

@phracek
Copy link
Member Author

phracek commented Nov 7, 2025

[test-pytest][test-openshift-pytest]

@phracek
Copy link
Member Author

phracek commented Nov 18, 2025

[test-all]

Migration matrix is following:

For db, puma, rack applications are classes:
db -> TestRubyHelloWorldContainer
puma -> TestRubyPumaTestAppContainer
rack -> TestRubyRackTestAppContainer

test_docker_run_usage -> test_container_basics.py->TestS2IRubyContainer(test_docker_run_usage)

test_application -> test_application in each class

test_connection -> test_application in each class in assert

test_response -> test_application in each class in assert

test_scl_usage -> test_container_basics.py->TestS2IRubyContainer(test_scl_usage)

test_npm_functionality -> test_container_basics.py->TestRubyNPMtestContainer

test_ruby_fips_mode ->
test_container_fips.py->TestRubyFipsModeContainer(test_fips_mode)

test_ruby_fips_s2i_app ->
test_container_fips.TestRubyFipsApplicationContainer(test_application)

test_from_dockerfile -> test_container_basics.py ->
TestS2IRubyContainer(test_dockerfiles)

test_from_dockerfile.s2i -> test_container_basics.py ->
TestS2IRubyContainer(test_dockerfiles)

Signed-off-by: Petr "Stone" Hracek <[email protected]>
Do not run FIPS tests on RHEL8

Signed-off-by: Petr "Stone" Hracek <[email protected]>
Fix skipping RHEL8 tests for FIPS.

Signed-off-by: Petr "Stone" Hracek <[email protected]>
Build app once and test it.

Signed-off-by: Petr "Stone" Hracek <[email protected]>
Signed-off-by: Petr "Stone" Hracek <[email protected]>
@phracek
Copy link
Member Author

phracek commented Dec 17, 2025

Rebased agains master.

[test-all]

Copy link
Contributor

@jackorp jackorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot promise that this review is by any means exhaustive to the last letter of the changes.

Bar the incorrect docstrings, there are some opportunities to refactor, PTAL.

Comment on lines +53 to +55
BRANCH_TO_TEST = "master"
if VERSION == "3.1" or VERSION == "3.3":
BRANCH_TO_TEST = "3.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems as kind of very general name. How about:

TEST_APP_BRANCH = "master"
if VERSION == "3.1" or VERSION == "3.3":
    TEST_APP_BRANCH = "3.3"

Also since we are going to some language that's not stringly typed, how about:

Suggested change
BRANCH_TO_TEST = "master"
if VERSION == "3.1" or VERSION == "3.3":
BRANCH_TO_TEST = "3.3"
TEST_APP_BRANCH = "master"
if VERSION and float(VERSION) >= 3.1 :
TEST_APP_BRANCH = "3.3"

Unless python has some support for versions (in Ruby, we could use e.g. Gem::Version class for semantically proper version comparisons)

In this case, only retyping the VERSION here so far, first file I am seeing now.

#!/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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could the existence of the image be checked from the script and fail with proper error message if it is not available?

Should it fail if IMAGE_NAME is not available?

Comment on lines +51 to +66
if VARS.OS == "rhel8":
pytest.skip("Do not execute on RHEL8")
if fips_enabled():
output = PodmanCLIWrapper.podman_run_command_and_remove(
cid_file_name={VARS.IMAGE_NAME},
cmd="ruby -ropenssl -e 'exit OpenSSL.fips_mode'",
)
print(f"FIPS is enabled {output}")
assert output
else:
output = PodmanCLIWrapper.podman_run_command_and_remove(
cid_file_name=f"{VARS.IMAGE_NAME}-{self.app.app_name}",
cmd="ruby -ropenssl -e 'exit !OpenSSL.fips_mode'",
)
print(f"FIPS is disable {output}")
assert not output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this works correctly, but I am not sure what is being asserted.

So, there are 3 possibilities based on how well I read PodmanCLIWrapper.podman_run_command_and_remove

  • returncode is returned, what is outlined here works because returncode is returned.
  • STDOUT &&/|| STDERR output is present, what is outlined here does not work and will blow up the moment our assumptions were wrong. (for example, we get a false positive/negative)
  • I read function stack incorrectly and it all just works.

test/run-pytest Outdated
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
# SINGLE_VERSION specifies the major version of the MariaDB in format of X.Y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# SINGLE_VERSION specifies the major version of the MariaDB in format of X.Y
# SINGLE_VERSION Specifies the image version - (must match with subdirectory in repo)

comment copy from common/build.sh

Comment on lines +75 to +78
"""
Test if building nginx-container based on
examples/Dockerfile works
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
Test if building nginx-container based on
examples/Dockerfile works
"""
Test if building apps based on Containerfiles in
examples/ works

"""
self.oc_api.delete_project()

def test_dancer_ex_template_inside_cluster(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dancer_ex? I assume that's incorrect

Suggested change
def test_dancer_ex_template_inside_cluster(self):
def test_rails_ex_template_inside_cluster(self):

from conftest import VARS


DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move to conftest.py? @phracek

I think the cases here are that the rails ex either has a template which specifies the image, or we are looking for a specific image.

Either way, the app either depends on specific PGSQL of version XYZ, or we will want to move it to later releases/distros. Using conftest as a single place might be advantageous.

from conftest import VARS


DEPLOYED_PGSQL_IMAGE = "quay.io/sclorg/postgresql-12-c8s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as before, but for completeness, maybe move to conftest.py.

@@ -0,0 +1,68 @@
import pytest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe merge the file with test_ocp_s2i_local_templates.py and instead of differing in only 1 method (in how the template is sourced), add 1 test method that is the difference. More opportunities to refactoring to less code present themselves if the files are merged.

from conftest import VARS


class TestHelmCakePHPTemplate:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class TestHelmCakePHPTemplate:
class TestHelmRailsRubyTemplate:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants