Skip to content

Commit

Permalink
Only use debian and rockylinux for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
philpep committed Jul 21, 2023
1 parent dc8f15a commit eb266ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 89 deletions.
14 changes: 0 additions & 14 deletions images/alpine/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions images/archlinux/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions images/ubuntu_xenial/Dockerfile

This file was deleted.

7 changes: 1 addition & 6 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ def has_docker():
"""

DOCKER_IMAGES = [
"alpine",
"archlinux",
"rockylinux8",
"debian_bullseye",
"ubuntu_xenial",
]


Expand Down Expand Up @@ -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"
Expand Down
50 changes: 10 additions & 40 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
*[
"docker://{}".format(image)
for image in (
"alpine",
"archlinux",
"rockylinux8",
"debian_bullseye",
"ubuntu_xenial",
)
]
)
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eb266ac

Please sign in to comment.