ansible-role-swarm/molecule/default/tests/test_default.py

43 lines
1 KiB
Python
Raw Normal View History

2021-11-22 10:27:46 +00:00
import testinfra.utils.ansible_runner
import time
time.sleep(60)
def test_packages(host):
package = host.package('docker.io')
assert package.is_installed
2022-04-06 08:17:32 +00:00
def test_default_config_file(host):
path = host.file('/etc/default/docker')
assert path.exists
assert path.is_file
assert path.user == 'root'
assert path.group == 'root'
assert path.mode == 0o644
assert path.contains('https_proxy=http://127.0.0.1:3128')
2021-11-22 10:27:46 +00:00
def test_service(host):
service = host.service('docker')
assert service.is_running
assert service.is_enabled
def test_sockets(host):
socket = host.socket('tcp://0.0.0.0:80')
assert socket.is_listening
def test_docker_network(host):
cmd = host.run('docker network list')
assert cmd.succeeded
assert 'proxy' in cmd.stdout
def test_docker_container(host):
cmd = host.run('docker ps')
assert cmd.succeeded
assert 'whoami' in cmd.stdout
assert 'traefik' in cmd.stdout
def test_databases(host):
cmd = host.run('curl -H "Host: whoami" http://127.0.0.1')
assert cmd.succeeded
assert "I'm " in cmd.stdout