Integration tests for docker_node_facts (#52423)
parent
36e0415d64
commit
e284a1546f
|
@ -0,0 +1,5 @@
|
|||
shippable/posix/group2
|
||||
skip/osx
|
||||
skip/freebsd
|
||||
destructive
|
||||
skip/rhel8.0
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- setup_docker
|
|
@ -0,0 +1,5 @@
|
|||
- include_tasks: test_node_facts.yml
|
||||
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')
|
||||
|
||||
- fail: msg="Too old docker / docker-py version to run docker_swarm_facts tests!"
|
||||
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|
|
@ -0,0 +1,87 @@
|
|||
---
|
||||
- block:
|
||||
- name: Make sure we're not already using Docker swarm
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: true
|
||||
|
||||
- name: Try to get docker_node_facts when docker is not running in swarm mode
|
||||
docker_node_facts:
|
||||
ignore_errors: yes
|
||||
register: output
|
||||
|
||||
- name: assert failure when called when swarm is not in use or not run on manager node
|
||||
assert:
|
||||
that:
|
||||
- 'output is failed'
|
||||
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
|
||||
|
||||
- name: Create a Swarm cluster
|
||||
docker_swarm:
|
||||
state: present
|
||||
register: output
|
||||
|
||||
- name: assert changed when create a new swarm cluster
|
||||
assert:
|
||||
that:
|
||||
- 'output is changed'
|
||||
- 'output.actions[0] | regex_search("New Swarm cluster created: ")'
|
||||
- 'output.swarm_facts.JoinTokens.Manager'
|
||||
- 'output.swarm_facts.JoinTokens.Worker'
|
||||
|
||||
- name: Try to get docker_node_facts when docker is running in swarm mode and as manager
|
||||
docker_node_facts:
|
||||
register: output
|
||||
|
||||
- name: assert reading docker swarm node facts
|
||||
assert:
|
||||
that:
|
||||
- 'output.nodes_facts | length > 0'
|
||||
- 'output.nodes_facts[0].ID is string'
|
||||
|
||||
- name: Try to get docker_node_facts using the self parameter
|
||||
docker_node_facts:
|
||||
self: yes
|
||||
register: output
|
||||
|
||||
- name: assert reading swarm facts with list of nodes option
|
||||
assert:
|
||||
that:
|
||||
- 'output.nodes_facts | length == 1'
|
||||
- 'output.nodes_facts[0].ID is string'
|
||||
|
||||
- name: Get local docker node name
|
||||
set_fact:
|
||||
localnodename: "{{ output.nodes_facts[0].Description.Hostname }}"
|
||||
|
||||
|
||||
- name: Try to get docker_node_facts using the local node name as parameter
|
||||
docker_node_facts:
|
||||
name: "{{ localnodename }}"
|
||||
register: output
|
||||
|
||||
- name: assert reading reading swarm facts and using node filter (random node name)
|
||||
assert:
|
||||
that:
|
||||
- 'output.nodes_facts | length == 1'
|
||||
- 'output.nodes_facts[0].ID is string'
|
||||
|
||||
- name: Create random name
|
||||
set_fact:
|
||||
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
|
||||
|
||||
- name: Try to get docker_node_facts using random node name as parameter
|
||||
docker_node_facts:
|
||||
name: "{{ randomnodename }}"
|
||||
register: output
|
||||
|
||||
- name: assert reading reading swarm facts and using node filter (random node name)
|
||||
assert:
|
||||
that:
|
||||
- 'output.nodes_facts | length == 0'
|
||||
|
||||
always:
|
||||
- name: Cleanup
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: true
|
Loading…
Reference in New Issue