Skip to content

Commit

Permalink
Initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Sep 24, 2021
1 parent b18e16f commit 520c8c7
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 7 deletions.
26 changes: 21 additions & 5 deletions tests/integration/targets/route53_health_check/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
94 changes: 92 additions & 2 deletions tests/integration/targets/route53_health_check/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 520c8c7

Please sign in to comment.