From eb266acb6c338b646efbc7824cb4e212f87426b0 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Fri, 21 Jul 2023 16:39:25 +0200 Subject: [PATCH] Only use debian and rockylinux for testing --- images/alpine/Dockerfile | 14 --------- images/archlinux/Dockerfile | 7 ----- images/ubuntu_xenial/Dockerfile | 22 --------------- test/conftest.py | 7 +---- test/test_modules.py | 50 +++++++-------------------------- 5 files changed, 11 insertions(+), 89 deletions(-) delete mode 100644 images/alpine/Dockerfile delete mode 100644 images/archlinux/Dockerfile delete mode 100644 images/ubuntu_xenial/Dockerfile diff --git a/images/alpine/Dockerfile b/images/alpine/Dockerfile deleted file mode 100644 index 27ff79ff..00000000 --- a/images/alpine/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM alpine:3.14 - -RUN apk add --update --no-cache python3 openrc openssh && \ - sed -i "s/^#PermitRootLogin prohibit-password/PermitRootLogin without-password/g" /etc/ssh/sshd_config && \ - rm -f /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_rsa_key && \ - ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_ecdsa_key && \ - ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && \ - rc-update add sshd && \ - mkdir -p /root/.ssh && \ - chmod 700 /root/.ssh && \ - echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgDryK4AjJeifuc2N54St13KMNlnGLAtibQSMmvSyrhH7XJ1atnBo1HrJhGZNNBVKM67+zYNc9J3fg3qI1g63vSQAA+nXMsDYwu4BPwupakpwJELcGZJxsUGzjGVotVpqPIX5nW8NBGvkVuObI4UELOleq5mQMTGerJO64KkSVi20FDwPJn3q8GG2zk3pESiDA5ShEyFhYC8vOLfSSYD0LYmShAVGCLEgiNb+OXQL6ZRvzqfFEzL0QvaI/l3mb6b0VFPAO4QWOL0xj3cWzOZXOqht3V85CZvSk8ISdNgwCjXLZsPeaYL/toHNvBF30VMrDZ7w4SDU0ZZLEsc/ezxjb" > /root/.ssh/authorized_keys - -EXPOSE 22 -CMD ["/sbin/init"] diff --git a/images/archlinux/Dockerfile b/images/archlinux/Dockerfile deleted file mode 100644 index 89086342..00000000 --- a/images/archlinux/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM archlinux/archlinux:base - -RUN pacman -Syu --noconfirm --noprogressbar --quiet python openssh iputils procps systemd systemd-sysvcompat && \ - systemctl enable sshd.service - -EXPOSE 22 -CMD ["/usr/sbin/init"] diff --git a/images/ubuntu_xenial/Dockerfile b/images/ubuntu_xenial/Dockerfile deleted file mode 100644 index e245caab..00000000 --- a/images/ubuntu_xenial/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:xenial - -# sshd is disabled for systemd -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ - python \ - iputils-ping \ - openssh-server && \ - rm -rf /var/lib/apt/lists/* -RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do if ! test $i = systemd-tmpfiles-setup.service; then rm -f $i; fi; done) && \ - rm -f /lib/systemd/system/multi-user.target.wants/* && \ - rm -f /etc/systemd/system/*.wants/* && \ - rm -f /lib/systemd/system/local-fs.target.wants/* && \ - rm -f /lib/systemd/system/sockets.target.wants/*udev* && \ - rm -f /lib/systemd/system/sockets.target.wants/*initctl* && \ - systemctl disable ssh.service && \ - mkdir -p /var/run/sshd && \ - mkdir -p /root/.ssh && \ - echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgDryK4AjJeifuc2N54St13KMNlnGLAtibQSMmvSyrhH7XJ1atnBo1HrJhGZNNBVKM67+zYNc9J3fg3qI1g63vSQAA+nXMsDYwu4BPwupakpwJELcGZJxsUGzjGVotVpqPIX5nW8NBGvkVuObI4UELOleq5mQMTGerJO64KkSVi20FDwPJn3q8GG2zk3pESiDA5ShEyFhYC8vOLfSSYD0LYmShAVGCLEgiNb+OXQL6ZRvzqfFEzL0QvaI/l3mb6b0VFPAO4QWOL0xj3cWzOZXOqht3V85CZvSk8ISdNgwCjXLZsPeaYL/toHNvBF30VMrDZ7w4SDU0ZZLEsc/ezxjb" > /root/.ssh/authorized_keys - -EXPOSE 22 -CMD ["/sbin/init"] diff --git a/test/conftest.py b/test/conftest.py index f6600249..9a4fc2dd 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -54,11 +54,8 @@ def has_docker(): """ DOCKER_IMAGES = [ - "alpine", - "archlinux", "rockylinux8", "debian_bullseye", - "ubuntu_xenial", ] @@ -187,9 +184,7 @@ def host(request, tmpdir_factory): # Wait ssh to be up service = testinfra.get_host(docker_id, connection="docker").service - images_with_sshd = ("rockylinux8", "alpine", "archlinux") - - if image in images_with_sshd: + if image == "rockylinux8": service_name = "sshd" else: service_name = "ssh" diff --git a/test/test_modules.py b/test/test_modules.py index 6a4ab0ef..6830dd4b 100644 --- a/test/test_modules.py +++ b/test/test_modules.py @@ -25,11 +25,8 @@ *[ "docker://{}".format(image) for image in ( - "alpine", - "archlinux", "rockylinux8", "debian_bullseye", - "ubuntu_xenial", ) ] ) @@ -38,27 +35,16 @@ @all_images def test_package(host, docker_image): assert not host.package("zsh").is_installed - if docker_image in ("alpine", "archlinux"): - name = "openssh" - else: - name = "openssh-server" - - ssh = host.package(name) + ssh = host.package("openssh-server") version = { - "alpine": "8.", - "archlinux": "9.", "rockylinux8": "8.", "debian_bullseye": "1:8.4", - "ubuntu_xenial": "1:7.2", }[docker_image] assert ssh.is_installed assert ssh.version.startswith(version) release = { - "alpine": "r3", - "archlinux": None, "rockylinux8": ".el8", "debian_bullseye": None, - "ubuntu_xenial": None, }[docker_image] if release is None: with pytest.raises(NotImplementedError): @@ -101,11 +87,8 @@ def test_systeminfo(host, docker_image): assert host.system_info.type == "linux" release, distribution, codename, arch = { - "alpine": (r"^3\.14\.", "alpine", None, "x86_64"), - "archlinux": ("rolling", "arch", None, "x86_64"), "rockylinux8": (r"^8.\d+$", "rocky", None, "x86_64"), "debian_bullseye": (r"^11", "debian", "bullseye", "x86_64"), - "ubuntu_xenial": (r"^16\.04$", "ubuntu", "xenial", "x86_64"), }[docker_image] assert host.system_info.distribution == distribution @@ -115,29 +98,21 @@ def test_systeminfo(host, docker_image): @all_images def test_ssh_service(host, docker_image): - if docker_image in ("rockylinux8", "alpine", "archlinux"): + if docker_image == "rockylinux8": name = "sshd" else: name = "ssh" ssh = host.service(name) - if docker_image == "ubuntu_xenial": - assert not ssh.is_running + # wait at max 10 seconds for ssh is running + for _ in range(10): + if ssh.is_running: + break + time.sleep(1) else: - # wait at max 10 seconds for ssh is running - for _ in range(10): - if ssh.is_running: - break - time.sleep(1) - else: - if docker_image == "archlinux": - raise pytest.skip("FIXME: flapping test") - raise AssertionError("ssh is not running") + raise AssertionError("ssh is not running") - if docker_image == "ubuntu_xenial": - assert not ssh.is_enabled - else: - assert ssh.is_enabled + assert ssh.is_enabled def test_service_systemd_mask(host): @@ -242,17 +217,12 @@ def test_socket(host): def test_process(host, docker_image): init = host.process.get(pid=1) assert init.ppid == 0 - if docker_image != "alpine": - # busybox ps doesn't have a euid equivalent - assert init.euid == 0 + assert init.euid == 0 assert init.user == "root" args, comm = { - "alpine": ("/sbin/init", "init"), - "archlinux": ("/usr/sbin/init", "systemd"), "rockylinux8": ("/usr/sbin/init", "systemd"), "debian_bullseye": ("/sbin/init", "systemd"), - "ubuntu_xenial": ("/sbin/init", "systemd"), }[docker_image] assert init.args == args assert init.comm == comm