From 0dd8d73a38c9a7bf780723de0cbf769868e93b98 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 29 Oct 2018 22:34:00 +0100 Subject: [PATCH] docker_network: adding/updating tests (#47775) * Add substring test (fixes #32927). * Extend idempotency tests (fixes #32580). (cherry picked from commit 2dab10f1ec381a2a7f10ed943031b696971d9bad) --- .../docker_network/tasks/tests/basic.yml | 30 ++++++++++++--- .../docker_network/tasks/tests/substring.yml | 37 +++++++++++++++++++ 2 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 test/integration/targets/docker_network/tasks/tests/substring.yml diff --git a/test/integration/targets/docker_network/tasks/tests/basic.yml b/test/integration/targets/docker_network/tasks/tests/basic.yml index ffcf7f0e2a9..0b270cc7201 100644 --- a/test/integration/targets/docker_network/tasks/tests/basic.yml +++ b/test/integration/targets/docker_network/tasks/tests/basic.yml @@ -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 #################################################################### diff --git a/test/integration/targets/docker_network/tasks/tests/substring.yml b/test/integration/targets/docker_network/tasks/tests/substring.yml new file mode 100644 index 00000000000..d789348b2d4 --- /dev/null +++ b/test/integration/targets/docker_network/tasks/tests/substring.yml @@ -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