Skip to content

Commit

Permalink
NAT gateway: increase integration tests coverage
Browse files Browse the repository at this point in the history
     * Add additional integration tests for ec2_vpc_nat_gateway_info and ec2_vpc_nat_gatewy modules

Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Feb 2, 2021
1 parent 85ecade commit 7705caf
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@
# that:
# - create_ngw.changed


# ============================================================
- name: Get all NAT gateways with specific filters (state avalaibale)
ec2_vpc_nat_gateway_info:
filters:
state: ['available']
register: avalaible_ngws

- name: Assert success
assert:
that:
- avalaible_ngws is successful
- avalaible_ngws.result | length == 1

#- name: Get all NAT gateways with specific filters (state avalaibale) - CHECK_MODE
# ec2_vpc_nat_gateway_info:
# filters:
# state: ['available']
# register: avalaible_ngws

#- name: Assert success - CHECK_MODE
# assert:
# that:
# - avalaible_ngws is successful
# - avalaible_ngws.result | length == 1

# ============================================================
- name: Trying this again for idempotency - create new NAT gateway with eip allocation-id
ec2_vpc_nat_gateway:
Expand Down Expand Up @@ -256,6 +282,17 @@
# that:
# - not create_ngw.changed

- name: Fetch NAT gateway by ID (list)
ec2_vpc_nat_gateway_info:
nat_gateway_ids:
- "{{ nat_gateway_id }}"
register: ngw_info
ignore_errors: True

- name: Check NAT gateway exists
assert:
that:
- ngw_info is successful

# ============================================================
- name: Delete NAT gateway
Expand Down Expand Up @@ -285,6 +322,7 @@
# that:
# - delete_nat_gateway.changed


# ============================================================
- name: Create new NAT gateway with eip allocation-id and tags
ec2_vpc_nat_gateway:
Expand Down Expand Up @@ -350,6 +388,58 @@
# that:
# - not update_tags_ngw.changed


# ============================================================
- name: Gather information about a filtered list of NAT Gateways using tags
ec2_vpc_nat_gateway_info:
filters:
"tag:Tag Two": 'two {{ resource_prefix }}'
register: ngw_info

- name: Assert success
assert:
that:
- ngw_info is successful
- ngw_info.result | length == 1

#- name: Gather information about a filtered list of NAT Gateways using tags - CHECK_MODE
# ec2_vpc_nat_gateway_info:
# filters:
# "tag:Tag Two": 'two {{ resource_prefix }}'
# register: ngw_info

#- name: Assert success - CHECK_MODE
# assert:
# that:
# - ngw_info is successful
# - ngw_info.result | length == 1


# ============================================================
- name: Gather information about a filtered list of NAT Gateways using tags (no match)
ec2_vpc_nat_gateway_info:
filters:
"tag:Tag1": 'tag1'
register: ngw_info

- name: Assert success
assert:
that:
- ngw_info is successful
- ngw_info.result | length == 0

#- name: Gather information about a filtered list of NAT Gateways using tags (no match) - CHECK_MODE
# ec2_vpc_nat_gateway_info:
# filters:
# "tag:Tag1": 'tag1'
# register: ngw_info

#- name: Assert success - CHECK_MODE
# assert:
# that:
# - ngw_info is successful
# - ngw_info.result | length == 0


# ============================================================
- name: Update the tags - remove and add
Expand Down

0 comments on commit 7705caf

Please sign in to comment.