docker_network: adding/updating tests (#47775)
* Add substring test (fixes #32927).
* Extend idempotency tests (fixes #32580).
(cherry picked from commit 2dab10f1ec
)
This commit is contained in:
parent
953568e213
commit
0dd8d73a38
2 changed files with 61 additions and 6 deletions
|
@ -31,6 +31,22 @@
|
|||
state: present
|
||||
register: networks_1
|
||||
|
||||
- name: Connect network to containers 1
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ cname_1 }}"
|
||||
register: networks_2
|
||||
|
||||
- name: Connect network to containers 1 (idempotency)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ cname_1 }}"
|
||||
register: networks_2_idem
|
||||
|
||||
- name: Connect network to containers 1 and 2
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
|
@ -38,7 +54,7 @@
|
|||
connected:
|
||||
- "{{ cname_1 }}"
|
||||
- "{{ cname_2 }}"
|
||||
register: networks_2
|
||||
register: networks_3
|
||||
|
||||
- name: Connect network to containers 1 and 2 (idempotency)
|
||||
docker_network:
|
||||
|
@ -47,7 +63,7 @@
|
|||
connected:
|
||||
- "{{ cname_1 }}"
|
||||
- "{{ cname_2 }}"
|
||||
register: networks_2_idem
|
||||
register: networks_3_idem
|
||||
|
||||
- name: Connect network to container 3
|
||||
docker_network:
|
||||
|
@ -56,7 +72,7 @@
|
|||
connected:
|
||||
- "{{ cname_3 }}"
|
||||
appends: yes
|
||||
register: networks_3
|
||||
register: networks_4
|
||||
|
||||
- name: Connect network to container 3 (idempotency)
|
||||
docker_network:
|
||||
|
@ -65,7 +81,7 @@
|
|||
connected:
|
||||
- "{{ cname_3 }}"
|
||||
appends: yes
|
||||
register: networks_3_idem
|
||||
register: networks_4_idem
|
||||
|
||||
- name: Disconnect network from container 1
|
||||
docker_network:
|
||||
|
@ -74,7 +90,7 @@
|
|||
connected:
|
||||
- "{{ cname_2 }}"
|
||||
- "{{ cname_3 }}"
|
||||
register: networks_4
|
||||
register: networks_5
|
||||
|
||||
- name: Disconnect network from container 1 (idempotency)
|
||||
docker_network:
|
||||
|
@ -83,7 +99,7 @@
|
|||
connected:
|
||||
- "{{ cname_2 }}"
|
||||
- "{{ cname_3 }}"
|
||||
register: networks_4_idem
|
||||
register: networks_5_idem
|
||||
|
||||
- name: Cleanup
|
||||
docker_network:
|
||||
|
@ -101,6 +117,8 @@
|
|||
# - networks_3_idem is not changed
|
||||
- networks_4 is changed
|
||||
# - networks_4_idem is not changed
|
||||
- networks_5 is changed
|
||||
# - networks_5_idem is not changed
|
||||
|
||||
####################################################################
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
- name: Registering container and network names
|
||||
set_fact:
|
||||
nname_1: "{{ name_prefix ~ '-network-foo' }}"
|
||||
nname_2: "{{ name_prefix ~ '-network-foobar' }}"
|
||||
- name: Registering container and network names
|
||||
set_fact:
|
||||
dnetworks: "{{ dnetworks }} + [nname_1, nname_2]"
|
||||
|
||||
####################################################################
|
||||
|
||||
- name: Create network (superstring)
|
||||
docker_network:
|
||||
name: "{{ nname_2 }}"
|
||||
state: present
|
||||
register: networks_1
|
||||
|
||||
- name: Create network (substring)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
state: present
|
||||
register: networks_2
|
||||
|
||||
- name: Cleanup
|
||||
docker_network:
|
||||
name: "{{ network_name }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ nname_1 }}"
|
||||
- "{{ nname_2 }}"
|
||||
loop_control:
|
||||
loop_var: network_name
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- networks_1 is changed
|
||||
- networks_2 is changed
|
Loading…
Reference in a new issue