mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Integration test cleanup for cloudscale modules (#53629)
* Integration test cleanup for cloudscale modules This refactors the cleanup procedure for the integration tests of the cloudscale_server and cloudscale_volume modules to use an "always" section for cleanup. The cleanup code also deletes all resources which contain the test run prefix. This ensures that all resources are cleaned up regardless of the actual test result which is a prerequisite for running these tests in CI. * Move cloudscale_floating_ip tests from legacy to integration This also adds code to make sure that floating IPs are deleted even if a test run fails. This is unfortunately not possible for floatint IPv6 networks.
This commit is contained in:
committed by
René Moser
parent
3e52a6a693
commit
6471e4653d
@@ -24,12 +24,6 @@
|
||||
that:
|
||||
- vol is failed
|
||||
|
||||
- name: Delete duplicate volumes by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ item.json.uuid }}'
|
||||
state: 'absent'
|
||||
with_items: '{{ duplicate.results }}'
|
||||
|
||||
- name: Fail volume creation with UUID
|
||||
cloudscale_volume:
|
||||
uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
|
||||
@@ -57,7 +51,3 @@
|
||||
assert:
|
||||
that:
|
||||
- vol is failed
|
||||
- name: 'Delete volume'
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-name-UUID'
|
||||
state: 'absent'
|
||||
|
||||
@@ -1,158 +1,11 @@
|
||||
---
|
||||
- import_tasks: setup.yml
|
||||
|
||||
- name: Create volume
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
size_gb: 50
|
||||
register: vol
|
||||
- name: 'VERIFY: Create volume'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- vol.size_gb == 50
|
||||
- vol.name == '{{ cloudscale_resource_prefix }}-vol'
|
||||
|
||||
- name: Create volume indempotence
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
size_gb: 50
|
||||
register: vol
|
||||
- name: 'VERIFY: Create volume indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
|
||||
- name: Attach existing volume by name to server
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: vol
|
||||
- name: 'VERIFY: Attach existing volume by name to server'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- server.uuid in vol.server_uuids
|
||||
|
||||
- name: Attach existing volume by name to server indempotence
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: vol
|
||||
- name: 'VERIFY: Attach existing volume by name to server indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
- server.uuid in vol.server_uuids
|
||||
|
||||
- name: Resize attached volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
size_gb: 100
|
||||
register: vol
|
||||
- name: 'VERIFY: Resize attached volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- vol.size_gb == 100
|
||||
|
||||
- name: Resize attached volume by UUID indempotence
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
size_gb: 100
|
||||
register: vol
|
||||
- name: 'VERIFY: Resize attached volume by UUID indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
- vol.size_gb == 100
|
||||
|
||||
- name: Delete attached volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
state: 'absent'
|
||||
register: deleted
|
||||
- name: 'VERIFY: Delete attached volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- deleted is successful
|
||||
- deleted is changed
|
||||
- deleted.state == 'absent'
|
||||
|
||||
- name: Delete attached volume by UUID indempotence
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
state: 'absent'
|
||||
register: deleted
|
||||
- name: 'VERIFY: Delete attached volume by UUID indempotence'
|
||||
assert:
|
||||
that:
|
||||
- deleted is successful
|
||||
- deleted is not changed
|
||||
- deleted.state == 'absent'
|
||||
|
||||
- name: Create bulk volume and attach
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-bulk'
|
||||
type: bulk
|
||||
size_gb: 100
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: bulk
|
||||
- name: 'VERIFY: Create bulk volume and attach'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.size_gb == 100
|
||||
- server.uuid in bulk.server_uuids
|
||||
|
||||
- name: Detach volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ bulk.uuid }}'
|
||||
server_uuids: []
|
||||
register: bulk
|
||||
- name: 'VERIFY: Detach volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.server_uuids == []
|
||||
|
||||
- name: Resize detached volume by name
|
||||
cloudscale_volume:
|
||||
name: '{{ bulk.name }}'
|
||||
size_gb: 200
|
||||
register: bulk
|
||||
- name: 'VERIFY: Resize detached volume by name'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.size_gb == 200
|
||||
|
||||
- name: Delete volume by name
|
||||
cloudscale_volume:
|
||||
name: '{{ bulk.name }}'
|
||||
state: 'absent'
|
||||
register: bulk
|
||||
- name: 'VERIFY: Delete volume by name'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.state == 'absent'
|
||||
|
||||
- import_tasks: failures.yml
|
||||
|
||||
- import_tasks: check-mode.yml
|
||||
|
||||
- import_tasks: cleanup.yml
|
||||
- block:
|
||||
- import_tasks: setup.yml
|
||||
- import_tasks: tests.yml
|
||||
always:
|
||||
- import_role:
|
||||
name: cloudscale_common
|
||||
tasks_from: cleanup_servers
|
||||
- import_role:
|
||||
name: cloudscale_common
|
||||
tasks_from: cleanup_volumes
|
||||
|
||||
154
test/integration/targets/cloudscale_volume/tasks/tests.yml
Normal file
154
test/integration/targets/cloudscale_volume/tasks/tests.yml
Normal file
@@ -0,0 +1,154 @@
|
||||
---
|
||||
- name: Create volume
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
size_gb: 50
|
||||
register: vol
|
||||
- name: 'VERIFY: Create volume'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- vol.size_gb == 50
|
||||
- vol.name == '{{ cloudscale_resource_prefix }}-vol'
|
||||
|
||||
- name: Create volume indempotence
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
size_gb: 50
|
||||
register: vol
|
||||
- name: 'VERIFY: Create volume indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
|
||||
- name: Attach existing volume by name to server
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: vol
|
||||
- name: 'VERIFY: Attach existing volume by name to server'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- server.uuid in vol.server_uuids
|
||||
|
||||
- name: Attach existing volume by name to server indempotence
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-vol'
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: vol
|
||||
- name: 'VERIFY: Attach existing volume by name to server indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
- server.uuid in vol.server_uuids
|
||||
|
||||
- name: Resize attached volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
size_gb: 100
|
||||
register: vol
|
||||
- name: 'VERIFY: Resize attached volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is changed
|
||||
- vol.size_gb == 100
|
||||
|
||||
- name: Resize attached volume by UUID indempotence
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
size_gb: 100
|
||||
register: vol
|
||||
- name: 'VERIFY: Resize attached volume by UUID indempotence'
|
||||
assert:
|
||||
that:
|
||||
- vol is successful
|
||||
- vol is not changed
|
||||
- vol.size_gb == 100
|
||||
|
||||
- name: Delete attached volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
state: 'absent'
|
||||
register: deleted
|
||||
- name: 'VERIFY: Delete attached volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- deleted is successful
|
||||
- deleted is changed
|
||||
- deleted.state == 'absent'
|
||||
|
||||
- name: Delete attached volume by UUID indempotence
|
||||
cloudscale_volume:
|
||||
uuid: '{{ vol.uuid }}'
|
||||
state: 'absent'
|
||||
register: deleted
|
||||
- name: 'VERIFY: Delete attached volume by UUID indempotence'
|
||||
assert:
|
||||
that:
|
||||
- deleted is successful
|
||||
- deleted is not changed
|
||||
- deleted.state == 'absent'
|
||||
|
||||
- name: Create bulk volume and attach
|
||||
cloudscale_volume:
|
||||
name: '{{ cloudscale_resource_prefix }}-bulk'
|
||||
type: bulk
|
||||
size_gb: 100
|
||||
server_uuids:
|
||||
- '{{ server.uuid }}'
|
||||
register: bulk
|
||||
- name: 'VERIFY: Create bulk volume and attach'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.size_gb == 100
|
||||
- server.uuid in bulk.server_uuids
|
||||
|
||||
- name: Detach volume by UUID
|
||||
cloudscale_volume:
|
||||
uuid: '{{ bulk.uuid }}'
|
||||
server_uuids: []
|
||||
register: bulk
|
||||
- name: 'VERIFY: Detach volume by UUID'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.server_uuids == []
|
||||
|
||||
- name: Resize detached volume by name
|
||||
cloudscale_volume:
|
||||
name: '{{ bulk.name }}'
|
||||
size_gb: 200
|
||||
register: bulk
|
||||
- name: 'VERIFY: Resize detached volume by name'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.size_gb == 200
|
||||
|
||||
- name: Delete volume by name
|
||||
cloudscale_volume:
|
||||
name: '{{ bulk.name }}'
|
||||
state: 'absent'
|
||||
register: bulk
|
||||
- name: 'VERIFY: Delete volume by name'
|
||||
assert:
|
||||
that:
|
||||
- bulk is successful
|
||||
- bulk is changed
|
||||
- bulk.state == 'absent'
|
||||
|
||||
- import_tasks: failures.yml
|
||||
|
||||
- import_tasks: check-mode.yml
|
||||
Reference in New Issue
Block a user