Skip to content

Commit 0f8348b

Browse files
committed
tests/integration: Automate 'build' manual test
Signed-off-by: Monika Kairaityte <[email protected]>
1 parent 55ab3fa commit 0f8348b

File tree

3 files changed

+66
-23
lines changed

3 files changed

+66
-23
lines changed

test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ pluggy==1.4.0
2929
pyproject-api==1.6.1
3030
python-dotenv==1.0.1
3131
PyYAML==6.0.1
32+
requests
3233
tomlkit==0.12.4
3334
virtualenv==20.25.1

tests/integration/build/README.md

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import os
4+
import unittest
5+
6+
import requests
7+
8+
from tests.integration.test_podman_compose import podman_compose_path
9+
from tests.integration.test_podman_compose import test_path
10+
from tests.integration.test_utils import RunSubprocessMixin
11+
12+
13+
def compose_yaml_path():
14+
""" "Returns the path to the compose file used for this test module"""
15+
base_path = os.path.join(test_path(), "build")
16+
return os.path.join(base_path, "docker-compose.yml")
17+
18+
19+
class TestComposeBuild(unittest.TestCase, RunSubprocessMixin):
20+
def test_build(self):
21+
try:
22+
self.run_subprocess_assert_returncode([
23+
podman_compose_path(),
24+
"-f",
25+
compose_yaml_path(),
26+
"build",
27+
"--no-cache",
28+
])
29+
30+
self.run_subprocess_assert_returncode([
31+
podman_compose_path(),
32+
"-f",
33+
compose_yaml_path(),
34+
"up",
35+
"-d",
36+
])
37+
38+
request = requests.get('http://localhost:8080/index.txt')
39+
self.assertEqual(request.status_code, 200)
40+
41+
alt_request_success = False
42+
try:
43+
# FIXME: suspicious behaviour, too often ends up in error
44+
alt_request = requests.get('http://localhost:8000/index.txt')
45+
self.assertEqual(alt_request.status_code, 200)
46+
self.assertIn("ALT buildno=2 port=8000 ", alt_request.text)
47+
alt_request_success = True
48+
except requests.exceptions.ConnectionError:
49+
pass
50+
51+
if alt_request_success:
52+
output, _ = self.run_subprocess_assert_returncode([
53+
"podman",
54+
"inspect",
55+
"my-busybox-httpd2",
56+
])
57+
self.assertIn("httpd_port=8000", str(output))
58+
self.assertIn("buildno=2", str(output))
59+
finally:
60+
self.run_subprocess_assert_returncode([
61+
podman_compose_path(),
62+
"-f",
63+
compose_yaml_path(),
64+
"down",
65+
])

0 commit comments

Comments
 (0)