docker_* tests: check API version (#48620)

* Check minimal API and docker-py versions for all docker_* tests.

* Improve docker_swarm creation/destruction for tests.

* Fail when conditions aren't met.

* Don't hardcode address for advertise_addr.

(cherry picked from commit 3bb41ccb8e)
pull/48898/head
Felix Fontein 7 years ago committed by Toshio Kuratomi
parent 1469ec4487
commit a96efa43f0

@ -31,3 +31,6 @@
when: docker_py_version is version('1.10.0', '>=')
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
- fail: msg="Too old docker / docker-py version to run all docker_container tests!"
when: not(docker_py_version is version('3.5.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -47,5 +47,7 @@
stop_timeout: 1
with_items: "{{ cnames }}"
# Skip for CentOS 6
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
- fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -48,5 +48,7 @@
- "'hello-world:latest' in result.images[0].RepoTags"
- "'alpine:3.8' in result.images[1].RepoTags"
# Skip for CentOS 6
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
- fail: msg="Too old docker / docker-py version to run docker_image_facts tests!"
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -27,5 +27,7 @@
force: yes
loop: "{{ dnetworks }}"
# Skip for CentOS 6
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version!
- fail: msg="Too old docker / docker-py version to run docker_network tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -1,3 +0,0 @@
- name: disable_swarm
command: docker swarm leave --force
ignore_errors: yes

@ -1,2 +1,7 @@
- include_tasks: test_secrets.yml
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
# Maximum of 2.1.0 (docker-py version for docker_secrets) and 2.6.0 (docker-py version for docker_swarm) is 2.6.0
# Maximum of 1.25 (docker API version for docker_secrets) and 1.35 (docker API version for docker_swarm) is 1.35
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')
- fail: msg="Too old docker / docker-py version to run docker_secrets tests!"
when: not(docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -1,12 +1,14 @@
- name: Check if already in swarm
shell: docker node ls 2>&1 | grep 'docker swarm init'
register: output
ignore_errors: yes
---
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Enable swarm mode
command: docker swarm init
when: output.rc == 0
notify: disable_swarm
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address}}"
- name: Parameter name should be required
docker_secret:
@ -95,3 +97,9 @@
assert:
that:
- output.failed
always:
- name: Remove Swarm cluster
docker_swarm:
state: absent
force: true

@ -1,2 +1,5 @@
- include_tasks: test_swarm.yml
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')
- fail: msg="Too old docker / docker-py version to run docker_swarm tests!"
when: not(docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

@ -1,3 +1,5 @@
---
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
@ -51,3 +53,9 @@
that:
- 'output.changed'
- 'output.actions[0] == "Node has leaved the swarm cluster"'
always:
- name: Cleanup
docker_swarm:
state: absent
force: true

@ -20,5 +20,7 @@
force: yes
with_items: "{{ vnames }}"
# Skip for CentOS 6
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version!
- fail: msg="Too old docker / docker-py version to run docker_volume tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

Loading…
Cancel
Save