# 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'