Test Fixes (#299)

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2019-07-09 11:32:46 -07:00 committed by Alex Stephen
parent 697908c7fe
commit 5b92781ab0
45 changed files with 19 additions and 96 deletions

View file

@ -61,7 +61,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a service account
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: test_project
auth_kind: serviceaccount

View file

@ -108,8 +108,8 @@ def main():
module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
items = fetch_list(module, collection(module))
if items.get('items'):
items = items.get('items')
if items.get('accounts'):
items = items.get('accounts')
else:
items = []
return_value = {'resources': items}

View file

@ -484,7 +484,11 @@ def decode_request(response, module):
def encode_request(request, module):
request['topic'] = '/'.join(['projects', module.params['project'], 'topics', replace_resource_dict(request['topic'], 'name')])
if isinstance(module.params.get('topic'), dict):
request['topic'] = '/'.join(['projects', module.params['project'], 'topics', replace_resource_dict(module.params.get(u'topic', {}), 'name')])
else:
request['topic'] = '/'.join(['projects', module.params['project'], 'topics', module.params['topic']])
request['name'] = '/'.join(['projects', module.params['project'], 'subscriptions', module.params['name']])
return request

View file

@ -49,7 +49,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*my_example_dataset.*") | list | length == 1
- results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 1
# ----------------------------------------------------------------------------
- name: create a dataset that already exists
gcp_bigquery_dataset:
@ -81,7 +81,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that dataset was deleted
gcp_bigquery_dataset_facts:
project: "{{ gcp_project }}"
@ -93,7 +92,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*my_example_dataset.*") | list | length == 0
- results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 0
# ----------------------------------------------------------------------------
- name: delete a dataset that does not exist
gcp_bigquery_dataset:
@ -109,4 +108,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -66,7 +66,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*example_table.*") | list | length == 1
- results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 1
# ----------------------------------------------------------------------------
- name: create a table that already exists
gcp_bigquery_table:
@ -104,7 +104,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that table was deleted
gcp_bigquery_table_facts:
dataset: example_dataset
@ -117,7 +116,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*example_table.*") | list | length == 0
- results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 0
# ----------------------------------------------------------------------------
- name: delete a table that does not exist
gcp_bigquery_table:
@ -136,7 +135,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -80,7 +80,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that address was deleted
gcp_compute_address_facts:
filters:
@ -110,4 +109,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -95,7 +95,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that backend_bucket was deleted
gcp_compute_backend_bucket_facts:
filters:
@ -126,7 +125,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -116,7 +116,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that backend_service was deleted
gcp_compute_backend_service_facts:
filters:
@ -149,7 +148,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -92,7 +92,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that disk was deleted
gcp_compute_disk_facts:
filters:
@ -125,4 +124,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -111,7 +111,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that firewall was deleted
gcp_compute_firewall_facts:
filters:
@ -148,4 +147,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -114,7 +114,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that forwarding_rule was deleted
gcp_compute_forwarding_rule_facts:
filters:
@ -148,7 +147,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -75,7 +75,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that global_address was deleted
gcp_compute_global_address_facts:
filters:
@ -103,4 +102,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -151,7 +151,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that global_forwarding_rule was deleted
gcp_compute_global_forwarding_rule_facts:
filters:
@ -183,7 +182,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -107,7 +107,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that health_check was deleted
gcp_compute_health_check_facts:
filters:
@ -143,4 +142,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -91,7 +91,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that http_health_check was deleted
gcp_compute_http_health_check_facts:
filters:
@ -123,4 +122,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -91,7 +91,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that https_health_check was deleted
gcp_compute_https_health_check_facts:
filters:
@ -123,4 +122,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -88,7 +88,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that image was deleted
gcp_compute_image_facts:
filters:
@ -117,7 +116,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -172,7 +172,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance was deleted
gcp_compute_instance_facts:
filters:
@ -218,7 +217,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -104,7 +104,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance_group was deleted
gcp_compute_instance_group_facts:
filters:
@ -138,7 +137,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -130,7 +130,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance_group_manager was deleted
gcp_compute_instance_group_manager_facts:
filters:
@ -163,7 +162,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -144,7 +144,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance_template was deleted
gcp_compute_instance_template_facts:
filters:
@ -185,7 +184,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -79,7 +79,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that network was deleted
gcp_compute_network_facts:
filters:
@ -108,4 +107,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -104,7 +104,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that region_disk was deleted
gcp_compute_region_disk_facts:
filters:
@ -140,4 +139,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -107,7 +107,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that route was deleted
gcp_compute_route_facts:
filters:
@ -141,7 +140,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -124,7 +124,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that router was deleted
gcp_compute_router_facts:
filters:
@ -163,7 +162,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -127,7 +127,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that ssl_certificate was deleted
gcp_compute_ssl_certificate_facts:
filters:
@ -168,4 +167,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -95,7 +95,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that ssl_policy was deleted
gcp_compute_ssl_policy_facts:
filters:
@ -128,4 +127,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -97,7 +97,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that subnetwork was deleted
gcp_compute_subnetwork_facts:
filters:
@ -129,7 +128,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -122,7 +122,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_http_proxy was deleted
gcp_compute_target_http_proxy_facts:
filters:
@ -151,7 +150,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -151,7 +151,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_https_proxy was deleted
gcp_compute_target_https_proxy_facts:
filters:
@ -182,7 +181,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -80,7 +80,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_pool was deleted
gcp_compute_target_pool_facts:
filters:
@ -110,4 +109,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -146,7 +146,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_ssl_proxy was deleted
gcp_compute_target_ssl_proxy_facts:
filters:
@ -177,7 +176,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -121,7 +121,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_tcp_proxy was deleted
gcp_compute_target_tcp_proxy_facts:
filters:
@ -151,7 +150,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that target_vpn_gateway was deleted
gcp_compute_target_vpn_gateway_facts:
filters:
@ -132,7 +131,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -113,7 +113,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that url_map was deleted
gcp_compute_url_map_facts:
filters:
@ -142,7 +141,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -128,7 +128,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that vpn_tunnel was deleted
gcp_compute_vpn_tunnel_facts:
filters:
@ -161,7 +160,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -82,7 +82,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that managed_zone was deleted
gcp_dns_managed_zone_facts:
dns_name: test.somewild2.example.com.
@ -111,4 +110,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -108,7 +108,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that resource_record_set was deleted
gcp_dns_resource_record_set_facts:
managed_zone: "{{ managed_zone }}"
@ -141,7 +140,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -1,3 +1,2 @@
---
resource_name: "{{ resource_prefix }}"
sa_name: sa-{{ 100000 | random }}@graphite-playground.google.com.iam.gserviceaccount.com

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: delete a service account
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -24,7 +24,7 @@
#----------------------------------------------------------
- name: create a service account
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -46,11 +46,11 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*{{ sa_name }}.*") | list | length == 1
- results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 1
# ----------------------------------------------------------------------------
- name: create a service account that already exists
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -64,7 +64,7 @@
#----------------------------------------------------------
- name: delete a service account
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -86,11 +86,11 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*{{ sa_name }}.*") | list | length == 0
- results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 0
# ----------------------------------------------------------------------------
- name: delete a service account that does not exist
gcp_iam_service_account:
name: "{{ sa_name }}"
name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"

View file

@ -97,7 +97,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that database was deleted
gcp_sql_database_facts:
instance: "{{ instance }}"
@ -126,7 +125,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance was deleted
gcp_sql_instance_facts:
project: "{{ gcp_project }}"
@ -134,4 +133,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that user was deleted
gcp_sql_user_facts:
instance: "{{ instance }}"
@ -131,7 +130,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -61,7 +61,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
# ----------------------------------------------------------------------------
- name: delete a bucket that does not exist
gcp_storage_bucket:
@ -75,4 +74,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -77,7 +77,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
# ----------------------------------------------------------------------------
- name: delete a bucket access control that does not exist
gcp_storage_bucket_access_control:
@ -93,7 +92,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!