Skip to content

Commit

Permalink
[stable-2] Fix/improve inventory integration tests (#819)
Browse files Browse the repository at this point in the history
* Improve inventory integration tests. (#817)

(cherry picked from commit 14e2f92)

* Fix Python deps setup in callback/inventory tests. (#816)

(cherry picked from commit 6600f50)
  • Loading branch information
felixfontein authored Mar 14, 2024
1 parent 228cbf6 commit 5cddffa
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 31 deletions.
2 changes: 1 addition & 1 deletion tests/integration/targets/connection_docker_api/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
import_role:
name: setup_docker

- name: Setup docker
- name: Setup docker Python deps
import_role:
name: setup_docker_sdk_for_python
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@
loop:
- ansible-docker-test-docker-inventory-container-1
- ansible-docker-test-docker-inventory-container-2

- name: remove docker pagkages
action: "{{ ansible_facts.pkg_mgr }}"
args:
name:
- docker
- docker-ce
- docker-ce-cli
state: absent
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import_role:
name: setup_docker

- name: Setup Docker Python deps
import_role:
name: setup_docker_sdk_for_python

- name: Start containers
docker_container:
name: "{{ item.name }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ set -euo pipefail

cleanup() {
echo "Cleanup"
ansible-playbook playbooks/docker_cleanup.yml
ansible-playbook playbooks/docker_cleanup.yml "$@"
echo "Done"
}

trap cleanup INT TERM EXIT

echo "Setup"
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/docker_setup.yml
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/docker_setup.yml "$@"

echo "Test docker_containers inventory 1"
ansible-playbook -i inventory_1.docker.yml playbooks/test_inventory_1.yml
ansible-playbook -i inventory_1.docker.yml playbooks/test_inventory_1.yml "$@"

echo "Test docker_containers inventory 2"
ansible-playbook -i inventory_2.docker.yml playbooks/test_inventory_2.yml
ansible-playbook -i inventory_2.docker.yml playbooks/test_inventory_2.yml "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
include_role:
name: setup_docker

- name: Setup Docker Python deps
import_role:
name: setup_docker_sdk_for_python

# There seems to be no better way to install docker-machine. At least I couldn't find any packages for RHEL7/8.
- name: Download docker-machine binary
vars:
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/inventory_docker_machine/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ SAVED_PATH="$PATH"
cleanup() {
PATH="${SAVED_PATH}"
echo "Cleanup"
ansible-playbook -i teardown.docker_machine.yml playbooks/teardown.yml
ansible-playbook -i teardown.docker_machine.yml playbooks/teardown.yml "$@"
echo "Done"
}

trap cleanup INT TERM EXIT

echo "Pre-setup (install docker, docker-machine)"
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/pre-setup.yml
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/pre-setup.yml "$@"

echo "Print docker-machine version"
docker-machine --version
Expand All @@ -40,10 +40,10 @@ echo "Test that the docker_machine inventory plugin is being loaded"
ANSIBLE_DEBUG=yes ansible-inventory -i inventory_1.docker_machine.yml --list | grep -F "Loading InventoryModule 'docker_machine'"

echo "Setup"
ansible-playbook playbooks/setup.yml
ansible-playbook playbooks/setup.yml "$@"

echo "Test docker_machine inventory 1"
ansible-playbook -i inventory_1.docker_machine.yml playbooks/test_inventory_1.yml
ansible-playbook -i inventory_1.docker_machine.yml playbooks/test_inventory_1.yml "$@"

echo "Activate Docker Machine mock"
PATH=${SCRIPT_DIR}:$PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@
docker_swarm:
state: absent
force: yes

- name: remove docker pagkages
action: "{{ ansible_facts.pkg_mgr }}"
args:
name:
- docker
- docker-ce
- docker-ce-cli
state: absent
8 changes: 4 additions & 4 deletions tests/integration/targets/inventory_docker_swarm/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ set -euo pipefail

cleanup() {
echo "Cleanup"
ansible-playbook playbooks/swarm_cleanup.yml
ansible-playbook playbooks/swarm_cleanup.yml "$@"
echo "Done"
}

trap cleanup INT TERM EXIT

echo "Setup"
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/swarm_setup.yml
ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/swarm_setup.yml "$@"

echo "Test docker_swarm inventory 1"
ansible-playbook -i inventory_1.docker_swarm.yml playbooks/test_inventory_1.yml
ansible-playbook -i inventory_1.docker_swarm.yml playbooks/test_inventory_1.yml "$@"

echo "Test docker_swarm inventory 2"
ansible-playbook -i inventory_2.docker_swarm.yml playbooks/test_inventory_2.yml
ansible-playbook -i inventory_2.docker_swarm.yml playbooks/test_inventory_2.yml "$@"

0 comments on commit 5cddffa

Please sign in to comment.