Skip to content

Commit

Permalink
Drop support for CentOS 7 in tests and add RockyLinux 8
Browse files Browse the repository at this point in the history
Closes #670
  • Loading branch information
philpep committed Dec 10, 2022
1 parent cd16981 commit fc4bfd1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
5 changes: 2 additions & 3 deletions images/centos_7/Dockerfile → images/rockylinux8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM centos:7
FROM rockylinux:8

RUN yum -y install openssh-server && yum clean all &&\
RUN dnf -y install openssh-server procps python39 && dnf clean all &&\
(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/* && \
Expand All @@ -17,6 +17,5 @@ RUN yum -y install openssh-server && yum clean all &&\
mkdir -p /root/.ssh && \
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgDryK4AjJeifuc2N54St13KMNlnGLAtibQSMmvSyrhH7XJ1atnBo1HrJhGZNNBVKM67+zYNc9J3fg3qI1g63vSQAA+nXMsDYwu4BPwupakpwJELcGZJxsUGzjGVotVpqPIX5nW8NBGvkVuObI4UELOleq5mQMTGerJO64KkSVi20FDwPJn3q8GG2zk3pESiDA5ShEyFhYC8vOLfSSYD0LYmShAVGCLEgiNb+OXQL6ZRvzqfFEzL0QvaI/l3mb6b0VFPAO4QWOL0xj3cWzOZXOqht3V85CZvSk8ISdNgwCjXLZsPeaYL/toHNvBF30VMrDZ7w4SDU0ZZLEsc/ezxjb" > /root/.ssh/authorized_keys

VOLUME ["/sys/fs/cgroup"]
EXPOSE 22
CMD ["/usr/sbin/init"]
4 changes: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def has_docker():
DOCKER_IMAGES = [
"alpine",
"archlinux",
"centos_7",
"rockylinux8",
"debian_bullseye",
"ubuntu_xenial",
]
Expand Down Expand Up @@ -181,7 +181,7 @@ def host(request, tmpdir_factory):
# Wait ssh to be up
service = testinfra.get_host(docker_id, connection="docker").service

images_with_sshd = ("centos_7", "alpine", "archlinux")
images_with_sshd = ("rockylinux8", "alpine", "archlinux")

if image in images_with_sshd:
service_name = "sshd"
Expand Down
28 changes: 14 additions & 14 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_ansible_get_hosts():
b"[g1]\n"
b"debian\n"
b"[g2]\n"
b"centos\n"
b"rockylinux\n"
b"[g3:children]\n"
b"g1\n"
b"g2\n"
Expand All @@ -142,13 +142,13 @@ def test_ansible_get_hosts():
def get_hosts(spec):
return AnsibleRunner(f.name).get_hosts(spec)

assert get_hosts("all") == ["centos", "debian", "ungrp"]
assert get_hosts("*") == ["centos", "debian", "ungrp"]
assert get_hosts("all") == ["debian", "rockylinux", "ungrp"]
assert get_hosts("*") == ["debian", "rockylinux", "ungrp"]
assert get_hosts("g1") == ["debian"]
assert get_hosts("*2") == ["centos"]
assert get_hosts("*2") == ["rockylinux"]
assert get_hosts("*ia*") == ["debian"]
assert get_hosts("*3") == ["centos", "debian"]
assert get_hosts("*4") == ["centos", "debian"]
assert get_hosts("*3") == ["debian", "rockylinux"]
assert get_hosts("*4") == ["debian", "rockylinux"]
assert get_hosts("ungrouped") == ["ungrp"]
assert get_hosts("un*") == ["ungrp"]
assert get_hosts("nope") == []
Expand All @@ -159,7 +159,7 @@ def test_ansible_get_variables():
f.write(
(
b"debian a=b c=d\n"
b"centos e=f\n"
b"rockylinux e=f\n"
b"[all:vars]\n"
b"a=a\n"
b"[g]\n"
Expand All @@ -174,9 +174,9 @@ def get_vars(host):
return AnsibleRunner(f.name).get_variables(host)

groups = {
"all": ["centos", "debian"],
"all": ["debian", "rockylinux"],
"g": ["debian"],
"ungrouped": ["centos"],
"ungrouped": ["rockylinux"],
}
assert get_vars("debian") == {
"a": "b",
Expand All @@ -186,10 +186,10 @@ def get_vars(host):
"group_names": ["g"],
"groups": groups,
}
assert get_vars("centos") == {
assert get_vars("rockylinux") == {
"a": "a",
"e": "f",
"inventory_hostname": "centos",
"inventory_hostname": "rockylinux",
"group_names": ["ungrouped"],
"groups": groups,
}
Expand Down Expand Up @@ -485,12 +485,12 @@ def test_backend_importables():
assert obj.get_connection_type() == connection_type


@pytest.mark.testinfra_hosts("docker://centos_7", "ssh://centos_7")
@pytest.mark.testinfra_hosts("docker://rockylinux8", "ssh://rockylinux8")
def test_docker_encoding(host):
encoding = host.check_output(
"python -c 'import locale;print(locale.getpreferredencoding())'"
"python3 -c 'import locale;print(locale.getpreferredencoding())'"
)
assert encoding == "ANSI_X3.4-1968"
assert encoding == "UTF-8"
string = "ťēꞩƫìṇḟřặ ṧꝕèȃǩ ửƫᵮ8"
assert host.check_output("echo %s | tee /tmp/s.txt", string) == string
assert host.file("/tmp/s.txt").content_string.strip() == string
Expand Down
15 changes: 8 additions & 7 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
for image in (
"alpine",
"archlinux",
"centos_7",
"rockylinux8",
"debian_bullseye",
"ubuntu_xenial",
)
Expand All @@ -47,7 +47,7 @@ def test_package(host, docker_image):
version = {
"alpine": "8.",
"archlinux": "9.",
"centos_7": "7.",
"rockylinux8": "8.",
"debian_bullseye": "1:8.4",
"ubuntu_xenial": "1:7.2",
}[docker_image]
Expand All @@ -56,7 +56,7 @@ def test_package(host, docker_image):
release = {
"alpine": "r3",
"archlinux": None,
"centos_7": ".el7",
"rockylinux8": ".el8",
"debian_bullseye": None,
"ubuntu_xenial": None,
}[docker_image]
Expand All @@ -73,7 +73,7 @@ def test_held_package(host):
assert python.version.startswith("3.9.")


@pytest.mark.testinfra_hosts("docker://centos_7")
@pytest.mark.testinfra_hosts("docker://rockylinux8")
def test_non_default_package_tool(host):
# Make non default pkg tool binary present
host.run("install -m a+rx /bin/true /usr/bin/dpkg-query")
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_systeminfo(host, docker_image):
release, distribution, codename, arch = {
"alpine": (r"^3\.14\.", "alpine", None, "x86_64"),
"archlinux": ("rolling", "arch", None, "x86_64"),
"centos_7": (r"^7$", "centos", 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]
Expand All @@ -115,7 +115,7 @@ def test_systeminfo(host, docker_image):

@all_images
def test_ssh_service(host, docker_image):
if docker_image in ("centos_7", "alpine", "archlinux"):
if docker_image in ("rockylinux8", "alpine", "archlinux"):
name = "sshd"
else:
name = "ssh"
Expand Down Expand Up @@ -188,6 +188,7 @@ def test_facter(host):
assert host.facter("virtual") in (
{"virtual": "docker"},
{"virtual": "hyperv"}, # github action uses hyperv
{"virtual": "physical"}, # I've this on my machine...
)


Expand Down Expand Up @@ -249,7 +250,7 @@ def test_process(host, docker_image):
args, comm = {
"alpine": ("/sbin/init", "init"),
"archlinux": ("/usr/sbin/init", "systemd"),
"centos_7": ("/usr/sbin/init", "systemd"),
"rockylinux8": ("/usr/sbin/init", "systemd"),
"debian_bullseye": ("/sbin/init", "systemd"),
"ubuntu_xenial": ("/sbin/init", "systemd"),
}[docker_image]
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def is_installed(self):
- pkg (FreeBSD)
- pkg_info (NetBSD)
- pkg_info (OpenBSD)
- rpm (RHEL, Centos, Fedora, ...)
- rpm (RHEL, RockyLinux, Fedora, ...)
"""
raise NotImplementedError

Expand Down

0 comments on commit fc4bfd1

Please sign in to comment.