Make docker swarm integration tests more reliable (#59473)
This commit is contained in:
parent
723da33176
commit
3ceeae0de9
8 changed files with 102 additions and 87 deletions
|
@ -8,4 +8,3 @@ skip/docker # The tests sometimes make docker daemon unstable; hence,
|
||||||
# after finishing the tests to minimize potential effects
|
# after finishing the tests to minimize potential effects
|
||||||
# on other tests.
|
# on other tests.
|
||||||
needs/root
|
needs/root
|
||||||
unstable
|
|
||||||
|
|
35
test/integration/targets/docker_swarm/tasks/cleanup.yml
Normal file
35
test/integration/targets/docker_swarm/tasks/cleanup.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
- name: CLEANUP | Leave Docker Swarm
|
||||||
|
docker_swarm:
|
||||||
|
state: absent
|
||||||
|
force: true
|
||||||
|
ignore_errors: yes
|
||||||
|
register: leave_swarm
|
||||||
|
|
||||||
|
- name: CLEANUP | Kill Docker and cleanup
|
||||||
|
when: leave_swarm is failed
|
||||||
|
block:
|
||||||
|
- name: CLEANUP | Kill docker daemon
|
||||||
|
command: systemctl kill -s 9 docker
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: CLEANUP | Clear out /var/lib/docker
|
||||||
|
shell: rm -rf /var/lib/docker/*
|
||||||
|
args:
|
||||||
|
warn: no
|
||||||
|
|
||||||
|
- name: CLEANUP | Start docker daemon
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: started
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: CLEANUP | Wait for docker daemon to be fully started
|
||||||
|
command: docker ps
|
||||||
|
register: result
|
||||||
|
until: result is success
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
- name: CLEANUP | Leave Docker Swarm
|
||||||
|
docker_swarm:
|
||||||
|
state: absent
|
||||||
|
force: true
|
|
@ -1,38 +1,18 @@
|
||||||
---
|
- name: Run Docker Swarm tests
|
||||||
# Run the tests
|
when:
|
||||||
- block:
|
- docker_py_version is version('1.10.0', '>=')
|
||||||
- include_tasks: run-test.yml
|
- docker_api_version is version('1.25', '>=')
|
||||||
with_fileglob:
|
|
||||||
- "tests/*.yml"
|
block:
|
||||||
|
- include_tasks: "{{ item }}"
|
||||||
|
with_fileglob:
|
||||||
|
- 'tests/*.yml'
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Cleanup (trying)
|
- import_tasks: cleanup.yml
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: no
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: Kill docker daemon
|
- fail:
|
||||||
command: systemctl kill -s 9 docker
|
msg: "Too old docker / docker-py version to run docker_swarm tests!"
|
||||||
become: yes
|
when:
|
||||||
|
- not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>='))
|
||||||
- name: Restart docker daemon
|
- (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|
||||||
service:
|
|
||||||
name: docker
|
|
||||||
state: restarted
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Wait for docker daemon to be fully restarted
|
|
||||||
command: docker ps
|
|
||||||
|
|
||||||
- name: Cleanup
|
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: no
|
|
||||||
|
|
||||||
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')
|
|
||||||
|
|
||||||
- fail: msg="Too old docker / docker-py version to run docker_swarm tests!"
|
|
||||||
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
- name: Make sure we're not already using Docker swarm
|
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: no
|
|
||||||
- name: "Loading tasks from {{ item }}"
|
|
||||||
include_tasks: "{{ item }}"
|
|
|
@ -1,8 +1,9 @@
|
||||||
---
|
- debug:
|
||||||
|
msg: Running tests/basic.yml
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## Errors ##########################################################
|
## Errors ##########################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
- name: Test parameters with state=join
|
- name: Test parameters with state=join
|
||||||
docker_swarm:
|
docker_swarm:
|
||||||
state: join
|
state: join
|
||||||
|
@ -140,16 +141,18 @@
|
||||||
- name: assert changed when remove a swarm cluster
|
- name: assert changed when remove a swarm cluster
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'output_1 is changed'
|
- 'output_1 is changed'
|
||||||
- 'output_1.diff.before is defined'
|
- 'output_1.diff.before is defined'
|
||||||
- 'output_1.diff.after is defined'
|
- 'output_1.diff.after is defined'
|
||||||
- 'output_2 is changed'
|
- 'output_2 is changed'
|
||||||
- 'output_2.actions[0] == "Node has left the swarm cluster"'
|
- 'output_2.actions[0] == "Node has left the swarm cluster"'
|
||||||
- 'output_2.diff.before is defined'
|
- 'output_2.diff.before is defined'
|
||||||
- 'output_2.diff.after is defined'
|
- 'output_2.diff.after is defined'
|
||||||
- 'output_3 is not changed'
|
- 'output_3 is not changed'
|
||||||
- 'output_3.diff.before is defined'
|
- 'output_3.diff.before is defined'
|
||||||
- 'output_3.diff.after is defined'
|
- 'output_3.diff.after is defined'
|
||||||
- 'output_4 is not changed'
|
- 'output_4 is not changed'
|
||||||
- 'output_4.diff.before is defined'
|
- 'output_4.diff.before is defined'
|
||||||
- 'output_4.diff.after is defined'
|
- 'output_4.diff.after is defined'
|
||||||
|
|
||||||
|
- include_tasks: cleanup.yml
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
---
|
- debug:
|
||||||
- block:
|
msg: Running tests/options-ca.yml
|
||||||
|
|
||||||
|
- name: options-ca
|
||||||
|
when: pyopenssl_version.stdout is version('0.15', '>=') or
|
||||||
|
cryptography_version.stdout is version('1.6', '>=')
|
||||||
|
block:
|
||||||
- name: Generate privatekey
|
- name: Generate privatekey
|
||||||
openssl_privatekey:
|
openssl_privatekey:
|
||||||
path: "{{ output_dir }}/ansible_{{ key }}.key"
|
path: "{{ output_dir }}/ansible_{{ key }}.key"
|
||||||
|
@ -151,4 +156,4 @@
|
||||||
- "'Minimum version required is 2.6.0 ' in output_1.msg"
|
- "'Minimum version required is 2.6.0 ' in output_1.msg"
|
||||||
when: docker_py_version is version('2.6.0', '<')
|
when: docker_py_version is version('2.6.0', '<')
|
||||||
|
|
||||||
when: pyopenssl_version.stdout is version('0.15', '>=') or cryptography_version.stdout is version('1.6', '>=')
|
- include_tasks: cleanup.yml
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
---
|
- debug:
|
||||||
|
msg: Running tests/options.yml
|
||||||
|
|
||||||
- name: Create a Swarm cluster
|
- name: Create a Swarm cluster
|
||||||
docker_swarm:
|
docker_swarm:
|
||||||
state: present
|
state: present
|
||||||
|
@ -1152,3 +1154,5 @@
|
||||||
- 'output_6.actions[0] == "Swarm cluster updated"'
|
- 'output_6.actions[0] == "Swarm cluster updated"'
|
||||||
- 'output_6.diff.before is defined'
|
- 'output_6.diff.before is defined'
|
||||||
- 'output_6.diff.after is defined'
|
- 'output_6.diff.after is defined'
|
||||||
|
|
||||||
|
- include_tasks: cleanup.yml
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
---
|
- debug:
|
||||||
|
msg: Running tests/remote-addr-pool.yml
|
||||||
- name: Remove Swarm cluster
|
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: yes
|
|
||||||
register: output_2
|
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## default_addr_pool ###############################################
|
## default_addr_pool ###############################################
|
||||||
|
@ -29,30 +23,34 @@
|
||||||
register: output_2
|
register: output_2
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: cleanup
|
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: no
|
|
||||||
|
|
||||||
- name: assert default_addr_pool
|
- name: assert default_addr_pool
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'output_1 is changed'
|
- 'output_1 is changed'
|
||||||
- 'output_2 is not changed'
|
- 'output_2 is not changed'
|
||||||
- 'output_2.swarm_facts.DefaultAddrPool == ["2.0.0.0/16"]'
|
- 'output_2.swarm_facts.DefaultAddrPool == ["2.0.0.0/16"]'
|
||||||
when: docker_api_version is version('1.39', '>=') and docker_py_version is version('4.0.0', '>=')
|
when:
|
||||||
|
- docker_api_version is version('1.39', '>=')
|
||||||
|
- docker_py_version is version('4.0.0', '>=')
|
||||||
|
|
||||||
- name: assert default_addr_pool failed when unsupported
|
- name: assert default_addr_pool failed when unsupported
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'output_1 is failed'
|
- 'output_1 is failed'
|
||||||
- "'Minimum version required' in output_1.msg"
|
- "'Minimum version required' in output_1.msg"
|
||||||
when: docker_api_version is version('1.39', '<') or docker_py_version is version('4.0.0', '<')
|
when: docker_api_version is version('1.39', '<') or
|
||||||
|
docker_py_version is version('4.0.0', '<')
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## subnet_size #####################################################
|
## subnet_size #####################################################
|
||||||
####################################################################
|
####################################################################
|
||||||
|
- name: Leave swarm
|
||||||
|
docker_swarm:
|
||||||
|
state: absent
|
||||||
|
force: yes
|
||||||
|
default_addr_pool:
|
||||||
|
- "2.0.0.0/16"
|
||||||
|
diff: yes
|
||||||
|
|
||||||
- name: subnet_size
|
- name: subnet_size
|
||||||
docker_swarm:
|
docker_swarm:
|
||||||
|
@ -77,17 +75,16 @@
|
||||||
- 'output_1 is changed'
|
- 'output_1 is changed'
|
||||||
- 'output_2 is not changed'
|
- 'output_2 is not changed'
|
||||||
- 'output_2.swarm_facts.SubnetSize == 26'
|
- 'output_2.swarm_facts.SubnetSize == 26'
|
||||||
when: docker_api_version is version('1.39', '>=') and docker_py_version is version('4.0.0', '>=')
|
when:
|
||||||
|
- docker_api_version is version('1.39', '>=')
|
||||||
- name: cleanup
|
- docker_py_version is version('4.0.0', '>=')
|
||||||
docker_swarm:
|
|
||||||
state: absent
|
|
||||||
force: true
|
|
||||||
diff: no
|
|
||||||
|
|
||||||
- name: assert subnet_size failed when unsupported
|
- name: assert subnet_size failed when unsupported
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- output_1 is failed
|
- output_1 is failed
|
||||||
- "'Minimum version required' in output_1.msg"
|
- "'Minimum version required' in output_1.msg"
|
||||||
when: docker_api_version is version('1.39', '<') or docker_py_version is version('4.0.0', '<')
|
when: docker_api_version is version('1.39', '<') or
|
||||||
|
docker_py_version is version('4.0.0', '<')
|
||||||
|
|
||||||
|
- include_tasks: cleanup.yml
|
||||||
|
|
Loading…
Reference in a new issue