1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloudstack: add more integration tests

This commit is contained in:
Rene Moser 2015-08-23 22:48:32 +02:00
parent 3ccfebc9f7
commit 15a7f818e1
10 changed files with 404 additions and 1 deletions

View file

@ -5,8 +5,12 @@
tags:
- cloudstack
vars:
cs_resource_prefix: "cs{{ resource_prefix | default('') }}"
cs_resource_prefix: "{{ resource_prefix | default('cs-') }}"
roles:
- { role: test_cs_project, tags: test_cs_project }
- { role: test_cs_iso, tags: test_cs_iso }
- { role: test_cs_domain, tags: test_cs_domain }
- { role: test_cs_vmsnapshot, tags: test_cs_vmsnapshot }
- { role: test_cs_sshkeypair, tags: test_cs_sshkeypair }
- { role: test_cs_affinitygroup, tags: test_cs_affinitygroup }
- { role: test_cs_securitygroup, tags: test_cs_securitygroup }

View file

@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common

View file

@ -0,0 +1,112 @@
---
- name: setup
cs_domain: path={{ cs_resource_prefix }}_domain state=absent
register: dom
- name: verify setup
assert:
that:
- dom|success
- name: test fail if missing name
action: cs_domain
register: dom
ignore_errors: true
- name: verify results of fail if missing params
assert:
that:
- dom|failed
- 'dom.msg == "missing required arguments: path"'
- name: test fail if ends with /
cs_domain: path={{ cs_resource_prefix }}_domain/
register: dom
ignore_errors: true
- name: verify results of fail if ends with /
assert:
that:
- dom|failed
- dom.msg == "Path '{{ cs_resource_prefix }}_domain/' must not end with /"
- name: test create a domain
cs_domain: path={{ cs_resource_prefix }}_domain
register: dom
- name: verify results of test create a domain
assert:
that:
- dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
- dom.name == "{{ cs_resource_prefix }}_domain"
- name: test create a domain idempotence
cs_domain: path={{ cs_resource_prefix }}_domain
register: dom
- name: verify results of test create a domain idempotence
assert:
that:
- not dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
- dom.name == "{{ cs_resource_prefix }}_domain"
- name: test create a subdomain
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom
- name: verify results of test create a domain
assert:
that:
- dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test create a subdomain idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom
- name: verify results of test create a subdomain idempotence
assert:
that:
- not dom|changed
- name: test delete a subdomain
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent
register: dom
- name: verify results of test delete a subdomain idempotence
assert:
that:
- dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a subdomain idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent
register: dom
- name: verify results of test delete a subdomain idempotence
assert:
that:
- not dom|changed
- name: test create a subdomain 2
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom
- name: verify results of test create a subdomain 2
assert:
that:
- dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a domain with clean up
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true
register: dom
- name: verify results of test delete a domain with clean up
assert:
that:
- dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
- dom.name == "{{ cs_resource_prefix }}_domain"
- name: test delete a domain with clean up idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true
register: dom
- name: verify results of test delete a domain with clean up idempotence
assert:
that:
- not dom|changed

View file

@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common

View file

@ -0,0 +1,71 @@
---
- name: ensure iso is deleted
cs_iso:
name: "{{ cs_resource_prefix }}-iso"
state: absent
register: iso
- name: verify ensure iso is deleted
assert:
that:
- iso|success
- name: test download iso
cs_iso:
name: "{{ cs_resource_prefix }}-iso"
url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
os_type: Debian GNU/Linux 7(64-bit)
register: iso
- name: verify test download iso
assert:
that:
- iso|changed
- iso.name == "{{ cs_resource_prefix }}-iso"
- name: test download iso idempotence
cs_iso:
name: "{{ cs_resource_prefix }}-iso"
url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
os_type: Debian GNU/Linux 7(64-bit)
register: iso
- name: verify test download iso idempotence
assert:
that:
- not iso|changed
- iso.name == "{{ cs_resource_prefix }}-iso"
# TODO: on 4.6 simulator no checksum was returned
# TODO: check if this is a bug in 4.6
#- name: test download iso idempotence by checksum
# cs_iso:
# name: "{{ cs_resource_prefix }}-iso2"
# checksum: "{{ iso.checksum }}"
# url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
# os_type: Debian GNU/Linux 7(64-bit)
# register: iso2
#- name: verify test download iso idempotence by checksum
# assert:
# that:
# - not iso2|changed
# - iso2.name == "{{ cs_resource_prefix }}-iso"
# - iso2.checksum == iso.checksum
- name: test remove iso
cs_iso:
name: "{{ cs_resource_prefix }}-iso"
state: absent
register: iso
- name: verify test remove iso
assert:
that:
- iso|changed
- iso.name == "{{ cs_resource_prefix }}-iso"
- name: test remove iso idempotence
cs_iso:
name: "{{ cs_resource_prefix }}-iso"
state: absent
register: iso
- name: verify test remove iso idempotence
assert:
that:
- not iso|changed

