install_docker/molecule/default/tests/test_default.py

32 lines
1.2 KiB
Python
Raw Normal View History

2023-04-04 19:15:48 +00:00
"""Role testing files using testinfra."""
def test_hosts_file(host):
"""Validate /etc/hosts file."""
etc_hosts = host.file("/etc/hosts")
assert etc_hosts.exists
assert etc_hosts.user == "root"
assert etc_hosts.group == "root"
2023-04-04 19:15:48 +00:00
def test_docker_service(host):
"""Validate docker service."""
docker_service = host.service("docker.service")
assert docker_service.is_enabled
assert docker_service.is_running
assert docker_service.systemd_properties["Restart"] == "always"
assert docker_service.systemd_properties["FragmentPath"] == "/lib/systemd/system/docker.service"
def test_docker_daemon(host):
"""Validate /etc/docker/daemon.json file."""
docker_daemon_file = host.file("/etc/docker/daemon.json")
assert docker_daemon_file.exists
assert docker_daemon_file.user == "root"
assert docker_daemon_file.group =="root"
assert docker_daemon_file.mode == 0o644
assert docker_daemon_file.contains("{}")
def test_docker_interaction(host):
"""Validate interaction with docker."""
docker_ps = host.check_output("docker ps")
assert docker_ps == "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES"