Use podman backend

Signed-off-by: Christian König <ckoenig@posteo.de>
tests_systemd
Christian König 1 year ago
parent 91b934cae7
commit 28ba803b38

@ -15,7 +15,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/usr/sbin/init"]

@ -15,7 +15,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/usr/sbin/init"]

@ -1,4 +1,4 @@
FROM buildpack-deps:buster-scm
FROM docker.io/buildpack-deps:buster-scm
RUN apt-get update && apt-get -y install systemd systemd-sysv
@ -16,7 +16,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/bin/systemd"]

@ -1,4 +1,4 @@
FROM buildpack-deps:bullseye-scm
FROM docker.io/buildpack-deps:bullseye-scm
RUN apt-get update && apt-get -y install systemd systemd-sysv
@ -16,7 +16,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/bin/systemd"]

@ -1,4 +1,4 @@
FROM fedora:35
FROM docker.io/fedora:35
RUN dnf install -y git systemd
ENV GITDIR /etc/.pihole
@ -15,7 +15,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/usr/sbin/init"]

@ -1,4 +1,4 @@
FROM fedora:36
FROM docker.io/fedora:36
RUN dnf install -y git systemd
ENV GITDIR /etc/.pihole
@ -15,7 +15,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/usr/sbin/init"]

@ -1,4 +1,4 @@
FROM fedora:37
FROM docker.io/fedora:37
RUN dnf install -y git systemd
ENV GITDIR /etc/.pihole
@ -15,7 +15,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/usr/sbin/init"]

@ -1,4 +1,4 @@
FROM buildpack-deps:focal-scm
FROM docker.io/buildpack-deps:focal-scm
RUN apt-get update && apt-get -y install systemd systemd-sysv
@ -17,7 +17,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/bin/systemd"]

@ -1,4 +1,4 @@
FROM buildpack-deps:jammy-scm
FROM docker.io/buildpack-deps:jammy-scm
RUN apt-get update && apt-get -y install systemd systemd-sysv
@ -17,7 +17,4 @@ RUN true && \
ENV SKIP_INSTALL true
ENV OS_CHECK_DOMAIN_NAME dev-supportedos.pi-hole.net
ENV container docker
STOPSIGNAL SIGRTMIN+3
CMD ["/bin/systemd"]

@ -1,6 +1,6 @@
import pytest
import testinfra
import testinfra.backend.docker
import testinfra.backend.podman
import subprocess
from textwrap import dedent
@ -19,37 +19,37 @@ info_box = "[i]"
# Monkeypatch sh to bash, if they ever support non hard code /bin/sh this can go away
# https://github.com/pytest-dev/pytest-testinfra/blob/master/testinfra/backend/docker.py
# https://github.com/pytest-dev/pytest-testinfra/blob/master/testinfra/backend/podman.py
def run_bash(self, command, *args, **kwargs):
cmd = self.get_command(command, *args)
if self.user is not None:
out = self.run_local(
"docker exec -u %s %s /bin/bash -c %s", self.user, self.name, cmd
"podman exec -u %s %s /bin/bash -c %s", self.user, self.name, cmd
)
else:
out = self.run_local("docker exec %s /bin/bash -c %s", self.name, cmd)
out = self.run_local("podman exec %s /bin/bash -c %s", self.name, cmd)
out.command = self.encode(cmd)
return out
testinfra.backend.docker.DockerBackend.run = run_bash
testinfra.backend.podman.PodmanBackend.run = run_bash
@pytest.fixture
def host():
# run a container
docker_id = (
subprocess.check_output(["docker", "run", "-t", "-d", "--privileged", IMAGE])
pod_id = (
subprocess.check_output(["podman", "run", "-t", "-d", "--cap-add=ALL", IMAGE])
.decode()
.strip()
)
# return a testinfra connection to the container
docker_host = testinfra.get_host("docker://" + docker_id)
pod_host = testinfra.get_host("podman://" + pod_id)
yield docker_host
yield pod_host
# at the end of the test suite, destroy the container
subprocess.check_call(["docker", "rm", "-f", docker_id])
subprocess.check_call(["podman", "rm", "-f", pod_id])
# Helper functions

@ -1,4 +1,3 @@
docker-compose == 1.29.2
pytest == 7.2.1
pytest-xdist == 3.1.0
pytest-testinfra == 7.0.0

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _centos_8.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _centos_8.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _centos_9.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _centos_9.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _debian_10.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _debian_10.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _debian_11.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _debian_11.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _fedora_35.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _fedora_35.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py ./test_fedora_support.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _fedora_36.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _fedora_36.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py ./test_fedora_support.py

@ -2,7 +2,7 @@
envlist = py3
[testenv]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _fedora_37.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _fedora_37.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py ./test_fedora_support.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _ubuntu_20.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _ubuntu_20.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py

@ -2,7 +2,7 @@
envlist = py3
[testenv:py3]
allowlist_externals = docker
allowlist_externals = podman
deps = -rrequirements.txt
commands = docker build -f _ubuntu_22.Dockerfile -t pytest_pihole:test_container ../
commands = podman build -f _ubuntu_22.Dockerfile -t pytest_pihole:test_container ../
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py

Loading…
Cancel
Save