From 520c8c78b741f2262ab067f7959fd646b2abc05d Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 24 Sep 2021 11:50:48 +0200 Subject: [PATCH] Initial tests --- .../route53_health_check/defaults/main.yml | 26 ++++- .../route53_health_check/tasks/main.yml | 94 ++++++++++++++++++- 2 files changed, 113 insertions(+), 7 deletions(-) diff --git a/tests/integration/targets/route53_health_check/defaults/main.yml b/tests/integration/targets/route53_health_check/defaults/main.yml index 9e738b6a4da..af5fa4aca1d 100644 --- a/tests/integration/targets/route53_health_check/defaults/main.yml +++ b/tests/integration/targets/route53_health_check/defaults/main.yml @@ -3,14 +3,30 @@ # # Module uses the following as an 'ID' # (the real ID is automatically assigned after creation) +# - ip_address +# - fqdn +# - port +# - type +# - request_interval -ip_address: 192.0.{{ 256 | random(seed=resource_prefix) }}.0 -fqdn: -port: -type: -request_interval: +#ip_address: We allocate an EIP due to route53 restrictions +fqdn: '{{ tiny_prefix }}.route53-health.ansible.test' +port: '8080' +type: 'TCP' +request_interval: 30 # modifiable # - resource_path # - string_match # - failure_threshold + +failure_threshold: 5 +failure_threshold_updated: 1 + +# For resource_path we need an HTTP/HTTPS type check +# for string_match we need an _STR_MATCH type +type_https_match: 'HTTPS_STR_MATCH' +resource_path: '/' +resource_path_updated: '/healthz' +string_match: 'Hello' +string_match_updated: 'Hello World' diff --git a/tests/integration/targets/route53_health_check/tasks/main.yml b/tests/integration/targets/route53_health_check/tasks/main.yml index b2895ceddef..9b23b5d6db5 100644 --- a/tests/integration/targets/route53_health_check/tasks/main.yml +++ b/tests/integration/targets/route53_health_check/tasks/main.yml @@ -21,11 +21,101 @@ security_token: '{{ security_token | default(omit) }}' region: '{{ aws_region }}' block: - - debug: msg=hello + # Route53 can only test against routable IPs. Request an EIP so some poor + # soul doesn't get randomly hit by our testing. + - name: Allocate an EIP we can test against + ec2_eip: + state: present + register: eip + + - set_fact: + ip_address: '{{ eip.public_ip }}' + + # Minimum possible definition + - name: 'Create a TCP health check' + route53_health_check: + state: present + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + + - name: 'Create a TCP health check - idempotency' + route53_health_check: + state: present + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + + # Update an attribute (for TCP only failure threshold makes sense) + - name: 'Update TCP health check - set threshold' + route53_health_check: + state: present + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + failure_threshold: '{{ failure_threshold_updated }}' + + - name: 'Update TCP health check - set threshold - idempotency' + route53_health_check: + state: present + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + failure_threshold: '{{ failure_threshold_updated }}' + + # Test deletion + - name: 'Delete TCP health check' + route53_health_check: + state: absent + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + + - name: 'Delete TCP health check - idempotency' + route53_health_check: + state: absent + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + +## ip_address: '192.0.2.{{ 256 | random(seed=resource_prefix) }}' +## fqdn: '{{ tiny_prefix }}.route53-health.ansible.test' +## port: '8080' +## type: 'TCP' +## request_interval: 30 +## +## # modifiable +## # - resource_path +## # - string_match +## # - failure_threshold +## +## failure_threshold: 5 +## failure_threshold_updated: 1 +## +## # For resource_path we need an HTTP/HTTPS type check +## # for string_match we need an _STR_MATCH type +## type_https_match: 'HTTPS_STR_MATCH' +## resource_path: '/' +## resource_path_updated: '/healthz' +## string_match: 'Hello' +## string_match_updated: 'Hello World' always: - - debug: msg=hello ################################################ # TEARDOWN STARTS HERE ################################################ + + - name: 'Delete TCP health check' + route53_health_check: + state: absent + ip_address: '{{ ip_address }}' + port: '{{ port }}' + type: '{{ type }}' + ignore_errors: true + + - name: release EIP + ec2_eip: + state: absent + public_ip: '{{ ip_address }}' + ignore_errors: true