summaryrefslogtreecommitdiffstats
path: root/test/integration/targets
diff options
context:
space:
mode:
authorRené Moser <mail@renemoser.net>2019-08-29 16:08:54 +0200
committerGitHub <noreply@github.com>2019-08-29 16:08:54 +0200
commit9b5528ab8e3f01577ddb6390174cfa1021037597 (patch)
treee8267507cd7654b0f18794d7ad309478d0e00293 /test/integration/targets
parentadd tag functionality to cs_network (#61530) (diff)
downloadansible-9b5528ab8e3f01577ddb6390174cfa1021037597.tar.xz
ansible-9b5528ab8e3f01577ddb6390174cfa1021037597.zip
cloudscale_volume: refactor to implement tags support (#61531)
Diffstat (limited to 'test/integration/targets')
-rw-r--r--test/integration/targets/cloudscale_volume/tasks/check-mode.yml62
-rw-r--r--test/integration/targets/cloudscale_volume/tasks/failures.yml19
-rw-r--r--test/integration/targets/cloudscale_volume/tasks/tests.yml106
3 files changed, 106 insertions, 81 deletions
diff --git a/test/integration/targets/cloudscale_volume/tasks/check-mode.yml b/test/integration/targets/cloudscale_volume/tasks/check-mode.yml
deleted file mode 100644
index caf8aeed4e..0000000000
--- a/test/integration/targets/cloudscale_volume/tasks/check-mode.yml
+++ /dev/null
@@ -1,62 +0,0 @@
----
-- name: Create volume in check mode
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-check-mode'
- size_gb: 50
- register: check_mode_vol
- check_mode: True
-- name: Delete volume created in check mode
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-check-mode'
- state: 'absent'
- register: check_mode_delete
-- name: 'VERIFY: Create volume in check mode'
- assert:
- that:
- - check_mode_vol is successful
- - check_mode_vol is changed
- - check_mode_delete is successful
- - check_mode_delete is not changed
-
-- name: Create volume
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-vol'
- size_gb: 50
-- name: Attach volume in check mode
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-vol'
- server_uuids:
- - '{{ server.uuid }}'
- check_mode: True
- register: check_mode_attach
-- name: Detach volume
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-vol'
- server_uuids: []
- register: check_mode_detach
-- name: 'VERIFY: Attach volume in check mode'
- assert:
- that:
- - check_mode_attach is successful
- - check_mode_attach is changed
- - check_mode_detach is successful
- - check_mode_detach is not changed
-
-- name: Resize volume in check mode
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-vol'
- size_gb: 100
- register: check_mode_resize
- check_mode: True
-- name: Get volume info
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-vol'
- register: check_mode_info
-- name: 'VERIFY: Resize volume in check mode'
- assert:
- that:
- - check_mode_resize is successful
- - check_mode_resize is changed
- - check_mode_info is successful
- - check_mode_info is not changed
- - check_mode_info.size_gb == 50
diff --git a/test/integration/targets/cloudscale_volume/tasks/failures.yml b/test/integration/targets/cloudscale_volume/tasks/failures.yml
index a1e8612171..cab0d27cdc 100644
--- a/test/integration/targets/cloudscale_volume/tasks/failures.yml
+++ b/test/integration/targets/cloudscale_volume/tasks/failures.yml
@@ -27,6 +27,7 @@
- name: Fail volume creation with UUID
cloudscale_volume:
uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ name: '{{ cloudscale_resource_prefix }}-inexistent'
size_gb: 10
register: vol
ignore_errors: True
@@ -34,20 +35,4 @@
assert:
that:
- vol is failed
-
-- name: Create volume
- cloudscale_volume:
- name: '{{ cloudscale_resource_prefix }}-name-UUID'
- size_gb: 50
- register: vol
-- name: Fail name and UUID
- cloudscale_volume:
- name: '{{ vol.name }}'
- uuid: '{{ vol.uuid }}'
- size_gb: 100
- register: vol
- ignore_errors: True
-- name: 'VERIFY: Fail name and UUID'
- assert:
- that:
- - vol is failed
+ - vol.msg.startswith('The volume with UUID \'ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48\' was not found')
diff --git a/test/integration/targets/cloudscale_volume/tasks/tests.yml b/test/integration/targets/cloudscale_volume/tasks/tests.yml
index 8e93eab9af..d9d9fb00ec 100644
--- a/test/integration/targets/cloudscale_volume/tasks/tests.yml
+++ b/test/integration/targets/cloudscale_volume/tasks/tests.yml
@@ -1,8 +1,29 @@
---
+- name: Create volume in check mode
+ cloudscale_volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Create volume in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.state == 'absent'
+
- name: Create volume
cloudscale_volume:
name: '{{ cloudscale_resource_prefix }}-vol'
size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
register: vol
- name: 'VERIFY: Create volume'
assert:
@@ -11,17 +32,43 @@
- vol is changed
- vol.size_gb == 50
- vol.name == '{{ cloudscale_resource_prefix }}-vol'
+ - vol.tags.project == 'ansible-test'
+ - vol.tags.stage == 'production'
+ - vol.tags.sla == '24-7'
- name: Create volume indempotence
cloudscale_volume:
name: '{{ cloudscale_resource_prefix }}-vol'
size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
register: vol
- name: 'VERIFY: Create volume indempotence'
assert:
that:
- vol is successful
- vol is not changed
+ - vol.size_gb == 50
+ - vol.name == '{{ cloudscale_resource_prefix }}-vol'
+ - vol.tags.project == 'ansible-test'
+ - vol.tags.stage == 'production'
+ - vol.tags.sla == '24-7'
+
+- name: Attach existing volume by name to server in check mode
+ cloudscale_volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ server_uuids:
+ - '{{ server.uuid }}'
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Attach existing volume by name to server in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - server.uuid not in vol.server_uuids
- name: Attach existing volume by name to server
cloudscale_volume:
@@ -49,6 +96,19 @@
- vol is not changed
- server.uuid in vol.server_uuids
+- name: Resize attached volume by UUID in check mode
+ cloudscale_volume:
+ uuid: '{{ vol.uuid }}'
+ size_gb: 100
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Resize attached volume by UUID in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.size_gb == 50
+
- name: Resize attached volume by UUID
cloudscale_volume:
uuid: '{{ vol.uuid }}'
@@ -73,6 +133,21 @@
- vol is not changed
- vol.size_gb == 100
+- name: Delete attached volume by UUID in check mode
+ cloudscale_volume:
+ uuid: '{{ vol.uuid }}'
+ state: 'absent'
+ check_mode: yes
+ register: deleted
+- name: 'VERIFY: Delete attached volume by UUID in check mode'
+ assert:
+ that:
+ - deleted is successful
+ - deleted is changed
+ - deleted.state == 'present'
+ - deleted.uuid == vol.uuid
+ - deleted.name == '{{ cloudscale_resource_prefix }}-vol'
+
- name: Delete attached volume by UUID
cloudscale_volume:
uuid: '{{ vol.uuid }}'
@@ -84,6 +159,8 @@
- deleted is successful
- deleted is changed
- deleted.state == 'absent'
+ - deleted.uuid == vol.uuid
+ - deleted.name == '{{ cloudscale_resource_prefix }}-vol'
- name: Delete attached volume by UUID indempotence
cloudscale_volume:
@@ -96,6 +173,8 @@
- deleted is successful
- deleted is not changed
- deleted.state == 'absent'
+ - deleted.uuid == vol.uuid
+ - not deleted.name
- name: Create bulk volume and attach
cloudscale_volume:
@@ -137,6 +216,19 @@
- bulk is changed
- bulk.size_gb == 200
+- name: Delete volume by name in check mode
+ cloudscale_volume:
+ name: '{{ bulk.name }}'
+ state: 'absent'
+ check_mode: yes
+ register: bulk
+- name: 'VERIFY: Delete volume by name'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.state == 'present'
+
- name: Delete volume by name
cloudscale_volume:
name: '{{ bulk.name }}'
@@ -149,6 +241,16 @@
- bulk is changed
- bulk.state == 'absent'
-- import_tasks: failures.yml
+- name: Delete volume by name idempotence
+ cloudscale_volume:
+ name: '{{ bulk.name }}'
+ state: 'absent'
+ register: bulk
+- name: 'VERIFY: Delete volume by name idempotence'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is not changed
+ - bulk.state == 'absent'
-- import_tasks: check-mode.yml
+- import_tasks: failures.yml