mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
[GCP] Healthcheck module (#24564)
* [GCP] Healthcheck module * fix return YAML block * removed update_ return value; removed python26 check; typos and docs updates * doc fix * Updated int test for no-update conditions * added filter_gcp_fields test * fixed bug in update where dictionary wasn't built correctly and port was not being set. * added default values to documentation block
This commit is contained in:
parent
ed2f13b3db
commit
c99c3b2b5d
5 changed files with 682 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# defaults file for test_gcp_healthcheck
|
||||
service_account_email: "{{ gce_service_account_email }}"
|
||||
credentials_file: "{{ gce_pem_file }}"
|
||||
project_id: "{{ gce_project_id }}"
|
||||
http_healthcheck: "ans-int-healthcheck-http-{{ resource_prefix|lower }}"
|
||||
https_healthcheck: "ans-int-healthcheck-https-{{ resource_prefix|lower }}"
|
176
test/integration/roles/test_gcp_healthcheck/tasks/main.yml
Normal file
176
test/integration/roles/test_gcp_healthcheck/tasks/main.yml
Normal file
|
@ -0,0 +1,176 @@
|
|||
# GCP Healthcheck Integration Tests.
|
||||
######
|
||||
# ============================================================
|
||||
- name: param check
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ http_healthcheck }}"
|
||||
healthcheck_type: HTTP
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 10
|
||||
timeout: 30
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
state: present
|
||||
ignore_errors: True
|
||||
register: result
|
||||
- name: check interval
|
||||
assert:
|
||||
that:
|
||||
'result.msg == "timeout (30) is greater than check_interval (10)"'
|
||||
# ============================================================
|
||||
- name: create "{{ http_healthcheck }}"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ http_healthcheck }}"
|
||||
healthcheck_type: HTTP
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 5
|
||||
timeout: 5
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
state: present
|
||||
register: result
|
||||
- name: assert create
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "present"'
|
||||
- 'result.changed'
|
||||
# ============================================================
|
||||
- name: "update {{ http_healthcheck }}, no change"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ http_healthcheck }}"
|
||||
healthcheck_type: HTTP
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 5
|
||||
timeout: 5
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
state: present
|
||||
register: result
|
||||
- name: assert update no change
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "present"'
|
||||
- 'not result.changed'
|
||||
- 'result.port == 80'
|
||||
# ============================================================
|
||||
- name: create minimum "{{ https_healthcheck }}"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ https_healthcheck }}"
|
||||
healthcheck_type: HTTPS
|
||||
state: present
|
||||
register: result
|
||||
- name: assert create
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "present"'
|
||||
- 'result.changed'
|
||||
# ============================================================
|
||||
- name: "update {{ https_healthcheck }}, no change"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ https_healthcheck }}"
|
||||
healthcheck_type: HTTPS
|
||||
state: present
|
||||
register: result
|
||||
- name: assert not updated
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "present"'
|
||||
- 'result.port == 443'
|
||||
- 'not result.changed'
|
||||
# ============================================================
|
||||
- name: update "{{ https_healthcheck }}"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ https_healthcheck }}"
|
||||
healthcheck_type: HTTPS
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 5
|
||||
timeout: 5
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
port: 444
|
||||
state: present
|
||||
register: result
|
||||
- name: assert update "{{ https_healthcheck }}"
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "present"'
|
||||
- 'result.changed'
|
||||
- 'result.port == 444'
|
||||
# ============================================================
|
||||
- pause: seconds=5
|
||||
# ============================================================
|
||||
- name: delete "{{ http_healthcheck }}"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ http_healthcheck }}"
|
||||
healthcheck_type: HTTP
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 5
|
||||
timeout: 5
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
state: absent
|
||||
register: result
|
||||
tags:
|
||||
- delete
|
||||
- name: assert absent
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "absent"'
|
||||
- 'result.changed'
|
||||
# ============================================================
|
||||
- name: delete "{{ https_healthcheck }}"
|
||||
# ============================================================
|
||||
gcp_healthcheck:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
healthcheck_name: "{{ https_healthcheck }}"
|
||||
healthcheck_type: HTTPS
|
||||
host_header: my-host
|
||||
request_path: /hc
|
||||
check_interval: 5
|
||||
timeout: 5
|
||||
unhealthy_threshold: 2
|
||||
healthy_threshold: 1
|
||||
state: absent
|
||||
register: result
|
||||
tags:
|
||||
- delete
|
||||
- name: assert absent
|
||||
assert:
|
||||
that:
|
||||
- 'result.state == "absent"'
|
||||
- 'result.changed'
|
Loading…
Add table
Add a link
Reference in a new issue