-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
14 changed files
with
1,767 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cloud/cs | ||
cs/group1 | ||
cs/group3 |
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,5 @@ | ||
--- | ||
instance_number: 1 | ||
test_cs_instance_template: "{{ cs_common_template }}" | ||
test_cs_instance_offering_1: Small Instance | ||
test_cs_instance_offering_2: Medium Instance |
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: | ||
- 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,115 @@ | ||
--- | ||
- name: test destroy instance in check mode | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: absent | ||
register: instance | ||
check_mode: true | ||
- name: verify destroy instance in check mode | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state != "Destroyed" | ||
|
||
- name: test destroy instance | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Destroyed" | ||
|
||
- name: test destroy instance idempotence | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance idempotence | ||
assert: | ||
that: | ||
- instance is not changed | ||
|
||
- name: test recover to stopped state and update a deleted instance in check mode | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
service_offering: "{{ test_cs_instance_offering_1 }}" | ||
state: stopped | ||
register: instance | ||
check_mode: true | ||
- name: verify test recover to stopped state and update a deleted instance in check mode | ||
assert: | ||
that: | ||
- instance is changed | ||
|
||
- name: test recover to stopped state and update a deleted instance | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
service_offering: "{{ test_cs_instance_offering_1 }}" | ||
state: stopped | ||
register: instance | ||
- name: verify test recover to stopped state and update a deleted instance | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Stopped" | ||
- instance.service_offering == test_cs_instance_offering_1 | ||
|
||
- name: test recover to stopped state and update a deleted instance idempotence | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
service_offering: "{{ test_cs_instance_offering_1 }}" | ||
state: stopped | ||
register: instance | ||
- name: verify test recover to stopped state and update a deleted instance idempotence | ||
assert: | ||
that: | ||
- instance is not changed | ||
- instance.state == "Stopped" | ||
- instance.service_offering == test_cs_instance_offering_1 | ||
|
||
- name: test expunge instance in check mode | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: expunged | ||
register: instance | ||
check_mode: true | ||
- name: verify test expunge instance in check mode | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Stopped" | ||
- instance.service_offering == test_cs_instance_offering_1 | ||
|
||
- name: test expunge instance | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: expunged | ||
register: instance | ||
- name: verify test expunge instance | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Stopped" | ||
- instance.service_offering == test_cs_instance_offering_1 | ||
|
||
- name: test expunge instance idempotence | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: expunged | ||
register: instance | ||
- name: verify test expunge instance idempotence | ||
assert: | ||
that: | ||
- instance is not changed |
44 changes: 44 additions & 0 deletions
44
tests/integration/targets/instance/tasks/absent_display_name.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,44 @@ | ||
--- | ||
- name: test destroy instance with display_name | ||
ngine_io.cloudstack.instance: | ||
display_name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance with display_name | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Destroyed" | ||
|
||
- name: test destroy instance with display_name idempotence | ||
ngine_io.cloudstack.instance: | ||
display_name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: absent | ||
register: instance | ||
- name: verify destroy instance with display_name idempotence | ||
assert: | ||
that: | ||
- instance is not changed | ||
|
||
- name: test recover to stopped state and update a deleted instance with display_name | ||
ngine_io.cloudstack.instance: | ||
display_name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
service_offering: "{{ test_cs_instance_offering_1 }}" | ||
state: stopped | ||
register: instance | ||
- name: verify test recover to stopped state and update a deleted instance with display_name | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.state == "Stopped" | ||
- instance.service_offering == test_cs_instance_offering_1 | ||
|
||
# force expunge, only works with admin permissions | ||
- ngine_io.cloudstack.instance: | ||
display_name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
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,36 @@ | ||
--- | ||
- name: cleanup ssh key | ||
ngine_io.cloudstack.ssh_key: | ||
name: "{{ cs_resource_prefix }}-sshkey" | ||
state: absent | ||
register: sshkey | ||
- name: verify cleanup ssh key | ||
assert: | ||
that: | ||
- sshkey is successful | ||
|
||
- name: cleanup affinity group | ||
ngine_io.cloudstack.affinity_group: | ||
name: "{{ cs_resource_prefix }}-ag" | ||
state: absent | ||
register: ag | ||
until: ag is successful | ||
retries: 20 | ||
delay: 5 | ||
- name: verify cleanup affinity group | ||
assert: | ||
that: | ||
- ag is successful | ||
|
||
- name: cleanup security group ...take a while unless instance is expunged | ||
ngine_io.cloudstack.security_group: | ||
name: "{{ cs_resource_prefix }}-sg" | ||
state: absent | ||
register: sg | ||
until: sg is successful | ||
retries: 100 | ||
delay: 10 | ||
- name: verify cleanup security group | ||
assert: | ||
that: | ||
- sg is successful |
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,137 @@ | ||
--- | ||
- name: setup ensure running instance to get host infos | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
template: "{{ test_cs_instance_template }}" | ||
service_offering: "{{ test_cs_instance_offering_1 }}" | ||
state: started | ||
register: running_instance | ||
|
||
- name: setup ensure stopped instance | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
state: stopped | ||
|
||
- name: setup zone facts | ||
ngine_io.cloudstack.zone_info: | ||
name: "{{ cs_common_zone_basic }}" | ||
register: zone_info | ||
|
||
- name: setup find the host name | ||
shell: cs listHosts type=routing zoneid="{{ zone_info.zones[0].id }}" | ||
args: | ||
chdir: "{{ playbook_dir }}" | ||
register: host | ||
|
||
- name: host convert from json | ||
set_fact: | ||
host_json: "{{ host.stdout | from_json }}" | ||
|
||
- name: select a host on which the instance was not running on | ||
set_fact: | ||
host: "{{ host_json | json_query('host[?name!=`' + running_instance.host + '`] | [0]') }}" | ||
|
||
- debug: | ||
msg: "from current host {{ running_instance.host }} to new host {{ host.name }}" | ||
|
||
- name: test starting instance on new host in check mode | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
state: started | ||
register: instance | ||
check_mode: true | ||
- name: verify test starting instance on new host in check mode | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.name == cs_resource_prefix + "-vm-" + instance_number | ||
- instance.host is not defined | ||
- instance.state == "Stopped" | ||
|
||
- name: test starting instance on new host | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
state: started | ||
register: instance | ||
- name: verify test starting instance on new host | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.name == cs_resource_prefix + "-vm-" + instance_number | ||
- instance.host == host.name | ||
- instance.state == "Running" | ||
|
||
- name: test starting instance on new host idempotence | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
state: started | ||
register: instance | ||
- name: verify test starting instance on new host idempotence | ||
assert: | ||
that: | ||
- instance is not changed | ||
- instance.name == cs_resource_prefix + "-vm-" + instance_number | ||
- instance.host == host.name | ||
- instance.state == "Running" | ||
|
||
- name: select a host on which the instance is not running on | ||
set_fact: | ||
host: "{{ host_json | json_query('host[?name!=`' + instance.host + '`] | [0]') }}" | ||
|
||
- debug: | ||
msg: "from current host {{ instance.host }} to new host {{ host.name }}" | ||
|
||
- name: test force update running instance in check mode | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
force: true | ||
register: instance | ||
check_mode: true | ||
- name: verify force update running instance in check mode | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.name == cs_resource_prefix + "-vm-" + instance_number | ||
- instance.host != host.name | ||
- instance.state == "Running" | ||
|
||
- name: test force update running instance | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
force: true | ||
register: instance | ||
- name: verify force update running instance | ||
assert: | ||
that: | ||
- instance is changed | ||
- instance.name cs_resource_prefix + "-vm-" + instance_number | ||
- instance.host == host.name | ||
- instance.state == "Running" | ||
|
||
- name: test force update running instance idempotence | ||
ngine_io.cloudstack.instance: | ||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}" | ||
zone: "{{ cs_common_zone_basic }}" | ||
host: "{{ host.name }}" | ||
force: true | ||
register: instance | ||
- name: verify force update running instance idempotence | ||
assert: | ||
that: | ||
- instance is not changed | ||
- instance.name == cs_resource_prefix + "-vm-" + instance_number | ||
- instance.display_name == cs_resource_prefix + "-display-" + instance_number | ||
- instance.host == host.name | ||
- 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,18 @@ | ||
--- | ||
- import_tasks: setup.yml | ||
|
||
- import_tasks: present.yml | ||
- import_tasks: tags.yml | ||
- import_tasks: absent.yml | ||
|
||
- import_tasks: present_display_name.yml | ||
- import_tasks: absent_display_name.yml | ||
|
||
# TODO: These tests randomly fail in all kinds of unexpected states. | ||
# This needs to be verified by the cloudstack community. | ||
# - import_tasks: host.yml | ||
|
||
- import_tasks: sshkeys.yml | ||
- import_tasks: project.yml | ||
|
||
- import_tasks: cleanup.yml |
Oops, something went wrong.