1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloudstack: cs_domain: tests: add update tests (#27791)

This commit is contained in:
René Moser 2017-08-05 10:33:01 +02:00 committed by GitHub
parent e1cfcdbbc6
commit f1ef61da4e
2 changed files with 108 additions and 34 deletions

View file

@ -40,13 +40,10 @@ options:
network_domain: network_domain:
description: description:
- Network domain for networks in the domain. - Network domain for networks in the domain.
required: false
default: null
clean_up: clean_up:
description: description:
- Clean up all domain resources like child domains and accounts. - Clean up all domain resources like child domains and accounts.
- Considered on C(state=absent). - Considered on C(state=absent).
required: false
default: false default: false
state: state:
description: description:
@ -57,29 +54,28 @@ options:
poll_async: poll_async:
description: description:
- Poll async jobs until job has finished. - Poll async jobs until job has finished.
required: false
default: true default: true
extends_documentation_fragment: cloudstack extends_documentation_fragment: cloudstack
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Create a domain - name: Create a domain
local_action: local_action:
module: cs_domain module: cs_domain
path: ROOT/customers path: ROOT/customers
network_domain: customers.example.com network_domain: customers.example.com
# Create another subdomain - name: Create another subdomain
local_action: local_action:
module: cs_domain module: cs_domain
path: ROOT/customers/xy path: ROOT/customers/xy
network_domain: xy.customers.example.com network_domain: xy.customers.example.com
# Remove a domain - name: Remove a domain
local_action: local_action:
module: cs_domain module: cs_domain
path: ROOT/customers/xy path: ROOT/customers/xy
state: absent state: absent
''' '''
RETURN = ''' RETURN = '''

View file

@ -1,6 +1,8 @@
--- ---
- name: setup - name: setup
cs_domain: path={{ cs_resource_prefix }}_domain state=absent cs_domain:
path: "{{ cs_resource_prefix }}_domain"
state: absent
register: dom register: dom
- name: verify setup - name: verify setup
assert: assert:
@ -18,7 +20,8 @@
- 'dom.msg == "missing required arguments: path"' - 'dom.msg == "missing required arguments: path"'
- name: test fail if ends with / - name: test fail if ends with /
cs_domain: path={{ cs_resource_prefix }}_domain/ cs_domain:
path: "{{ cs_resource_prefix }}_domain/"
register: dom register: dom
ignore_errors: true ignore_errors: true
- name: verify results of fail if ends with / - name: verify results of fail if ends with /
@ -28,7 +31,8 @@
- dom.msg == "Path '{{ cs_resource_prefix }}_domain/' must not end with /" - dom.msg == "Path '{{ cs_resource_prefix }}_domain/' must not end with /"
- name: test create a domain in check mode - name: test create a domain in check mode
cs_domain: path={{ cs_resource_prefix }}_domain cs_domain:
path: "{{ cs_resource_prefix }}_domain"
register: dom register: dom
check_mode: true check_mode: true
- name: verify results of test create a domain in check mode - name: verify results of test create a domain in check mode
@ -37,7 +41,8 @@
- dom|changed - dom|changed
- name: test create a domain - name: test create a domain
cs_domain: path={{ cs_resource_prefix }}_domain cs_domain:
path: "{{ cs_resource_prefix }}_domain"
register: dom register: dom
- name: verify results of test create a domain - name: verify results of test create a domain
assert: assert:
@ -47,7 +52,8 @@
- dom.name == "{{ cs_resource_prefix }}_domain" - dom.name == "{{ cs_resource_prefix }}_domain"
- name: test create a domain idempotence - name: test create a domain idempotence
cs_domain: path={{ cs_resource_prefix }}_domain cs_domain:
path: "{{ cs_resource_prefix }}_domain"
register: dom register: dom
- name: verify results of test create a domain idempotence - name: verify results of test create a domain idempotence
assert: assert:
@ -56,6 +62,17 @@
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain" - dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
- dom.name == "{{ cs_resource_prefix }}_domain" - dom.name == "{{ cs_resource_prefix }}_domain"
- name: test create a domain idempotence2
cs_domain:
path: "/{{ cs_resource_prefix }}_domain"
register: dom
- name: verify results of test create a domain idempotence2
assert:
that:
- not dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
- dom.name == "{{ cs_resource_prefix }}_domain"
- name: test fail to create a subdomain for inexistent domain - name: test fail to create a subdomain for inexistent domain
cs_domain: cs_domain:
path: ROOT/inexistent/{{ cs_resource_prefix }}_subdomain path: ROOT/inexistent/{{ cs_resource_prefix }}_subdomain
@ -68,7 +85,8 @@
- dom.msg == "Parent domain path ROOT/inexistent does not exist" - dom.msg == "Parent domain path ROOT/inexistent does not exist"
- name: test create a subdomain in check mode - name: test create a subdomain in check mode
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom register: dom
check_mode: true check_mode: true
- name: verify results of test create a domain in check mode - name: verify results of test create a domain in check mode
@ -77,7 +95,8 @@
- dom|changed - dom|changed
- name: test create a subdomain - name: test create a subdomain
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom register: dom
- name: verify results of test create a domain - name: verify results of test create a domain
assert: assert:
@ -87,15 +106,60 @@
- dom.name == "{{ cs_resource_prefix }}_subdomain" - dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test create a subdomain idempotence - name: test create a subdomain idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom register: dom
- name: verify results of test create a subdomain idempotence - name: verify results of test create a subdomain idempotence
assert: assert:
that: that:
- not dom|changed - not dom|changed
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test update a subdomain in check mode
cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
network_domain: domain.example.com
register: dom
check_mode: true
- name: verify results of test update a subdomain in check mode
assert:
that:
- dom|changed
- dom.network_domain is undefined
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test update a subdomain
cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
network_domain: domain.example.com
register: dom
- name: verify results of test update a subdomain
assert:
that:
- dom|changed
- dom.network_domain == "domain.example.com"
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test update a subdomain idempotence
cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
network_domain: domain.example.com
register: dom
- name: verify results of test update a subdomain idempotence
assert:
that:
- not dom|changed
- dom.network_domain == "domain.example.com"
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
- dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a subdomain in check mode - name: test delete a subdomain in check mode
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
state: absent
register: dom register: dom
check_mode: true check_mode: true
- name: verify results of test delete a subdomain in check mode - name: verify results of test delete a subdomain in check mode
@ -106,7 +170,9 @@
- dom.name == "{{ cs_resource_prefix }}_subdomain" - dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a subdomain - name: test delete a subdomain
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
state: absent
register: dom register: dom
- name: verify results of test delete a subdomain - name: verify results of test delete a subdomain
assert: assert:
@ -116,7 +182,9 @@
- dom.name == "{{ cs_resource_prefix }}_subdomain" - dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a subdomain idempotence - name: test delete a subdomain idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
state: absent
register: dom register: dom
- name: verify results of test delete a subdomain idempotence - name: verify results of test delete a subdomain idempotence
assert: assert:
@ -124,7 +192,8 @@
- not dom|changed - not dom|changed
- name: test create a subdomain 2 - name: test create a subdomain 2
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
register: dom register: dom
- name: verify results of test create a subdomain 2 - name: verify results of test create a subdomain 2
assert: assert:
@ -134,7 +203,10 @@
- dom.name == "{{ cs_resource_prefix }}_subdomain" - dom.name == "{{ cs_resource_prefix }}_subdomain"
- name: test delete a domain with clean up in check mode - name: test delete a domain with clean up in check mode
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain
state: absent
clean_up: true
register: dom register: dom
check_mode: true check_mode: true
- name: verify results of test delete a domain with clean up in check mode - name: verify results of test delete a domain with clean up in check mode
@ -145,7 +217,10 @@
- dom.name == "{{ cs_resource_prefix }}_domain" - dom.name == "{{ cs_resource_prefix }}_domain"
- name: test delete a domain with clean up - name: test delete a domain with clean up
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain
state: absent
clean_up: true
register: dom register: dom
- name: verify results of test delete a domain with clean up - name: verify results of test delete a domain with clean up
assert: assert:
@ -155,7 +230,10 @@
- dom.name == "{{ cs_resource_prefix }}_domain" - dom.name == "{{ cs_resource_prefix }}_domain"
- name: test delete a domain with clean up idempotence - name: test delete a domain with clean up idempotence
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true cs_domain:
path: ROOT/{{ cs_resource_prefix }}_domain
state: absent
clean_up: true
register: dom register: dom
- name: verify results of test delete a domain with clean up idempotence - name: verify results of test delete a domain with clean up idempotence
assert: assert: