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

Add test_rax_meta role

This commit is contained in:
Matt Martz 2015-01-16 14:11:50 -06:00
parent 9878ebf0ee
commit abac45dafc
4 changed files with 341 additions and 4 deletions

View file

@ -115,10 +115,7 @@ gce: $(CREDENTIALS_FILE)
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make gce_cleanup ; \
exit $$RC;
rackspace_prepare:
ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) -t prepare
rackspace: rackspace_prepare $(CREDENTIALS_FILE)
rackspace: $(CREDENTIALS_FILE)
ansible-playbook rackspace.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
RC=$$? ; \
CLOUD_RESOURCE_PREFIX="$(CLOUD_RESOURCE_PREFIX)" make rackspace_cleanup ; \

View file

@ -16,6 +16,9 @@
- role: test_rax_facts
tags: test_rax_facts
- role: test_rax_meta
tags: test_rax_meta
- role: test_rax_clb
tags: test_rax_clb

View file

@ -0,0 +1,3 @@
dependencies:
- prepare_tests
- prepare_rax_tests

View file

@ -0,0 +1,334 @@
# ============================================================
- name: Test rax_meta with no args
rax_meta:
ignore_errors: true
register: rax_meta
- name: Validate results of rax_meta with no args
assert:
that:
- rax_meta|failed
- rax_meta.msg == 'one of the following is required: address,id,name'
# ============================================================
# ============================================================
- name: Test rax_meta with credentials and address
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
address: '1.2.3.4'
ignore_errors: true
register: rax_meta
- name: Validate results of rax_meta with only creds
assert:
that:
- rax_meta|failed
- rax_meta.msg.startswith('None is not a valid region')
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region and address
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
address: '1.2.3.4'
ignore_errors: true
register: rax_meta
- name: Validate rax_meta creds, region and address
assert:
that:
- rax_meta|failed
- rax_meta.msg == 'Failed to find a server matching provided search parameters'
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region and id
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: '1234'
ignore_errors: true
register: rax_meta
- name: Validate rax_meta creds, region and id
assert:
that:
- rax_meta|failed
- rax_meta.msg == 'Failed to find a server matching provided search parameters'
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region and name
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: 'bad'
ignore_errors: true
register: rax_meta
- name: Validate rax_meta creds, region and name
assert:
that:
- rax_meta|failed
- rax_meta.msg == 'Failed to find a server matching provided search parameters'
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, address, id and name
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
address: '1.2.3.4'
id: '1234'
name: 'bad'
ignore_errors: true
register: rax_meta
- name: Validate rax_meta creds, region, address, id and name
assert:
that:
- rax_meta|failed
- "rax_meta.msg == 'parameters are mutually exclusive: [\\'address\\', \\'id\\', \\'name\\']'"
# ============================================================
# ============================================================
- name: Build CloudServer for rax_meta tests
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-rax_meta"
meta:
foo: bar
wait: true
register: rax
- name: Validate build
assert:
that:
- rax|success
- rax|changed
- rax.action == 'create'
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-rax_meta"
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid public IPv4 address
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
address: "{{ rax.success.0.rax_accessipv4 }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid public IPv4 address
assert:
that:
- rax_meta|success
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid public IPv6 address
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
address: "{{ rax.success.0.rax_accessipv6 }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid public IPv6 address
assert:
that:
- rax_meta|success
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid private IPv4 address
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
address: "{{ rax.success.0.rax_networks.private|first }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid private IPv4 address
assert:
that:
- rax_meta|success
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid ID
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: "{{ rax.success.0.rax_id }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid ID
assert:
that:
- rax_meta|success
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid name
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: "{{ rax.success.0.rax_name }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid name
assert:
that:
- rax_meta|success
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid ID set foo=bar
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: "{{ rax.success.0.rax_id }}"
meta:
foo: bar
register: rax_meta
- name: Validate rax_meta creds, region, and valid ID set foo=bar
assert:
that:
- rax_meta|success
- rax_meta|changed
- "rax_meta.meta == {'foo': 'bar'}"
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid ID set bar=baz
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: "{{ rax.success.0.rax_id }}"
meta:
bar: baz
register: rax_meta
- name: Validate rax_meta creds, region, and valid ID set bar=baz
assert:
that:
- rax_meta|success
- "rax_meta.meta == {'bar': 'baz'}"
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid ID set bar=baz (idempotent)
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: "{{ rax.success.0.rax_id }}"
meta:
bar: baz
register: rax_meta
- name: Validate rax_meta creds, region, and valid ID set bar=baz
assert:
that:
- rax_meta|success
- not rax_meta|changed
- "rax_meta.meta == {'bar': 'baz'}"
# ============================================================
# ============================================================
- name: Test rax_meta with creds, region, and valid ID delete meta
rax_meta:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
id: "{{ rax.success.0.rax_id }}"
register: rax_meta
- name: Validate rax_meta creds, region, and valid ID delete meta
assert:
that:
- rax_meta|success
- rax_meta|changed
- rax_meta.meta == {}
# ============================================================
# ============================================================
- name: "Delete CloudServer"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
instance_ids:
- "{{ rax.success.0.rax_id }}"
state: absent
wait: true
register: rax
- name: "Validate delete"
assert:
that:
- rax|changed
- rax|success
- rax.action == 'delete'
- rax.success[0].name == "{{ resource_prefix }}-rax_meta"
# ============================================================