From 3e00968b62711d396a0d12ac7fd17992b67a008b Mon Sep 17 00:00:00 2001 From: Alina Buzachis Date: Tue, 2 Feb 2021 23:10:30 +0100 Subject: [PATCH] NAT gateway: increase integration tests coverage * Add additional integration tests for ec2_vpc_nat_gateway_info and ec2_vpc_nat_gatewy modules Signed-off-by: Alina Buzachis --- .../ec2_vpc_nat_gateway/tasks/main.yml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml b/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml index 2b411340149..8224958716f 100644 --- a/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml @@ -145,6 +145,33 @@ # 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: @@ -256,6 +283,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 @@ -285,6 +323,7 @@ # that: # - delete_nat_gateway.changed + # ============================================================ - name: Create new NAT gateway with eip allocation-id and tags ec2_vpc_nat_gateway: @@ -350,6 +389,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