summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/docker_swarm/tasks/main.yml15
-rw-r--r--test/integration/targets/docker_swarm/tasks/run-test.yml8
-rw-r--r--test/integration/targets/docker_swarm/tasks/test_swarm.yml108
-rw-r--r--test/integration/targets/docker_swarm/tasks/tests/basic.yml132
4 files changed, 154 insertions, 109 deletions
diff --git a/test/integration/targets/docker_swarm/tasks/main.yml b/test/integration/targets/docker_swarm/tasks/main.yml
index 94a923c138..04d8cef912 100644
--- a/test/integration/targets/docker_swarm/tasks/main.yml
+++ b/test/integration/targets/docker_swarm/tasks/main.yml
@@ -1,4 +1,17 @@
-- include_tasks: test_swarm.yml
+---
+# Run the tests
+- block:
+ - include_tasks: run-test.yml
+ with_fileglob:
+ - "tests/*.yml"
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
+ diff: no
+
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.25', '>=')
- fail: msg="Too old docker / docker-py version to run docker_swarm tests!"
diff --git a/test/integration/targets/docker_swarm/tasks/run-test.yml b/test/integration/targets/docker_swarm/tasks/run-test.yml
new file mode 100644
index 0000000000..d9069c90b5
--- /dev/null
+++ b/test/integration/targets/docker_swarm/tasks/run-test.yml
@@ -0,0 +1,8 @@
+---
+- 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 }}"
diff --git a/test/integration/targets/docker_swarm/tasks/test_swarm.yml b/test/integration/targets/docker_swarm/tasks/test_swarm.yml
deleted file mode 100644
index 28cf74c826..0000000000
--- a/test/integration/targets/docker_swarm/tasks/test_swarm.yml
+++ /dev/null
@@ -1,108 +0,0 @@
----
-- block:
- - name: Make sure we're not already using Docker swarm
- docker_swarm:
- state: absent
- force: true
-
- - name: Test parameters with state=join
- docker_swarm:
- state: join
- ignore_errors: yes
- register: output
-
- - name: assert failure when called with state=join and no advertise_addr,remote_addrs,join_token
- assert:
- that:
- - 'output.failed'
- - 'output.msg == "state is join but all of the following are missing: advertise_addr, remote_addrs, join_token"'
-
- - name: Test parameters with state=remove
- docker_swarm:
- state: remove
- ignore_errors: yes
- register: output
-
- - name: assert failure when called with state=remove and no node_id
- assert:
- that:
- - 'output.failed'
- - 'output.msg == "state is remove but all of the following are missing: node_id"'
-
- - name: Create a Swarm cluster (check mode)
- docker_swarm:
- state: present
- advertise_addr: "{{ansible_default_ipv4.address}}"
- check_mode: yes
- register: output_1
-
- - name: Create a Swarm cluster
- docker_swarm:
- state: present
- advertise_addr: "{{ansible_default_ipv4.address}}"
- register: output_2
-
- - name: Create a Swarm cluster (idempotent)
- docker_swarm:
- state: present
- advertise_addr: "{{ansible_default_ipv4.address}}"
- register: output_3
-
- - name: Create a Swarm cluster (idempotent, check mode)
- docker_swarm:
- state: present
- advertise_addr: "{{ansible_default_ipv4.address}}"
- check_mode: yes
- register: output_4
-
- - name: assert changed when create a new swarm cluster
- assert:
- that:
- - 'output_1 is changed'
- - 'output_2 is changed'
- - 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
- - 'output_2.swarm_facts.JoinTokens.Manager'
- - 'output_2.swarm_facts.JoinTokens.Worker'
- - 'output_3 is not changed'
- - 'output_4 is not changed'
-
- - name: Remove a Swarm cluster (check mode)
- docker_swarm:
- state: absent
- force: true
- check_mode: yes
- register: output_1
-
- - name: Remove a Swarm cluster
- docker_swarm:
- state: absent
- force: true
- register: output_2
-
- - name: Remove a Swarm cluster (idempotent)
- docker_swarm:
- state: absent
- force: true
- register: output_3
-
- - name: Remove a Swarm cluster (idempotent, check mode)
- docker_swarm:
- state: absent
- force: true
- check_mode: yes
- register: output_4
-
- - name: assert changed when remove a swarm cluster
- assert:
- that:
- - 'output_1 is changed'
- - 'output_2 is changed'
- - 'output_2.actions[0] == "Node has left the swarm cluster"'
- - 'output_3 is not changed'
- - 'output_4 is not changed'
-
- always:
- - name: Cleanup
- docker_swarm:
- state: absent
- force: true
diff --git a/test/integration/targets/docker_swarm/tasks/tests/basic.yml b/test/integration/targets/docker_swarm/tasks/tests/basic.yml
new file mode 100644
index 0000000000..98bfbf56d2
--- /dev/null
+++ b/test/integration/targets/docker_swarm/tasks/tests/basic.yml
@@ -0,0 +1,132 @@
+---
+####################################################################
+## Errors ##########################################################
+####################################################################
+
+- name: Test parameters with state=join
+ docker_swarm:
+ state: join
+ ignore_errors: yes
+ register: output
+
+- name: assert failure when called with state=join and no advertise_addr,remote_addrs,join_token
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is join but all of the following are missing: advertise_addr, remote_addrs, join_token"'
+
+- name: Test parameters with state=remove
+ docker_swarm:
+ state: remove
+ ignore_errors: yes
+ register: output
+
+- name: assert failure when called with state=remove and no node_id
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is remove but all of the following are missing: node_id"'
+
+####################################################################
+## Creation ########################################################
+####################################################################
+
+- name: Create a Swarm cluster (check mode)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ diff: yes
+ register: output_2
+
+- name: Create a Swarm cluster (idempotent)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ diff: yes
+ register: output_3
+
+- name: Create a Swarm cluster (idempotent, check mode)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: assert changed when create a new swarm cluster
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
+ - 'output_2.swarm_facts.JoinTokens.Manager'
+ - 'output_2.swarm_facts.JoinTokens.Worker'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+
+####################################################################
+## Removal #########################################################
+####################################################################
+
+- name: Remove a Swarm cluster (check mode)
+ docker_swarm:
+ state: absent
+ force: true
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: Remove a Swarm cluster
+ docker_swarm:
+ state: absent
+ force: true
+ diff: yes
+ register: output_2
+
+- name: Remove a Swarm cluster (idempotent)
+ docker_swarm:
+ state: absent
+ force: true
+ diff: yes
+ register: output_3
+
+- name: Remove a Swarm cluster (idempotent, check mode)
+ docker_swarm:
+ state: absent
+ force: true
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: assert changed when remove a swarm cluster
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Node has left the swarm cluster"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'