mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-05 10:20:26 -07:00
Merge pull request #639 from ansible-collections/update-tests
chore: remove jinja vars from conditional statements in test asserts
This commit is contained in:
commit
e8bcdf6005
13 changed files with 31 additions and 30 deletions
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
profile: production
|
||||
parseable: true
|
||||
skip_list:
|
||||
- ANSIBLE0010
|
||||
use_default_rules: true
|
||||
verbosity: 1
|
||||
exclude_paths:
|
||||
- ./roles/gcp_http_lb/
|
||||
- ./tests/
|
||||
- ./plugins
|
||||
# Ignore submodule https://github.com/GoogleCloudPlatform/google-cloud-ops-agents-ansible
|
||||
- roles/google_cloud_ops_agents/
|
||||
|
|
2
.github/workflows/ansible-test.yml
vendored
2
.github/workflows/ansible-test.yml
vendored
|
@ -37,7 +37,7 @@ jobs:
|
|||
- name: Install ansible-lint
|
||||
run: pip install ansible-lint==24.7.0
|
||||
- name: Run ansible-lint
|
||||
run: ansible-lint
|
||||
run: ansible-lint --exclude roles/google_cloud_ops_agents/
|
||||
unit:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Gcloud | Archive | RedHat | Ensure bash completion is installed
|
||||
ansible.builtin.yum:
|
||||
ansible.builtin.dnf:
|
||||
name:
|
||||
- bash-completion
|
||||
register: task_result
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
- name: Gcloud | RHEL | Add an Apt signing key, uses whichever key is at the URL
|
||||
# https://cloud.google.com/sdk/docs/install#rpm
|
||||
- name: Gcloud | RHEL | Add a dnf signing key, uses whichever key is at the URL
|
||||
ansible.builtin.yum_repository:
|
||||
name: google-cloud-sdk
|
||||
description: Google Cloud SDK
|
||||
baseurl: https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
|
||||
baseurl: https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-x86_64
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
repo_gpgcheck: true
|
||||
repo_gpgcheck: false
|
||||
gpgkey:
|
||||
- https://packages.cloud.google.com/yum/doc/yum-key.gpg
|
||||
- https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
|
||||
|
||||
- name: Gcloud | RHEL | Install the google-cloud-sdk package
|
||||
ansible.builtin.yum:
|
||||
ansible.builtin.dnf:
|
||||
name: google-cloud-sdk
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
|
@ -21,7 +21,7 @@
|
|||
delay: 2
|
||||
|
||||
- name: Gcloud | Debian | Install the google-cloud-sdk additional components
|
||||
ansible.builtin.yum:
|
||||
ansible.builtin.dnf:
|
||||
name: google-cloud-sdk-{{ item }}
|
||||
update_cache: "yes"
|
||||
register: task_result
|
||||
|
|
|
@ -16,6 +16,7 @@ ZONE="us-central1-a"
|
|||
main() {
|
||||
# note: the ordering here is deliberate, to start with
|
||||
# leaf resources and work upwards to parent resources.
|
||||
cleanup_resource "container" "clusters" "" "--zone=$ZONE"
|
||||
cleanup_resource_per_region "compute" "vpn-tunnels"
|
||||
cleanup_resource "compute" "instances" "" "--zone=$ZONE"
|
||||
cleanup_resource_per_region "compute" "addresses"
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'my-cluster' in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a cluster that already exists
|
||||
google.cloud.gcp_container_cluster:
|
||||
|
@ -104,7 +104,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'my-cluster' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a cluster that does not exist
|
||||
google.cloud.gcp_container_cluster:
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'my-pool' in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*my-pool.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a node pool that already exists
|
||||
google.cloud.gcp_container_node_pool:
|
||||
|
@ -108,7 +108,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'my-pool' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*my-pool.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a node pool that does not exist
|
||||
google.cloud.gcp_container_node_pool:
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'www.testzone-4.com.'in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*www\\.testzone-4\\.com.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a resource record set that already exists
|
||||
google.cloud.gcp_dns_resource_record_set:
|
||||
|
@ -118,7 +118,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'www.testzone-4.com.'not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*www\\.testzone-4\\.com.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a resource record set that does not exist
|
||||
google.cloud.gcp_dns_resource_record_set:
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "\"{{ resource_name }}\" in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a subscription that already exists
|
||||
google.cloud.gcp_pubsub_subscription:
|
||||
|
@ -98,7 +98,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "\"{{ resource_name }}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a subscription that does not exist
|
||||
google.cloud.gcp_pubsub_subscription:
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'test-topic1' in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*test-topic1.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a topic that already exists
|
||||
google.cloud.gcp_pubsub_topic:
|
||||
|
@ -82,7 +82,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'test-topic1' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*test-topic1.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a topic that does not exist
|
||||
google.cloud.gcp_pubsub_topic:
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "\"{{ resource_name }}\" in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a database that already exists
|
||||
google.cloud.gcp_sql_database:
|
||||
|
@ -107,7 +107,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "\"{{ resource_name }}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a database that does not exist
|
||||
google.cloud.gcp_sql_database:
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'test-user' in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*test-user.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Create a user that already exists
|
||||
google.cloud.gcp_sql_user:
|
||||
|
@ -111,7 +111,7 @@
|
|||
- name: Verify that command succeeded
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'test-user' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*test-user.*") | list | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: Delete a user that does not exist
|
||||
google.cloud.gcp_sql_user:
|
||||
|
|
|
@ -85,7 +85,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
|
|||
difference = {"test": "original"}
|
||||
request1 = GcpRequest(value1)
|
||||
request2 = GcpRequest(value2)
|
||||
self.assertNotEquals(request1, request2)
|
||||
self.assertNotEqual(request1, request2)
|
||||
self.assertEqual(request1.difference(request2), difference)
|
||||
|
||||
def test_nested_dictionaries_no_difference(self):
|
||||
|
@ -99,7 +99,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
|
|||
difference = {"foo": {"quiet": {"tree": "test"}, "bar": "baz"}}
|
||||
request1 = GcpRequest(value1)
|
||||
request2 = GcpRequest(value2)
|
||||
self.assertNotEquals(request1, request2)
|
||||
self.assertNotEqual(request1, request2)
|
||||
self.assertEqual(request1.difference(request2), difference)
|
||||
|
||||
def test_arrays_strings_no_difference(self):
|
||||
|
@ -123,7 +123,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
|
|||
}
|
||||
request1 = GcpRequest(value1)
|
||||
request2 = GcpRequest(value2)
|
||||
self.assertNotEquals(request1, request2)
|
||||
self.assertNotEqual(request1, request2)
|
||||
self.assertEqual(request1.difference(request2), difference)
|
||||
|
||||
def test_arrays_dicts_with_no_difference(self):
|
||||
|
@ -141,7 +141,7 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
|
|||
difference = {"foo": [{"test": "value", "foo": "bar"}]}
|
||||
request1 = GcpRequest(value1)
|
||||
request2 = GcpRequest(value2)
|
||||
self.assertNotEquals(request1, request2)
|
||||
self.assertNotEqual(request1, request2)
|
||||
self.assertEqual(request1.difference(request2), difference)
|
||||
|
||||
def test_dicts_boolean_with_difference(self):
|
||||
|
@ -165,5 +165,5 @@ class GCPRequestDifferenceTestCase(unittest.TestCase):
|
|||
}
|
||||
request1 = GcpRequest(value1)
|
||||
request2 = GcpRequest(value2)
|
||||
self.assertNotEquals(request1, request2)
|
||||
self.assertNotEqual(request1, request2)
|
||||
self.assertEqual(request1.difference(request2), difference)
|
||||
|
|
Loading…
Add table
Reference in a new issue