Skip to content

Commit

Permalink
cloudstack: add more integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Aug 23, 2015
1 parent 3ccfebc commit 15a7f81
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/integration/cloudstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 3 additions & 0 deletions test/integration/roles/test_cs_domain/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common
112 changes: 112 additions & 0 deletions test/integration/roles/test_cs_domain/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/roles/test_cs_iso/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common
71 changes: 71 additions & 0 deletions test/integration/roles/test_cs_iso/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/roles/test_cs_project/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common
100 changes: 100 additions & 0 deletions test/integration/roles/test_cs_project/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/roles/test_cs_vmsnapshot/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator)
test_cs_instance_offering_1: Small Instance
3 changes: 3 additions & 0 deletions test/integration/roles/test_cs_vmsnapshot/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common
Loading

0 comments on commit 15a7f81

Please sign in to comment.