[GCE] updates to gce integration test (#18097)

* Added test for sequenced-name instance generation (num_instances)
* Added param-check tags to tests that only do argument checking
Should be merged AFTER ansible/ansible-modules-core#4276
pull/18339/merge
Tom Melendez 8 years ago committed by Ryan Brown
parent 3fd03b764b
commit b9e07c8dd7

@ -5,12 +5,14 @@
gce:
register: result
ignore_errors: true
tags:
- param-check
- name: assert failure when called with no parameters
assert:
that:
- 'result.failed'
- 'result.msg == "Missing GCE connection parameters in libcloud secrets file."'
- 'result.msg == "Must specify a \"name\" or \"instance_names\""'
# ============================================================
- name: test missing name
@ -20,8 +22,10 @@
project_id: "{{ project_id }}"
register: result
ignore_errors: true
tags:
- param-check
- name: assert failure when called with no parameters
- name: assert failure when missing name
assert:
that:
- 'result.failed'
@ -95,6 +99,43 @@
- 'result.name == "{{ instance_name }}"'
- 'result.state == "absent"'
# ============================================================
- name: test num_instances state=present (expected changed=true)
gce:
base_name: "{{ instance_name }}"
num_instances: 2
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
state: present
register: result
- name: assert state=present (expected changed=true)
assert:
that:
- 'result.changed'
- 'result.name == "{{ instance_name }}"'
- 'result.state == "present"'
- 'result.instance_data|length == 2'
# ============================================================
- name: test num_instances state=absent (expected changed=true)
gce:
base_name: "{{ instance_name }}"
num_instances: 2
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
state: absent
register: result
- name: assert num_instances state=absent (expected changed=true)
assert:
that:
- 'result.changed'
- 'result.state == "absent"'
- 'result.instance_names == ["{{ instance_name }}-000", "{{ instance_name }}-001"]'
# ============================================================
- name: test disks given (expected changed=true)
gce:

Loading…
Cancel
Save