File: test_podman_compose_build.py

package info (click to toggle)
podman-compose 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: python: 10,946; sh: 107; javascript: 48; makefile: 13
file content (65 lines) | stat: -rw-r--r-- 2,141 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# SPDX-License-Identifier: GPL-2.0

import os
import unittest

import requests

from tests.integration.test_utils import podman_compose_path
from tests.integration.test_utils 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",
            ])