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
     * Add ec2_vpc_nat_gateway_info in aliases
     * Fix NAT gateway search

Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Feb 9, 2021
1 parent 468b6d2 commit f33eb01
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/integration/targets/ec2_vpc_nat_gateway/aliases
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cloud/aws
shippable/aws/group2
ec2_vpc_nat_gateway_info
94 changes: 94 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,35 @@
# that:
# - create_ngw.changed


# ============================================================
- name: Get NAT gateway with specific filters (state and subnet)
ec2_vpc_nat_gateway_info:
filters:
subnet-id: "{{ subnet_id }}"
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 and subnet) - CHECK_MODE
# ec2_vpc_nat_gateway_info:
# filters:
# state: ['available']
# subnet-id: "{{ subnet_id }}"
# 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 +285,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 +325,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 +391,33 @@
# 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
#- ngw_info.result | selectattr("nat_gateway_id",'equalto',"{{ }}")

#- 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: Update the tags - remove and add
Expand Down Expand Up @@ -383,6 +451,32 @@
# that:
# - update_tags_ngw.changed

# ============================================================
- name: Gather information about a filtered list of NAT Gateways using tags (no match)
ec2_vpc_nat_gateway_info:
filters:
"tag:tag_one": '{{ resource_prefix }} One'
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:tag_one": '{{ resource_prefix }} One'
# register: ngw_info

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



# ============================================================
- name: Update the tags add without purge
Expand Down

0 comments on commit f33eb01

Please sign in to comment.