Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate manual build tests #997

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ pluggy==1.4.0
pyproject-api==1.6.1
python-dotenv==1.0.1
PyYAML==6.0.1
requests
tomlkit==0.12.4
virtualenv==20.25.1
23 changes: 0 additions & 23 deletions tests/integration/build/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions tests/integration/build_fail/README.md

This file was deleted.

65 changes: 65 additions & 0 deletions tests/integration/test_podman_compose_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-License-Identifier: GPL-2.0

import os
import unittest

import requests

from tests.integration.test_podman_compose import podman_compose_path
from tests.integration.test_podman_compose import test_path
from tests.integration.test_utils import RunSubprocessMixin


def compose_yaml_path():
""" "Returns the path to the compose file used for this test module"""
base_path = os.path.join(test_path(), "build")
return os.path.join(base_path, "docker-compose.yml")


class TestComposeBuild(unittest.TestCase, RunSubprocessMixin):
def test_build(self):
try:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"build",
"--no-cache",
])

self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"up",
"-d",
])

request = requests.get('http://localhost:8080/index.txt')
self.assertEqual(request.status_code, 200)

alt_request_success = False
try:
# FIXME: suspicious behaviour, too often ends up in error
alt_request = requests.get('http://localhost:8000/index.txt')
self.assertEqual(alt_request.status_code, 200)
self.assertIn("ALT buildno=2 port=8000 ", alt_request.text)
alt_request_success = True
except requests.exceptions.ConnectionError:
pass

if alt_request_success:
output, _ = self.run_subprocess_assert_returncode([
"podman",
"inspect",
"my-busybox-httpd2",
])
self.assertIn("httpd_port=8000", str(output))
self.assertIn("buildno=2", str(output))
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
])
30 changes: 30 additions & 0 deletions tests/integration/test_podman_compose_build_fail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-2.0

import os
import unittest

from tests.integration.test_podman_compose import podman_compose_path
from tests.integration.test_podman_compose import test_path
from tests.integration.test_utils import RunSubprocessMixin


def compose_yaml_path():
""" "Returns the path to the compose file used for this test module"""
base_path = os.path.join(test_path(), "build_fail")
return os.path.join(base_path, "docker-compose.yml")


class TestComposeBuildFail(unittest.TestCase, RunSubprocessMixin):
def test_build_fail(self):
output, error = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"build",
],
expected_returncode=127,
)
self.assertIn("RUN this_command_does_not_exist", str(output))
self.assertIn("this_command_does_not_exist: not found", str(error))
self.assertIn("while running runtime: exit status 127", str(error))