mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 11:58:43 +00:00
Add docker connection tests (#37)
* Add docker connection tests. * Make it easier to switch image.
This commit is contained in:
parent
68952f9d1d
commit
c0bd1becea
@ -1,2 +1,2 @@
|
||||
non_local
|
||||
unsupported
|
||||
shippable/posix/group4
|
||||
destructive
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- setup_docker
|
||||
1
tests/integration/targets/connection_docker/runme-connection.sh
Symbolic link
1
tests/integration/targets/connection_docker/runme-connection.sh
Symbolic link
@ -0,0 +1 @@
|
||||
../connection_posix/test.sh
|
||||
@ -1 +0,0 @@
|
||||
../connection_posix/test.sh
|
||||
46
tests/integration/targets/connection_docker/runme.sh
Executable file
46
tests/integration/targets/connection_docker/runme.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# If you use another image, you possibly also need to adjust
|
||||
# ansible_python_interpreter in test_connection.inventory.
|
||||
IMAGE=python:3-alpine
|
||||
|
||||
# Setup phase
|
||||
|
||||
echo "Setup"
|
||||
ANSIBLE_ROLES_PATH=.. ansible-playbook setup.yml
|
||||
|
||||
# If docker wasn't installed, don't run the tests
|
||||
if [ "$(command -v docker)" == "" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
# Test phase
|
||||
|
||||
|
||||
DOCKER_CONTAINERS="docker-connection-test-container"
|
||||
|
||||
[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cleanup() {
|
||||
echo "Cleanup"
|
||||
docker rm -f ${DOCKER_CONTAINERS}
|
||||
echo "Shutdown"
|
||||
ANSIBLE_ROLES_PATH=.. ansible-playbook shutdown.yml
|
||||
echo "Done"
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap cleanup INT TERM EXIT
|
||||
|
||||
echo "Start containers"
|
||||
for CONTAINER in ${DOCKER_CONTAINERS}; do
|
||||
docker run --rm --name ${CONTAINER} --detach ${IMAGE} /bin/sh -c 'sleep 10m'
|
||||
docker exec ${CONTAINER} pip3 install coverage
|
||||
echo ${CONTAINER}
|
||||
done
|
||||
|
||||
echo "Run tests"
|
||||
./runme-connection.sh
|
||||
10
tests/integration/targets/connection_docker/setup.yml
Normal file
10
tests/integration/targets/connection_docker/setup.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
vars:
|
||||
docker_skip_cleanup: yes
|
||||
|
||||
tasks:
|
||||
- name: Setup docker
|
||||
import_role:
|
||||
name: setup_docker
|
||||
15
tests/integration/targets/connection_docker/shutdown.yml
Normal file
15
tests/integration/targets/connection_docker/shutdown.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
vars:
|
||||
docker_skip_cleanup: yes
|
||||
|
||||
tasks:
|
||||
- name: Remove docker packages
|
||||
action: "{{ ansible_facts.pkg_mgr }}"
|
||||
args:
|
||||
name:
|
||||
- docker
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
state: absent
|
||||
@ -1,6 +1,8 @@
|
||||
[docker]
|
||||
docker-pipelining ansible_ssh_pipelining=true
|
||||
docker-no-pipelining ansible_ssh_pipelining=false
|
||||
docker-no-pipelining ansible_pipelining=false
|
||||
docker-pipelining ansible_pipelining=true
|
||||
|
||||
[docker:vars]
|
||||
ansible_host=ubuntu-latest
|
||||
ansible_host=docker-connection-test-container
|
||||
ansible_connection=community.docker.docker
|
||||
ansible_python_interpreter=/usr/local/bin/python3
|
||||
|
||||
Loading…
Reference in New Issue
Block a user