Skip to content

Commit c359e76

Browse files
committed
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) Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
1 parent 1773c84 commit c359e76

25 files changed

+679
-0
lines changed

2.5/test/conftest.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
3+
import sys
4+
5+
from pathlib import Path
6+
from collections import namedtuple
7+
from pytest import skip
8+
9+
from container_ci_suite.utils import check_variables
10+
11+
12+
if not check_variables():
13+
sys.exit(1)
14+
15+
TAGS = {
16+
"rhel8": "-ubi8",
17+
"rhel9": "-ubi9",
18+
"rhel10": "-ubi10",
19+
}
20+
BRANCH_TO_TEST = "master"
21+
Vars = namedtuple(
22+
"Vars",
23+
[
24+
"OS",
25+
"TAG",
26+
"VERSION",
27+
"IMAGE_NAME",
28+
"SHORT_VERSION",
29+
"TEST_DIR",
30+
"BRANCH_TO_TEST",
31+
],
32+
)
33+
OS = os.getenv("TARGET").lower()
34+
VERSION = os.getenv("VERSION")
35+
BRANCH_TO_TEST = "master"
36+
if VERSION == "3.1" or VERSION == "3.3":
37+
BRANCH_TO_TEST = "3.3"
38+
39+
VARS = Vars(
40+
OS=OS,
41+
TAG=TAGS.get(OS),
42+
VERSION=VERSION,
43+
IMAGE_NAME=os.getenv("IMAGE_NAME"),
44+
SHORT_VERSION=VERSION.replace(".", ""),
45+
TEST_DIR=Path(__file__).parent.absolute(),
46+
BRANCH_TO_TEST=BRANCH_TO_TEST,
47+
)
48+
49+
50+
def fips_enabled():
51+
"""
52+
Check if FIPS is enabled on the system.
53+
"""
54+
if os.path.exists("/proc/sys/crypto/fips_enabled"):
55+
return Path("/proc/sys/crypto/fips_enabled").read_text() == "1"
56+
return False
57+
58+
59+
def skip_fips_tests_rhel8():
60+
"""
61+
Skip FIPS tests on RHEL8.
62+
"""
63+
if VARS.OS == "rhel8" and fips_enabled():
64+
skip("Skipping FIPS tests on RHEL8 because FIPS is enabled.")

2.5/test/run-pytest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/run-pytest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_application.py

2.5/test/test_container_basics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_basics.py

2.5/test/test_container_fips.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_fips.py

3.0/test/conftest.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
3+
import sys
4+
5+
from pathlib import Path
6+
from collections import namedtuple
7+
from pytest import skip
8+
9+
from container_ci_suite.utils import check_variables
10+
11+
12+
if not check_variables():
13+
sys.exit(1)
14+
15+
TAGS = {
16+
"rhel8": "-ubi8",
17+
"rhel9": "-ubi9",
18+
"rhel10": "-ubi10",
19+
}
20+
BRANCH_TO_TEST = "master"
21+
Vars = namedtuple(
22+
"Vars",
23+
[
24+
"OS",
25+
"TAG",
26+
"VERSION",
27+
"IMAGE_NAME",
28+
"SHORT_VERSION",
29+
"TEST_DIR",
30+
"BRANCH_TO_TEST",
31+
],
32+
)
33+
OS = os.getenv("TARGET").lower()
34+
VERSION = os.getenv("VERSION")
35+
BRANCH_TO_TEST = "master"
36+
if VERSION == "3.1" or VERSION == "3.3":
37+
BRANCH_TO_TEST = "3.3"
38+
39+
VARS = Vars(
40+
OS=OS,
41+
TAG=TAGS.get(OS),
42+
VERSION=VERSION,
43+
IMAGE_NAME=os.getenv("IMAGE_NAME"),
44+
SHORT_VERSION=VERSION.replace(".", ""),
45+
TEST_DIR=Path(__file__).parent.absolute(),
46+
BRANCH_TO_TEST=BRANCH_TO_TEST,
47+
)
48+
49+
50+
def fips_enabled():
51+
"""
52+
Check if FIPS is enabled on the system.
53+
"""
54+
if os.path.exists("/proc/sys/crypto/fips_enabled"):
55+
return Path("/proc/sys/crypto/fips_enabled").read_text() == "1"
56+
return False
57+
58+
59+
def skip_fips_tests_rhel8():
60+
"""
61+
Skip FIPS tests on RHEL8.
62+
"""
63+
if VARS.OS == "rhel8" and fips_enabled():
64+
skip("Skipping FIPS tests on RHEL8 because FIPS is enabled.")

3.0/test/run-pytest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/run-pytest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_application.py

3.0/test/test_container_basics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_basics.py

3.0/test/test_container_fips.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test/test_container_fips.py

0 commit comments

Comments
 (0)