View file

@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common

View file

@ -0,0 +1,100 @@
---
- name: ensure project does not exist
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: absent
register: prj
- name: verify project did not exist
assert:
that:
- prj|success
- name: test create project
cs_project:
name: "{{ cs_resource_prefix }}-prj"
register: prj
- name: verify test create project
assert:
that:
- prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- name: test create project idempotence
cs_project:
name: "{{ cs_resource_prefix }}-prj"
register: prj
- name: verify test create project idempotence
assert:
that:
- not prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- name: test suspend project
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: suspended
register: prj
- name: verify test suspend project
assert:
that:
- prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- prj.state == "Suspended"
- name: test suspend project idempotence
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: suspended
register: prj
- name: verify test suspend project idempotence
assert:
that:
- not prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- prj.state == "Suspended"
- name: test activate project
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: active
register: prj
- name: verify test activate project
assert:
that:
- prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- prj.state == "Active"
- name: test activate project idempotence
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: active
register: prj
- name: verify test activate project idempotence
assert:
that:
- not prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- prj.state == "Active"
- name: test delete project
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: absent
register: prj
- name: verify test delete project
assert:
that:
- prj|changed
- prj.name == "{{ cs_resource_prefix }}-prj"
- prj.state == "Active"
- name: test delete project idempotence
cs_project:
name: "{{ cs_resource_prefix }}-prj"
state: absent
register: prj
- name: verify test delete project idempotence
assert:
that:
- not prj|changed

View file

@ -0,0 +1,3 @@
---
test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator)
test_cs_instance_offering_1: Small Instance

View file

@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common

View file

@ -0,0 +1,101 @@
---
- name: setup instance
cs_instance:
name: "{{ cs_resource_prefix }}-vm-snapshot"
template: "{{ test_cs_instance_template }}"
service_offering: "{{ test_cs_instance_offering_1 }}"
register: instance
- name: verify create instance
assert:
that:
- instance|success
- name: ensure no snapshot exists
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
state: absent
register: snap
- name: verify setup
assert:
that:
- snap|success
- name: test fail if missing name
action: cs_vmsnapshot
register: snap
ignore_errors: true
- name: verify results of fail if missing params
assert:
that:
- snap|failed
- 'snap.msg == "missing required arguments: vm,name"'
- name: test create snapshot
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
snapshot_memory: yes
register: snap
- name: verify test create snapshot
assert:
that:
- snap|changed
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
- name: test create snapshot idempotence
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
snapshot_memory: yes
register: snap
- name: verify test create snapshot idempotence
assert:
that:
- not snap|changed
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
- name: test revert snapshot
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
state: revert
register: snap
- name: verify test revert snapshot
assert:
that:
- snap|changed
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
- name: test remove snapshot
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
state: absent
register: snap
- name: verify test remove snapshot
assert:
that:
- snap|changed
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
- name: test remove snapshot idempotence
cs_vmsnapshot:
name: "{{ cs_resource_prefix }}_snapshot"
vm: "{{ cs_resource_prefix }}-vm-snapshot"
state: absent
register: snap
- name: verify test remove snapshot idempotence
assert:
that:
- not snap|changed
- name: cleanup instance
cs_instance:
name: "{{ cs_resource_prefix }}-vm-snapshot"
state: expunged
register: instance
- name: verify destroy instance
assert:
that:
- instance|success