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.
cloudstack: cs_host: add integration tests
- Loading branch information
Showing
3 changed files
with
301 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,2 @@ | ||
cloud/cs | ||
posix/ci/cloud/cs |
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,296 @@ | ||
--- | ||
- name: test fail missing params | ||
cs_host: | ||
register: host | ||
ignore_errors: true | ||
- name: verify test fail missing url if host is not existent | ||
assert: | ||
that: | ||
- host|failed | ||
- 'host.msg == "missing required arguments: name"' | ||
|
||
- name: test fail missing params if host is not existent | ||
cs_host: | ||
name: sim | ||
register: host | ||
ignore_errors: true | ||
- name: verify test fail missing params if host is not existent | ||
assert: | ||
that: | ||
- host|failed | ||
- 'host.msg == "missing required arguments: password,username,hypervisor,pod"' | ||
|
||
- name: test create a host in check mode | ||
cs_host: | ||
name: sim | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: root | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
register: host | ||
check_mode: true | ||
- name: verify test create a host in check mode | ||
assert: | ||
that: | ||
- host|changed | ||
|
||
- name: test create a host | ||
cs_host: | ||
name: sim | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: root | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
register: host | ||
- name: verify test create a host | ||
assert: | ||
that: | ||
- host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- "host.name.startswith('SimulatedAgent.')" | ||
- host.host_tags == ['perf', 'gpu'] | ||
|
||
# This is special in simulator mode, we can not predict the full hostname. | ||
# That is why we gather the infos from the returns and use a fact. | ||
- name: assume the sim would resolve to the IP address | ||
set_fact: | ||
host_hostname: "{{ host.name }}" | ||
host_ip_address: "{{ host.ip_address }}" | ||
|
||
- name: test create a host idempotence | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
register: host | ||
- name: verify test create a host idempotence | ||
assert: | ||
that: | ||
- not host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu'] | ||
|
||
- name: test update host in check mode | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
- x2 | ||
register: host | ||
check_mode: true | ||
- name: verify test update a host in check mode | ||
assert: | ||
that: | ||
- host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu'] | ||
|
||
- name: test update host | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
- x2 | ||
register: host | ||
- name: verify test update a host in check mode | ||
assert: | ||
that: | ||
- host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu', 'x2'] | ||
|
||
- name: test update host idempotence | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: | ||
- perf | ||
- gpu | ||
- x2 | ||
register: host | ||
- name: verify test update a host idempotence | ||
assert: | ||
that: | ||
- not host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu', 'x2'] | ||
|
||
# FIXME: Removing by empty list seems to be an issue in the used lib cs underneath, disabled | ||
- name: test update host remove host_tags | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: [] | ||
register: host | ||
when: false | ||
- name: verify test update host remove host_tags | ||
assert: | ||
that: | ||
- host|changed | ||
- host.host_tags|length == 0 | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
when: false | ||
|
||
# FIXME: Removing by empty list seems to be an issue in the used lib cs underneath, disabled | ||
- name: test update host remove host_tags idempotence | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
url: "http://sim/c0-basic/h2" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
username: admin | ||
password: password | ||
hypervisor: Simulator | ||
allocation_state: enabled | ||
host_tags: [] | ||
register: host | ||
when: false | ||
- name: verify test update host remove host_tags idempotence | ||
assert: | ||
that: | ||
- not host|changed | ||
- len(host.host_tags) == 0 | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
when: false | ||
|
||
- name: test remove host in check mode | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
state: absent | ||
check_mode: true | ||
register: host | ||
- name: verify test remove a host in check mode | ||
assert: | ||
that: | ||
- host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu', 'x2'] | ||
|
||
- name: test remove host | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
state: absent | ||
register: host | ||
- name: verify test remove a host | ||
assert: | ||
that: | ||
- host|changed | ||
- host.cluster == 'C0-basic' | ||
- host.pod == 'POD0-basic' | ||
- host.hypervisor == 'Simulator' | ||
- host.allocation_state == 'enabled' | ||
- host.zone == 'Sandbox-simulator-basic' | ||
- host.state == 'Up' | ||
- host.name == '{{ host_hostname }}' | ||
- host.host_tags == ['perf', 'gpu', 'x2'] | ||
|
||
- name: test remove host idempotence | ||
cs_host: | ||
name: "{{ host_hostname }}" | ||
cluster: C0-basic | ||
pod: POD0-basic | ||
state: absent | ||
register: host | ||
- name: verify test remove a host idempotenc | ||
assert: | ||
that: | ||
- not host|changed |