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:
parent
3e52a6a693
commit
6471e4653d
15 changed files with 683 additions and 639 deletions
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: List all floating IPs
|
||||
uri:
|
||||
url: 'https://api.cloudscale.ch/v1/floating-ips'
|
||||
headers:
|
||||
Authorization: 'Bearer {{ cloudscale_api_token }}'
|
||||
status_code: 200
|
||||
register: floating_ip_list
|
||||
|
||||
- name: Remove all floating IPs created by this test run
|
||||
cloudscale_floating_ip:
|
||||
ip: '{{ item.network | ipaddr("address") }}'
|
||||
state: 'absent'
|
||||
when: cloudscale_resource_prefix in (item.reverse_ptr | string )
|
||||
with_items: '{{ floating_ip_list.json }}'
|
||||
loop_control:
|
||||
label: '{{ item.reverse_ptr }} ({{ item.network }})'
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: List all servers
|
||||
uri:
|
||||
url: 'https://api.cloudscale.ch/v1/servers'
|
||||
headers:
|
||||
Authorization: 'Bearer {{ cloudscale_api_token }}'
|
||||
status_code: 200
|
||||
register: server_list
|
||||
|
||||
- name: Remove all servers created by this test run
|
||||
cloudscale_server:
|
||||
uuid: '{{ item.uuid }}'
|
||||
state: 'absent'
|
||||
when: cloudscale_resource_prefix in item.name
|
||||
with_items: '{{ server_list.json }}'
|
||||
loop_control:
|
||||
label: '{{ item.name }} ({{ item.uuid }})'
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: List all volumes
|
||||
uri:
|
||||
url: 'https://api.cloudscale.ch/v1/volumes'
|
||||
headers:
|
||||
Authorization: 'Bearer {{ cloudscale_api_token }}'
|
||||
status_code: 200
|
||||
register: volume_list
|
||||
|
||||
- name: Remove all volumes created by this test run
|
||||
cloudscale_volume:
|
||||
uuid: '{{ item.uuid }}'
|
||||
state: 'absent'
|
||||
when: cloudscale_resource_prefix in item.name
|
||||
with_items: '{{ volume_list.json }}'
|
||||
loop_control:
|
||||
label: '{{ item.name }} ({{ item.uuid }})'
|
2
test/integration/targets/cloudscale_floating_ip/aliases
Normal file
2
test/integration/targets/cloudscale_floating_ip/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/cloudscale
|
||||
unsupported
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- cloudscale_common
|
|
@ -2,7 +2,7 @@
|
|||
block:
|
||||
- name: Create a server
|
||||
cloudscale_server:
|
||||
name: '{{ resource_prefix }}-test01'
|
||||
name: '{{ cloudscale_resource_prefix }}-test01'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
- name: Create a second server
|
||||
cloudscale_server:
|
||||
name: '{{ resource_prefix }}-test02'
|
||||
name: '{{ cloudscale_resource_prefix }}-test02'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
|
@ -18,16 +18,14 @@
|
|||
|
||||
- include_tasks: floating_ip.yml
|
||||
with_items:
|
||||
- { 'ip_version': 4, 'reverse_ptr': 'my-floating-ipv4.example.com' }
|
||||
- { 'ip_version': 6 }
|
||||
- { 'ip_version': 4, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-4.example.com' }
|
||||
- { 'ip_version': 6, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-6.example.com' }
|
||||
- { 'ip_version': 6, 'prefix_length': 56 }
|
||||
|
||||
always:
|
||||
- name: Delete servers
|
||||
cloudscale_server:
|
||||
uuid: '{{ item.uuid }}'
|
||||
state: 'absent'
|
||||
ignore_errors: True
|
||||
with_items:
|
||||
- '{{ test01 }}'
|
||||
- '{{ test02 }}'
|
||||
- import_role:
|
||||
name: cloudscale_common
|
||||
tasks_from: cleanup_servers
|
||||
- import_role:
|
||||
name: cloudscale_common
|
||||
tasks_from: cleanup_floating_ips
|
|
@ -1,447 +1,7 @@
|
|||
---
|
||||
- name: Test create a running server in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify create a running server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test create a running server
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
- name: Verify create a running server
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test create a running server idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
- name: Verify create a running server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test update flavor of a running server without force in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor of a running server without force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor of a running server without force
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor of a running server without force
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor of a running server without force idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor of a running server without force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor and name of a running server without force in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor and name of a running server without force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
- name: Test update flavor and name of a running server without force
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor and name of a running server without force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor and name of a running server without force idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor and name of a running server without force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor of a running server with force in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor of a running server with force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor of a running server with force
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
- name: Verify update flavor of a running server with force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update a running server with force idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
- name: Verify update flavor of a running server with force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Remember uuid of running server for anti affinity
|
||||
set_fact:
|
||||
running_server_uuid: '{{ server.uuid }}'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
check_mode: yes
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only in check mode
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'absent'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'stopped'
|
||||
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||
- server_stopped.interfaces.0.type == 'private'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only idempotence
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is not changed
|
||||
- server_stopped.state == 'stopped'
|
||||
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||
- server_stopped.interfaces.0.type == 'private'
|
||||
|
||||
- name: Test create server failure without required parameters
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-failed'
|
||||
register: server_failed
|
||||
ignore_errors: yes
|
||||
- name: Verify create server failure without required parameters
|
||||
assert:
|
||||
that:
|
||||
- server_failed is failed
|
||||
- "'missing required arguments' in server_failed.msg"
|
||||
|
||||
- name: Test stop running server in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: stopped
|
||||
check_mode: yes
|
||||
register: server
|
||||
- name: Verify stop running server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test stop running server
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify stop running server
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test stop running server idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: 'stopped'
|
||||
register: server
|
||||
- name: Verify stop running server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test update a stopped server in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update a stopped server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update a stopped server without force
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify update a stopped server without force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
|
||||
- name: Test update a stopped server idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify update a stopped server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
- name: Test server running in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify server running in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test server running
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
- name: Verify server running
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test server running idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
- name: Verify server running idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test running server deletion by name in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify running server deletion by name in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test running server deletion by name
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
- name: Verify running server deletion by name
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test running server deletion by name idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
- name: Verify running server deletion by name idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test stopped server deletion by uuid in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
check_mode: yes
|
||||
- name: Verify stopped server deletion by uuid in check mode
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'stopped'
|
||||
|
||||
- name: Test stopped server deletion by uuid
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
- name: Verify stopped server deletion by uuid
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'absent'
|
||||
|
||||
- name: Test stopped server deletion by uuid idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
- name: Verify stopped server deletion by uuid idempotence
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is not changed
|
||||
- server_stopped.state == 'absent'
|
||||
- block:
|
||||
- import_tasks: tests.yml
|
||||
always:
|
||||
- import_role:
|
||||
name: cloudscale_common
|
||||
tasks_from: cleanup_servers
|
||||
|
|
447
test/integration/targets/cloudscale_server/tasks/tests.yml
Normal file
447
test/integration/targets/cloudscale_server/tasks/tests.yml
Normal file
|
@ -0,0 +1,447 @@
|
|||
---
|
||||
- name: Test create a running server in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify create a running server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test create a running server
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
- name: Verify create a running server
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test create a running server idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
register: server
|
||||
- name: Verify create a running server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test update flavor of a running server without force in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor of a running server without force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor of a running server without force
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor of a running server without force
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor of a running server without force idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor of a running server without force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
|
||||
- name: Test update flavor and name of a running server without force in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor and name of a running server without force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
- name: Test update flavor and name of a running server without force
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor and name of a running server without force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor and name of a running server without force idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: no
|
||||
register: server
|
||||
- name: Verify update flavor and name of a running server without force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor of a running server with force in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update flavor of a running server with force in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update flavor of a running server with force
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
- name: Verify update flavor of a running server with force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update a running server with force idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
flavor: '{{ cloudscale_test_flavor_2 }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
force: yes
|
||||
register: server
|
||||
- name: Verify update flavor of a running server with force idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Remember uuid of running server for anti affinity
|
||||
set_fact:
|
||||
running_server_uuid: '{{ server.uuid }}'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
check_mode: yes
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only in check mode
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'absent'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'stopped'
|
||||
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||
- server_stopped.interfaces.0.type == 'private'
|
||||
|
||||
- name: Test create server stopped in anti affinity and private network only idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
anti_affinity_with: '{{ running_server_uuid }}'
|
||||
use_public_network: no
|
||||
use_private_network: yes
|
||||
state: stopped
|
||||
register: server_stopped
|
||||
- name: Verify create server stopped in anti affinity and private network only idempotence
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is not changed
|
||||
- server_stopped.state == 'stopped'
|
||||
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||
- server_stopped.interfaces.0.type == 'private'
|
||||
|
||||
- name: Test create server failure without required parameters
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-failed'
|
||||
register: server_failed
|
||||
ignore_errors: yes
|
||||
- name: Verify create server failure without required parameters
|
||||
assert:
|
||||
that:
|
||||
- server_failed is failed
|
||||
- "'missing required arguments' in server_failed.msg"
|
||||
|
||||
- name: Test stop running server in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: stopped
|
||||
check_mode: yes
|
||||
register: server
|
||||
- name: Verify stop running server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test stop running server
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify stop running server
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test stop running server idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
state: 'stopped'
|
||||
register: server
|
||||
- name: Verify stop running server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test update a stopped server in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify update a stopped server in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||
|
||||
- name: Test update a stopped server without force
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify update a stopped server without force
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
|
||||
- name: Test update a stopped server idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server.uuid }}'
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
flavor: '{{ cloudscale_test_flavor }}'
|
||||
image: '{{ cloudscale_test_image }}'
|
||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||
state: stopped
|
||||
register: server
|
||||
- name: Verify update a stopped server idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'stopped'
|
||||
- server.flavor.slug == '{{ cloudscale_test_flavor }}'
|
||||
- server.name == '{{ cloudscale_resource_prefix }}-test'
|
||||
|
||||
- name: Test server running in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify server running in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'stopped'
|
||||
|
||||
- name: Test server running
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
- name: Verify server running
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test server running idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: running
|
||||
register: server
|
||||
- name: Verify server running idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test running server deletion by name in check mode
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
check_mode: yes
|
||||
- name: Verify running server deletion by name in check mode
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'running'
|
||||
|
||||
- name: Test running server deletion by name
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
- name: Verify running server deletion by name
|
||||
assert:
|
||||
that:
|
||||
- server is changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test running server deletion by name idempotence
|
||||
cloudscale_server:
|
||||
name: '{{ cloudscale_resource_prefix }}-test'
|
||||
state: absent
|
||||
register: server
|
||||
- name: Verify running server deletion by name idempotence
|
||||
assert:
|
||||
that:
|
||||
- server is not changed
|
||||
- server.state == 'absent'
|
||||
|
||||
- name: Test stopped server deletion by uuid in check mode
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
check_mode: yes
|
||||
- name: Verify stopped server deletion by uuid in check mode
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'stopped'
|
||||
|
||||
- name: Test stopped server deletion by uuid
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
- name: Verify stopped server deletion by uuid
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is changed
|
||||
- server_stopped.state == 'absent'
|
||||
|
||||
- name: Test stopped server deletion by uuid idempotence
|
||||
cloudscale_server:
|
||||
uuid: '{{ server_stopped.uuid }}'
|
||||
state: absent
|
||||
register: server_stopped
|
||||
- name: Verify stopped server deletion by uuid idempotence
|
||||
assert:
|
||||
that:
|
||||
- server_stopped is not changed
|
||||
- server_stopped.state == 'absent'
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tags:
|
||||
- cloudscale
|
||||
roles:
|
||||
- { role: cloudscale_floating_ip, tags: cloudscale_floating_ip }
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
cloudscale_test_flavor: flex-2
|
||||
cloudscale_test_image: debian-9
|
||||
cloudscale_test_ssh_key: |
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
@ -1,2 +0,0 @@
|
|||
dependencies:
|
||||
- prepare_tests
|
Loading…
Reference in a new issue