mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-06 10:50:28 -07:00
tests: fixing region_target_http_proxy
The backend_service resource was not regional, which is in invalid configuration for a regional proxy to depend on. Fixing up cleanup-script to better handle region/ global resources.
This commit is contained in:
parent
b6f694ed7e
commit
5fc619fbb7
3 changed files with 25 additions and 69 deletions
|
@ -14,18 +14,21 @@ ZONE="us-central1-a"
|
|||
main() {
|
||||
# note: the ordering here is deliberate, to start with
|
||||
# leaf resources and work upwards to parent resources.
|
||||
cleanup_resource "compute instances" "--zone=$ZONE"
|
||||
cleanup_resource "compute target-http-proxies" "--global"
|
||||
cleanup_resource "compute forwarding-rules" "--global"
|
||||
cleanup_resource "compute url-maps" "--global"
|
||||
cleanup_resource "compute backend-services" "--global"
|
||||
cleanup_resource "compute instances" "" "--zone=$ZONE"
|
||||
cleanup_resource "compute target-http-proxies" "" "--global"
|
||||
cleanup_resource "compute forwarding-rules" "" "--global"
|
||||
cleanup_resource "compute url-maps" "" "--global"
|
||||
cleanup_resource "compute backend-services" "--global" "--global"
|
||||
cleanup_resource "compute backend-services" \
|
||||
"--regions=us-central1" "--region=us-central1"
|
||||
}
|
||||
|
||||
cleanup_resource() {
|
||||
resource_group="$1"
|
||||
extra_delete_args="$2"
|
||||
extra_list_args="$2"
|
||||
extra_delete_args="$3"
|
||||
|
||||
for resource in $(gcloud $resource_group list --project="${PROJECT_ID}" --format="csv[no-heading](name)"); do
|
||||
for resource in $(gcloud $resource_group list --project="${PROJECT_ID}" --format="csv[no-heading](name)" $extra_list_args); do
|
||||
gcloud $resource_group delete "${resource}" --project="${PROJECT_ID}" -q $extra_delete_args
|
||||
done
|
||||
}
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
cloud/gcp
|
||||
unsupported
|
||||
cloud/gcp
|
|
@ -13,43 +13,22 @@
|
|||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# Pre-test setup
|
||||
- name: create a instance group
|
||||
google.cloud.gcp_compute_instance_group:
|
||||
name: instancegroup-targethttpproxy
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: instancegroup
|
||||
- name: create a HTTP health check
|
||||
google.cloud.gcp_compute_http_health_check:
|
||||
name: httphealthcheck-targethttpproxy
|
||||
healthy_threshold: 10
|
||||
port: 8080
|
||||
timeout_sec: 2
|
||||
unhealthy_threshold: 5
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: healthcheck
|
||||
- name: create a backend service
|
||||
google.cloud.gcp_compute_backend_service:
|
||||
google.cloud.gcp_compute_region_backend_service:
|
||||
name: backendservice-targethttpproxy
|
||||
backends:
|
||||
- group: "{{ instancegroup.selfLink }}"
|
||||
health_checks:
|
||||
- "{{ healthcheck.selfLink }}"
|
||||
region: us-central1
|
||||
enable_cdn: 'true'
|
||||
protocol: HTTP
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
load_balancing_scheme: "EXTERNAL"
|
||||
state: present
|
||||
register: backendservice
|
||||
- name: create a URL map
|
||||
google.cloud.gcp_compute_url_map:
|
||||
google.cloud.gcp_compute_region_url_map:
|
||||
name: urlmap-targethttpproxy
|
||||
region: us-central1
|
||||
default_service: "{{ backendservice }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
|
@ -159,49 +138,24 @@
|
|||
# Post-test teardown
|
||||
# If errors happen, don't crash the playbook!
|
||||
- name: delete a URL map
|
||||
google.cloud.gcp_compute_url_map:
|
||||
google.cloud.gcp_compute_region_url_map:
|
||||
name: urlmap-targethttpproxy
|
||||
region: us-central1
|
||||
default_service: "{{ backendservice }}"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: urlmap
|
||||
ignore_errors: true
|
||||
- name: delete a backend service
|
||||
google.cloud.gcp_compute_backend_service:
|
||||
google.cloud.gcp_compute_region_backend_service:
|
||||
name: backendservice-targethttpproxy
|
||||
backends:
|
||||
- group: "{{ instancegroup.selfLink }}"
|
||||
health_checks:
|
||||
- "{{ healthcheck.selfLink }}"
|
||||
region: us-central1
|
||||
enable_cdn: 'true'
|
||||
protocol: HTTP
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: backendservice
|
||||
ignore_errors: true
|
||||
- name: delete a HTTP health check
|
||||
google.cloud.gcp_compute_http_health_check:
|
||||
name: httphealthcheck-targethttpproxy
|
||||
healthy_threshold: 10
|
||||
port: 8080
|
||||
timeout_sec: 2
|
||||
unhealthy_threshold: 5
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: healthcheck
|
||||
ignore_errors: true
|
||||
- name: delete a instance group
|
||||
google.cloud.gcp_compute_instance_group:
|
||||
name: instancegroup-targethttpproxy
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: instancegroup
|
||||
ignore_errors: true
|
||||
load_balancing_scheme: "EXTERNAL"
|
||||
state: present
|
||||
ignore_errors: true
|
Loading…
Add table
Reference in a new issue