Skip to content
Snippets Groups Projects
Commit a7646833 authored by Varac's avatar Varac
Browse files

Merge branch 'testinfra_example' into 'master'

First testinfra example tests

Closes #23

See merge request openappstack/bootstrap!25
parents abdb64b9 e622c48f
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ bootstrap:
script:
- apk update
- apk add ansible musl-dev linux-headers gcc py3-psutil openssh-client
- pip3 install requests tabulate
- pip3 install requests tabulate testinfra
# Ensure test/ is not world-writable otherwise ansible-playbook refuses to run, see
# https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir
- chmod 755 test/
......@@ -31,6 +31,7 @@ bootstrap:
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
# - mkdir -p --mode 700 ~/.ssh
- ANSIBLE_HOST_KEY_CHECKING=False python3 -u ./ci-bootstrap.py --create_droplet
- py.test -v --ansible-inventory=./inventory.yml --connection=ssh --hosts='ansible://*'
- python3 -c "import cosmos; cosmos.terminate_droplets_by_name(\"^ci-${CI_JOB_ID}\$\")"
artifacts:
paths:
......
# Run testinfra tests
Test host configured in `test/inventory.yml`
py.test -v --ansible-inventory=../inventory.yml --hosts='ansible://*'
Specify host manually:
py.test -v --hosts='ssh://root@varac-oas.openappstack.net'
# Issues
- Default ssh backend is `paramiko`, which doesn't work oout of the
box. It fails to connect to the host because the `ed25519` hostkey
was not verified. Therefore we need to force plain ssh:// with either
`connection=ssh` or `--hosts=ssh://…`
def test_docker_is_installed(host):
docker = host.package("docker-ce")
assert docker.is_installed
assert docker.version.startswith("5:18.09.2")
def test_docker_running_and_enabled(host):
docker = host.service("docker")
assert docker.is_running
assert docker.is_enabled
def test_release_is_bionic(host):
system_info = host.system_info
assert system_info.release == '18.04'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment