Skip to content

Commit

Permalink
add volume
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Nov 25, 2024
1 parent 158a393 commit 5413316
Show file tree
Hide file tree
Showing 6 changed files with 529 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/volume/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cloud/cs
cs/group2
cs/group3
8 changes: 8 additions & 0 deletions tests/integration/targets/volume/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
test_cs_instance_1: "{{ cs_resource_prefix }}-vm1"
test_cs_instance_2: "{{ cs_resource_prefix }}-vm2"
test_cs_instance_3: "{{ cs_resource_prefix }}-vm3"
test_cs_instance_template: "{{ cs_common_template }}"
test_cs_instance_offering_1: Small Instance
test_cs_disk_offering_1: Custom
test_cs_volume_to_upload: https://ansible-ci-files.s3.us-east-1.amazonaws.com/test/integration/targets/cs_volume/macchinina-xen.vhd.bz2
3 changes: 3 additions & 0 deletions tests/integration/targets/volume/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- cs_common
322 changes: 322 additions & 0 deletions tests/integration/targets/volume/tasks/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
---
- name: setup
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: vol
- name: verify setup
assert:
that:
- vol is successful

- name: setup instance 1
ngine_io.cloudstack.instance:
name: "{{ test_cs_instance_1 }}"
template: "{{ test_cs_instance_template }}"
service_offering: "{{ test_cs_instance_offering_1 }}"
zone: "{{ cs_common_zone_basic }}"
register: instance
- name: verify create instance
assert:
that:
- instance is successful

- name: setup instance 2
ngine_io.cloudstack.instance:
name: "{{ test_cs_instance_2 }}"
template: "{{ test_cs_instance_template }}"
service_offering: "{{ test_cs_instance_offering_1 }}"
zone: "{{ cs_common_zone_basic }}"
register: instance
- name: verify create instance
assert:
that:
- instance is successful

- name: test fail if missing name
ngine_io.cloudstack.volume:
zone: "{{ cs_common_zone_basic }}"
register: vol
ignore_errors: true
- name: verify results of fail if missing name
assert:
that:
- vol is failed
- "vol.msg == 'missing required arguments: name'"

- name: test create volume in check mode
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 20
register: vol
check_mode: true
- name: verify results test create volume in check mode
assert:
that:
- vol is changed

- name: test create volume
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 20
register: vol
- name: verify results test create volume
assert:
that:
- vol is changed
- vol.size == 20 * 1024 ** 3
- vol.name == cs_resource_prefix + "_vol"

- name: test create volume idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 20
register: vol
- name: verify results test create volume idempotence
assert:
that:
- vol is not changed
- vol.size == 20 * 1024 ** 3
- vol.name == cs_resource_prefix + "_vol"

- name: test shrink volume in check mode
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 10
shrink_ok: yes
register: vol
check_mode: true
- name: verify results test create volume in check mode
assert:
that:
- vol is changed
- vol.size == 20 * 1024 ** 3
- vol.name == cs_resource_prefix + "_vol"

- name: test shrink volume
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 10
shrink_ok: yes
register: vol
- name: verify results test create volume
assert:
that:
- vol is changed
- vol.size == 10 * 1024 ** 3
- vol.name == cs_resource_prefix + "_vol"

- name: test shrink volume idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
disk_offering: "{{ test_cs_disk_offering_1 }}"
size: 10
shrink_ok: yes
register: vol
- name: verify results test create volume
assert:
that:
- vol is not changed
- vol.size == 10 * 1024 ** 3
- vol.name == cs_resource_prefix + "_vol"

- name: test attach volume in check mode
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_1 }}"
state: attached
register: vol
check_mode: true
- name: verify results test attach volume in check mode
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.attached is not defined

- name: test attach volume
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_1 }}"
state: attached
register: vol
- name: verify results test attach volume
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.vm == "{{ test_cs_instance_1 }}"
- vol.attached is defined

- name: test attach volume idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_1 }}"
state: attached
register: vol
- name: verify results test attach volume idempotence
assert:
that:
- vol is not changed
- vol.name == cs_resource_prefix + "_vol"
- vol.vm == "{{ test_cs_instance_1 }}"
- vol.attached is defined

- name: test attach attached volume to another vm in check mdoe
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_2 }}"
state: attached
register: vol
check_mode: true
- name: verify results test attach attached volume to another vm in check mode
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.vm == "{{ test_cs_instance_1 }}"
- vol.attached is defined

- name: test attach attached volume to another vm
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_2 }}"
state: attached
register: vol
- name: verify results test attach attached volume to another vm
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.vm == "{{ test_cs_instance_2 }}"
- vol.attached is defined

- name: test attach attached volume to another vm idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
vm: "{{ test_cs_instance_2 }}"
state: attached
register: vol
- name: verify results test attach attached volume to another vm idempotence
assert:
that:
- vol is not changed
- vol.name == cs_resource_prefix + "_vol"
- vol.vm == "{{ test_cs_instance_2 }}"
- vol.attached is defined

- name: test detach volume in check mode
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: detached
register: vol
check_mode: true
- name: verify results test detach volume in check mdoe
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.attached is defined

- name: test detach volume
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: detached
register: vol
- name: verify results test detach volume
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"
- vol.attached is undefined

- name: test detach volume idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: detached
register: vol
- name: verify results test detach volume idempotence
assert:
that:
- vol is not changed
- vol.name == cs_resource_prefix + "_vol"
- vol.attached is undefined

- name: test delete volume in check mode
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: vol
check_mode: true
- name: verify results test create volume in check mode
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"

- name: test delete volume
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: vol
- name: verify results test create volume
assert:
that:
- vol is changed
- vol.name == cs_resource_prefix + "_vol"

- name: test delete volume idempotence
ngine_io.cloudstack.volume:
name: "{{ cs_resource_prefix }}_vol"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: vol
- name: verify results test delete volume idempotence
assert:
that:
- vol is not changed

- name: cleanup instance 1
ngine_io.cloudstack.instance:
name: "{{ test_cs_instance_1 }}"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: instance
- name: verify create instance
assert:
that:
- instance is successful

- name: cleanup instance 2
ngine_io.cloudstack.instance:
name: "{{ test_cs_instance_2 }}"
zone: "{{ cs_common_zone_basic }}"
state: absent
register: instance
- name: verify create instance
assert:
that:
- instance is successful
Loading

0 comments on commit 5413316

Please sign in to comment.