1515
1616
1717def build_s2i_app (app_path : Path ) -> ContainerTestLib :
18+ """
19+ Build S2I Container based on the app_path input
20+ :param: app_path: path to example directory
21+ :return new instance of ContainerTestLib
22+ """
1823 container_lib = ContainerTestLib (IMAGE_NAME )
1924 app_name = app_path .name
2025 s2i_app = container_lib .build_as_df (
@@ -38,7 +43,9 @@ def teardown_method(self):
3843 def test_run_app_test (self , example_app_test ):
3944 version = VERSION .replace ("-micro" , "" )
4045 cid_file_name = example_app_test .app_name
46+ # Create container with --user 10001
4147 assert self .s2i_app .create_container (cid_file_name = cid_file_name , container_args = "--user 10001" )
48+ # Wait till container does not start
4249 assert ContainerImage .wait_for_cid (cid_file_name = cid_file_name )
4350 cid = self .s2i_app .get_cid (cid_file_name = cid_file_name )
4451 assert cid
@@ -47,7 +54,9 @@ def test_run_app_test(self, example_app_test):
4754 command = PodmanCLIWrapper .podman_get_file_content (
4855 cid_file_name = cid , filename = "/opt/app-root/etc/nginx.d/default.conf"
4956 )
57+ # Checks if nginx configuration contains resolver
5058 assert re .search ("resolver" , command )
59+ # Checks if nginx configuration DO NOT container "DNS_SERVER"
5160 assert not re .search ("DNS_SERVER" , command )
5261 assert PodmanCLIWrapper .podman_run_command (
5362 f"--rm { example_app_test .image_name } /bin/bash -c 'nginx -v'"
@@ -83,6 +92,7 @@ def test_run_app_test(self):
8392 assert cid
8493 cip = self .s2i_app .get_cip (cid_file_name = cid_file_name )
8594 assert cip
95+ # Checks if returns header of Perl version
8696 perl_version = PodmanCLIWrapper .podman_exec_shell_command (cid_file_name = cid , cmd = "perl -e 'print \" $^V\" '" )
8797 assert self .s2i_app .test_response (
8898 url = f"http://{ cip } " , port = 8080 ,
@@ -115,14 +125,15 @@ def test_log_output(self, s2i_log_test):
115125 url = f"http://{ cip } " , port = 8080 , expected_output = "NGINX is working"
116126 )
117127 assert '"GET / HTTP/1.1" 200' in s2i_log_test .get_logs (cid_file_name = cid_file_name )
128+ # Check if /nothing-at-all is really no accessible
118129 assert self .s2i_app .test_response (
119130 url = f"http://{ cip } " , port = 8080 , page = "/nothing-at-all" , expected_code = 404
120131 )
121132 logs = self .s2i_app .get_logs (cid_file_name = cid_file_name )
122133 assert logs
134+ # Checks logs container 'failed' and 'No such file or directory'
123135 assert re .search ("open.*failed.*No such file or directory" , logs )
124136
125- # test_log_volume_output
126137 def test_log_volume_output (self , s2i_log_test ):
127138 cid_file_name = "test-app"
128139 s2i_log_test .set_new_image (image_name = f"{ IMAGE_NAME } -{ cid_file_name } " )
@@ -138,9 +149,11 @@ def test_log_volume_output(self, s2i_log_test):
138149 cid_file_name = cid ,
139150 filename = "/var/log/nginx/access.log"
140151 )
152+ # Check if /nothing-at-all is really no accessible
141153 assert self .s2i_app .test_response (
142154 url = f"http://{ cip } " , port = 8080 , page = "/nothing-at-all" , expected_code = 404
143155 )
156+ # Check if /nothing-at-all is really mentioned in 'access.log'
144157 assert '"GET /nothing-at-all HTTP/1.1" 404' in PodmanCLIWrapper .podman_get_file_content (
145158 cid_file_name = cid ,
146159 filename = "/var/log/nginx/access.log"
@@ -149,5 +162,6 @@ def test_log_volume_output(self, s2i_log_test):
149162 cid_file_name = cid ,
150163 filename = "/var/log/nginx/error.log"
151164 )
165+ # Checks logs container 'failed' and 'No such file or directory'
152166 assert re .search ("open.*failed.*No such file or directory" , logs_to_check )
153167
0 commit comments