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.
This commit is contained in:
parent
891687284f
commit
3bb41ccb8e
20 changed files with 537 additions and 481 deletions
|
@ -220,7 +220,7 @@ def main():
|
|||
|
||||
# Version checks
|
||||
cache_min_version = '3.3.0'
|
||||
if client.module.params['builder_cache'] and LooseVersion(docker_version) < LooseVersion(cache_min_version):
|
||||
if client.module.params['builder_cache'] and client.docker_py_version < LooseVersion(cache_min_version):
|
||||
msg = "Error: docker version is %s. Minimum version required for builds option is %s. Use `pip install --upgrade docker` to upgrade."
|
||||
client.module.fail(msg=(msg % (docker_version, cache_min_version)))
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
- include_tasks: test_docker_config.yml
|
||||
when: docker_api_version is version('1.30', '>=')
|
||||
# Maximum of 1.30 (docker API version for docker_config) 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_config 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,4 +1,5 @@
|
|||
---
|
||||
- block:
|
||||
- name: Make sure we're not already using Docker swarm
|
||||
docker_swarm:
|
||||
state: absent
|
||||
|
@ -108,6 +109,7 @@
|
|||
that:
|
||||
- not output.changed
|
||||
|
||||
always:
|
||||
- name: Remove a Swarm cluster
|
||||
docker_swarm:
|
||||
state: absent
|
||||
|
|
|
@ -33,3 +33,6 @@
|
|||
diff: no
|
||||
|
||||
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)
|
||||
|
|
|
@ -58,5 +58,7 @@
|
|||
- "result.docker_container"
|
||||
- "result.docker_container == docker_inspect_result[0]"
|
||||
|
||||
# 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_container_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)
|
||||
|
|
|
@ -47,5 +47,7 @@
|
|||
force_kill: yes
|
||||
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)
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
## overlay #########################################################
|
||||
####################################################################
|
||||
|
||||
- block:
|
||||
# Overlay networks require swarm initialization before they'll work
|
||||
- name: swarm
|
||||
docker_swarm:
|
||||
state: present
|
||||
advertise_addr: 192.168.1.1
|
||||
advertise_addr: "{{ansible_default_ipv4.address}}"
|
||||
|
||||
- name: overlay
|
||||
docker_network:
|
||||
|
@ -44,13 +45,17 @@
|
|||
state: absent
|
||||
force: yes
|
||||
|
||||
- name: cleanup swarm
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- overlay_1 is changed
|
||||
- overlay_2 is not changed
|
||||
- overlay_3 is changed
|
||||
|
||||
always:
|
||||
- name: cleanup swarm
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
# Requirements for docker_swarm
|
||||
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
images: yes
|
||||
networks: yes
|
||||
volumes: yes
|
||||
builder_cache: yes
|
||||
builder_cache: "{{ docker_py_version is version('3.3.0', '>=') }}"
|
||||
register: result
|
||||
|
||||
# Analyze result
|
||||
|
@ -56,5 +56,7 @@
|
|||
|
||||
- debug: var=result
|
||||
|
||||
# Skip for CentOS 6
|
||||
when: ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6
|
||||
when: docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')
|
||||
|
||||
- fail: msg="Too old docker / docker-py version to run docker_prune tests!"
|
||||
when: not(docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')) 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,4 +1,5 @@
|
|||
- include_tasks: test_stack.yml
|
||||
when:
|
||||
- ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
|
||||
- ansible_distribution != 'Fedora' or ansible_distribution_major_version|int >= 26
|
||||
when: docker_api_version is version('1.25', '>=')
|
||||
|
||||
- fail: msg="Too old docker / docker-py version to run docker_stack tests!"
|
||||
when: not(docker_api_version is version('1.25', '>=')) 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
|
||||
|
@ -104,6 +106,7 @@
|
|||
that:
|
||||
- output is not changed
|
||||
|
||||
always:
|
||||
- name: Remove a Swarm cluster
|
||||
docker_swarm:
|
||||
state: absent
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
- include_tasks: test_swarm_service.yml
|
||||
when:
|
||||
- ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
|
||||
- ansible_distribution != 'Fedora' or ansible_distribution_major_version|int >= 26
|
||||
# Maximum of 2.0.0 (docker-py version for docker_swarm_service) and 2.6.0 (docker-py version for docker_swarm) is 2.6.0
|
||||
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_service 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: Create a Swarm cluster
|
||||
docker_swarm:
|
||||
state: present
|
||||
|
@ -116,6 +118,7 @@
|
|||
state: present
|
||||
advertise_addr: "{{ansible_default_ipv4.address}}"
|
||||
|
||||
always:
|
||||
- name: Clean the docker daemon status
|
||||
docker_swarm:
|
||||
state: absent
|
||||
|
|
|
@ -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…
Reference in a new issue