Beispiel #1
0
def test_httpd_container(host: Host):
    with host.sudo():
        host.run_expect([0], 'podman image pull docker.io/httpd:2.4.39')
        host.run_expect([
            0
        ], 'podman container create --name httpd-test -p 127.0.0.1:8080:80 httpd:2.4.39'
                        )  # noqa E501
        host.run_expect([0], 'podman container start httpd-test')
    host.run_expect([0], 'sleep 2')

    curl_works = host.run_expect([0],
                                 "curl 'http://127.0.0.1:8080/' 2>/dev/null")
    assert 'It works!' in curl_works.stdout

    with host.sudo():
        host.run_expect([0], 'podman container stop httpd-test')
        host.run_expect([0], 'podman container start httpd-test')
        host.run_expect([0], 'podman container stop httpd-test')
Beispiel #2
0
def test_deb_packages_appear_installable(host: Host, deb: Path) -> None:
    """
    Confirms that a dry-run of installation reports no errors.
    Simple check for valid Debian package structure, but not thorough.
    When run on a malformed package, `dpkg` will report:

       dpkg-deb: error: `foo.deb' is not a debian format archive

    Testing application behavior is left to the functional tests.
    """

    package_name = extract_package_name_from_filepath(str(deb))
    assert deb.name.startswith(package_name)

    # sudo is required to call `dpkg --install`, even as dry-run.
    with host.sudo():
        c = host.run("dpkg --install --dry-run {}".format(deb))
        assert "Selecting previously unselected package {}".format(
            package_name) in c.stdout
        regex = "Preparing to unpack [./]+{} ...".format(re.escape(deb.name))
        assert re.search(regex, c.stdout, re.M)
        assert c.rc == 0
Beispiel #3
0
def test_container_basics(host: Host):
    with host.sudo():
        host.run_expect([0], 'podman image pull docker.io/hello-world')
        run_hello_world = host.run_expect([0], 'podman run --rm hello-world')
        assert 'Hello from Docker!' in run_hello_world.stdout
Beispiel #4
0
def test_assert_all_containers_are_stopped_and_removed(host: Host):
    with host.sudo():
        host.run_expect([0], 'podman container stop -a')
        host.run_expect([0], 'podman container prune -f')