Merge pull request #12058 from resmo/for-ansible

cloudstack: more integration tests and updates
This commit is contained in:
Brian Coca 2015-08-24 10:03:58 -04:00
commit 6da2587c36
14 changed files with 434 additions and 33 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

@ -46,7 +46,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "enabled"
- acc.state == "enabled"
- acc.domain == "ROOT"
- name: test create user account idempotence
@ -67,7 +67,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "enabled"
- acc.state == "enabled"
- acc.domain == "ROOT"
- name: test lock user account
@ -83,7 +83,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "locked"
- acc.state == "locked"
- acc.domain == "ROOT"
- name: test lock user account idempotence
@ -99,7 +99,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "locked"
- acc.state == "locked"
- acc.domain == "ROOT"
- name: test disable user account
@ -115,7 +115,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "disabled"
- acc.state == "disabled"
- acc.domain == "ROOT"
- name: test disable user account idempotence
@ -131,7 +131,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "disabled"
- acc.state == "disabled"
- acc.domain == "ROOT"
- name: test lock disabled user account
@ -147,7 +147,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "locked"
- acc.state == "locked"
- acc.domain == "ROOT"
- name: test lock disabled user account idempotence
@ -163,7 +163,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "locked"
- acc.state == "locked"
- acc.domain == "ROOT"
- name: test enable user account
@ -179,7 +179,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "enabled"
- acc.state == "enabled"
- acc.domain == "ROOT"
- name: test enable user account idempotence
@ -195,7 +195,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "enabled"
- acc.state == "enabled"
- acc.domain == "ROOT"
- name: test remove user account
@ -211,7 +211,7 @@
- acc.name == "{{ cs_resource_prefix }}_user"
- acc.network_domain == "{{ cs_resource_prefix }}.local"
- acc.account_type == "user"
- acc.account_state == "enabled"
- acc.state == "enabled"
- acc.domain == "ROOT"
- name: test remove user account idempotence

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

@ -1,2 +1,5 @@
---
instance_number: 1
test_cs_instance_template: CentOS 5.3(64-bit) no GUI (Simulator)
test_cs_instance_offering_1: Small Instance
test_cs_instance_offering_2: Medium Instance

View file

@ -1,11 +1,6 @@
---
- include: setup.yml
tags: any
- include: present.yml
tags: test_cs_instance_present
#- include: tags.yml
# tags: test_cs_instance_tags
- include: absent.yml
tags: test_cs_instance_absent
- include: cleanup.yml
tags: test_cs_instance_cleanup

View file

@ -2,8 +2,8 @@
- name: test create instance
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
template: Linux Debian 7 64-bit
service_offering: Tiny
template: "{{ test_cs_instance_template }}"
service_offering: "{{ test_cs_instance_offering_1 }}"
affinity_group: "{{ cs_resource_prefix }}-ag"
security_group: "{{ cs_resource_prefix }}-sg"
ssh_key: "{{ cs_resource_prefix }}-sshkey"
@ -16,7 +16,7 @@
- instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Running"
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey"
- not instance.tags
@ -25,8 +25,8 @@
- name: test create instance idempotence
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
template: Linux Debian 7 64-bit
service_offering: Tiny
template: "{{ test_cs_instance_template }}"
service_offering: "{{ test_cs_instance_offering_1 }}"
affinity_group: "{{ cs_resource_prefix }}-ag"
security_group: "{{ cs_resource_prefix }}-sg"
ssh_key: "{{ cs_resource_prefix }}-sshkey"
@ -39,7 +39,7 @@
- not instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Running"
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey"
- not instance.tags
@ -48,7 +48,7 @@
- name: test running instance not updated
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
service_offering: Micro
service_offering: "{{ test_cs_instance_offering_2 }}"
register: instance
- name: verify running instance not updated
assert:
@ -57,7 +57,7 @@
- not instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Running"
@ -73,7 +73,7 @@
- instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Stopped"
@ -94,7 +94,7 @@
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
display_name: "{{ cs_resource_prefix }}-display-{{ instance_number }}"
service_offering: Micro
service_offering: "{{ test_cs_instance_offering_2 }}"
register: instance
- name: verify updating stopped instance
assert:
@ -103,7 +103,7 @@
- instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
- instance.service_offering == "Micro"
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
- instance.state == "Stopped"
@ -119,7 +119,7 @@
- instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
- instance.service_offering == "Micro"
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
- instance.state == "Running"
@ -138,7 +138,7 @@
- name: test force update running instance
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
service_offering: Tiny
service_offering: "{{ test_cs_instance_offering_1 }}"
force: true
register: instance
- name: verify force update running instance
@ -148,13 +148,13 @@
- instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Running"
- name: test force update running instance idempotence
cs_instance:
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
service_offering: Tiny
service_offering: "{{ test_cs_instance_offering_1 }}"
force: true
register: instance
- name: verify force update running instance idempotence
@ -164,5 +164,5 @@
- not instance|changed
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
- instance.service_offering == "Tiny"
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
- instance.state == "Running"

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