forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
945 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
gather_facts: no | ||
tags: | ||
- cloudstack | ||
roles: | ||
- { role: test_cs_sshkeypair, tags: test_cs_sshkeypair } | ||
- { role: test_cs_affinitygroup, tags: test_cs_affinitygroup } | ||
- { role: test_cs_securitygroup, tags: test_cs_securitygroup } | ||
- { role: test_cs_securitygroup_rule, tags: test_cs_securitygroup_rule } | ||
- { role: test_cs_instance, tags: test_cs_instance } | ||
- { role: test_cs_instancegroup, tags: test_cs_instancegroup } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- test_cs_common |
58 changes: 58 additions & 0 deletions
58
test/integration/roles/test_cs_affinitygroup/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
- name: setup | ||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag state=absent | ||
register: ag | ||
- name: verify setup | ||
assert: | ||
that: | ||
- ag|success | ||
|
||
- name: test fail if missing name | ||
action: cs_affinitygroup | ||
register: ag | ||
ignore_errors: true | ||
- name: verify results of fail if missing name | ||
assert: | ||
that: | ||
- ag|failed | ||
- ag.msg == "missing required arguments: name" | ||
|
||
- name: test present affinity group | ||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag | ||
register: ag | ||
- name: verify results of create affinity group | ||
assert: | ||
that: | ||
- ag|success | ||
- ag|changed | ||
- ag.name == "{{ cs_resource_prefix }}_ag" | ||
|
||
- name: test present affinity group is idempotence | ||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag | ||
register: ag | ||
- name: verify results present affinity group is idempotence | ||
assert: | ||
that: | ||
- ag|success | ||
- not ag|changed | ||
- ag.name == "{{ cs_resource_prefix }}_ag" | ||
|
||
- name: test absent affinity group | ||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag state=absent | ||
register: ag | ||
- name: verify results of absent affinity group | ||
assert: | ||
that: | ||
- ag|success | ||
- ag|changed | ||
- ag.name == "{{ cs_resource_prefix }}_ag" | ||
|
||
- name: test absent affinity group is idempotence | ||
cs_affinitygroup: name={{ cs_resource_prefix }}_ag state=absent | ||
register: ag | ||
- name: verify results of absent affinity group is idempotence | ||
assert: | ||
that: | ||
- ag|success | ||
- not ag|changed | ||
- ag.name is undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
cs_resource_prefix: cloudstack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
instance_number: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- test_cs_common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: test destroy instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.state == "Destroyed" | ||
|
||
- name: test destroy instance idempotence | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance idempotence | ||
assert: | ||
that: | ||
- instance|success | ||
- not instance|changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- name: cleanup ssh key | ||
cs_sshkeypair: name={{ cs_resource_prefix }}-sshkey state=absent | ||
register: sshkey | ||
- name: verify cleanup ssh key | ||
assert: | ||
that: | ||
- sshkey|success | ||
|
||
- name: cleanup affinity group | ||
cs_affinitygroup: name={{ cs_resource_prefix }}-ag state=absent | ||
register: ag | ||
until: ag|success | ||
retries: 20 | ||
delay: 5 | ||
- name: verify cleanup affinity group | ||
assert: | ||
that: | ||
- ag|success | ||
|
||
- name: cleanup security group ...take a while unless instance is expunged | ||
cs_securitygroup: name={{ cs_resource_prefix }}-sg state=absent | ||
register: sg | ||
until: sg|success | ||
retries: 100 | ||
delay: 10 | ||
- name: verify cleanup security group | ||
assert: | ||
that: | ||
- sg|success | ||
|
||
# force expunge, only works with admin permissions | ||
- cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: expunged | ||
failed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- 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 |
168 changes: 168 additions & 0 deletions
168
test/integration/roles/test_cs_instance/tasks/present.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
--- | ||
- name: test create instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
template: Linux Debian 7 64-bit | ||
service_offering: Tiny | ||
affinity_group: "{{ cs_resource_prefix }}-ag" | ||
security_group: "{{ cs_resource_prefix }}-sg" | ||
ssh_key: "{{ cs_resource_prefix }}-sshkey" | ||
tags: [] | ||
register: instance | ||
- name: verify create instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.service_offering == "Tiny" | ||
- instance.state == "Running" | ||
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey" | ||
- not instance.tags | ||
|
||
|
||
- name: test create instance idempotence | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
template: Linux Debian 7 64-bit | ||
service_offering: Tiny | ||
affinity_group: "{{ cs_resource_prefix }}-ag" | ||
security_group: "{{ cs_resource_prefix }}-sg" | ||
ssh_key: "{{ cs_resource_prefix }}-sshkey" | ||
tags: [] | ||
register: instance | ||
- name: verify create instance idempotence | ||
assert: | ||
that: | ||
- instance|success | ||
- 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.state == "Running" | ||
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey" | ||
- not instance.tags | ||
|
||
|
||
- name: test running instance not updated | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
service_offering: Micro | ||
register: instance | ||
- name: verify running instance not updated | ||
assert: | ||
that: | ||
- instance|success | ||
- 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.state == "Running" | ||
|
||
|
||
- name: test stopping instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: stopped | ||
register: instance | ||
- name: verify stopping instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.service_offering == "Tiny" | ||
- instance.state == "Stopped" | ||
|
||
|
||
- name: test stopping instance idempotence | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: stopped | ||
register: instance | ||
- name: verify stopping instance idempotence | ||
assert: | ||
that: | ||
- instance|success | ||
- not instance|changed | ||
- instance.state == "Stopped" | ||
|
||
|
||
- name: test updating stopped instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
display_name: "{{ cs_resource_prefix }}-display-{{ instance_number }}" | ||
service_offering: Micro | ||
register: instance | ||
- name: verify updating stopped instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}" | ||
- instance.service_offering == "Micro" | ||
- instance.state == "Stopped" | ||
|
||
|
||
- name: test starting instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: started | ||
register: instance | ||
- name: verify starting instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}" | ||
- instance.service_offering == "Micro" | ||
- instance.state == "Running" | ||
|
||
|
||
- name: test starting instance idempotence | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
state: started | ||
register: instance | ||
- name: verify starting instance idempotence | ||
assert: | ||
that: | ||
- instance|success | ||
- not instance|changed | ||
- instance.state == "Running" | ||
|
||
- name: test force update running instance | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
service_offering: Tiny | ||
force: true | ||
register: instance | ||
- name: verify force update running instance | ||
assert: | ||
that: | ||
- instance|success | ||
- instance|changed | ||
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
- instance.service_offering == "Tiny" | ||
- instance.state == "Running" | ||
|
||
- name: test force update running instance idempotence | ||
cs_instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
service_offering: Tiny | ||
force: true | ||
register: instance | ||
- name: verify force update running instance idempotence | ||
assert: | ||
that: | ||
- instance|success | ||
- 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.state == "Running" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- name: setup ssh key | ||
cs_sshkeypair: name={{ cs_resource_prefix }}-sshkey | ||
register: sshkey | ||
- name: verify setup ssh key | ||
assert: | ||
that: | ||
- sshkey|success | ||
|
||
- name: setup affinity group | ||
cs_affinitygroup: name={{ cs_resource_prefix }}-ag | ||
register: ag | ||
- name: verify setup affinity group | ||
assert: | ||
that: | ||
- ag|success | ||
|
||
- name: setup security group | ||
cs_securitygroup: name={{ cs_resource_prefix }}-sg | ||
register: sg | ||
- name: verify setup security group | ||
assert: | ||
that: | ||
- sg|success | ||
|
||
- name: setup instance to be absent | ||
cs_instance: name={{ cs_resource_prefix }}-vm-{{ instance_number }} state=absent | ||
register: instance | ||
- name: verify instance to be absent | ||
assert: | ||
that: | ||
- instance|success |
Oops, something went wrong.