Skip to content

Commit

Permalink
Add support for s2i builds in httpd container
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Nov 28, 2024
1 parent 160459e commit ab3c028
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions test/container/test_httpd_s2i.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
image_tag = os.environ.get("IMAGE_NAME").split(":")[1]
test_dir = os.path.abspath(os.path.dirname(__file__))
pre_init_test_app = os.path.join(test_dir, "..", "pre-init-test-app")
self_cert_test = os.path.join(test_dir, "..", "self-signed-ssl")
sample_test_app = os.path.join(test_dir, "..", "sample-test-app")

app_paths = [
pre_init_test_app
]
app_params_pre = [pre_init_test_app]
app_params_sample = [sample_test_app]


@pytest.fixture(scope="module", params=app_paths)
def s2i_app(request):
@pytest.fixture(scope="module", params=app_params_pre)
def s2i_app_pre_init(request):
ci = S2IContainerImage(full_image_name)
app_name = os.path.basename(request.param)
s2i_app = ci.s2i_build_as_df(
Expand All @@ -40,14 +41,43 @@ def s2i_app(request):
s2i_app.cleanup_container()


class TestHttpdS2IContainer:
@pytest.fixture(scope="module", params=app_params_sample)
def s2i_sample_app(request):
ci = S2IContainerImage(full_image_name)
app_name = os.path.basename(request.param)
s2i_app = ci.s2i_build_as_df(
app_path=request.param,
s2i_args="--pull-policy=never",
src_image=full_image_name,
dst_image=f"{full_image_name}-{app_name}"
)
yield s2i_app
pass
if s2i_app:
s2i_app.cleanup_container()


@pytest.mark.usefixtures("s2i_app_pre_init")
class TestHttpdS2IPreInitContainer:

def test_run_pre_init_test(self, s2i_app):
def test_run_pre_init_test(self, s2i_app_pre_init):
print("run_pre_init_test")
assert s2i_app
assert s2i_app.create_container(cid_file="testing-app-pre-init", container_args="--user 1000")
cip = s2i_app.get_cip()
assert s2i_app_pre_init
assert s2i_app_pre_init.create_container(cid_file="testing-app-pre-init", container_args="--user 1000", image_name=s2i_app_pre_init.image_name)
cip = s2i_app_pre_init.get_cip()
assert cip
response = "This content was replaced by pre-init script."
assert s2i_app.test_response(url=f"{cip}", expected_code=200, expected_output=response)
assert s2i_app_pre_init.test_response(url=f"{cip}", expected_code=200, expected_output=response)


@pytest.mark.usefixtures("s2i_sample_app")
class TestHttpdS2ISampleAppContainer:

def test_self_cert_test(self, s2i_sample_app):
print("run_pre_init_test")
assert s2i_sample_app
assert s2i_sample_app.create_container(cid_file="testing-sample=app", container_args="--user 1000", image_name=s2i_sample_app.image_name)
cip = s2i_sample_app.get_cip()
assert cip
response = "This is a sample s2i application with static content."
assert s2i_sample_app.test_response(url=f"{cip}", expected_code=200, expected_output=response)

0 comments on commit ab3c028

Please sign in to comment.