Skip to content

Commit

Permalink
Test cleanup (#2397) (#2409)
Browse files Browse the repository at this point in the history
This is a backport of PR #2397 as merged into main (e178256).
SUMMARY

Update FQCN of modules that moved to amazon.aws
Remove explicit call to collections from defaults stanza, now we're using FQCNs we don't need to pull it in.

ISSUE TYPE

Feature Pull Request

COMPONENT NAME
tests/integration/targets
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell
  • Loading branch information
patchback[bot] authored Dec 5, 2024
1 parent 84c52c2 commit 62a934b
Show file tree
Hide file tree
Showing 71 changed files with 78 additions and 229 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/tests-fqcn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
trivial:
- Update FQCN of modules that moved to amazon.aws
- Remove explicit call to ``collections`` from defaults stanza, now we're using FQCNs we don't need to pull it in.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@

# we need a launch template, otherwise we cannot test the mixed instance policy
- name: create launch template for autoscaling group to test its mixed instances policy
community.aws.ec2_launch_template:
amazon.aws.ec2_launch_template:
template_name: "{{ resource_prefix }}-lt"
image_id: "{{ ec2_ami_id }}"
instance_type: t3.micro
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
- "{{ resource_prefix }}-lc-2"

- name: delete launch template
community.aws.ec2_launch_template:
amazon.aws.ec2_launch_template:
name: "{{ resource_prefix }}-lt"
state: absent
register: del_lt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# Unfortunately AWSRetry doesn't support paginators and boto3's paginators
# don't support any configuration of the delay between retries.
max_attempts: 20
collections:
- community.aws
block:
# https://github.com/ansible/ansible/issues/77257
- name: Set async_dir for HOME env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- "{{ default_tiny_name }}-2"

- name: remove launch templates
community.aws.ec2_launch_template:
amazon.aws.ec2_launch_template:
name: "{{ item }}"
state: absent
register: removed
Expand All @@ -42,15 +42,7 @@
loop:
- "{{ default_resource_name }}-1"
- "{{ default_resource_name }}-2"

- name: delete launch template
community.aws.ec2_launch_template:
name: "{{ default_resource_name }}"
state: absent
register: del_lt
retries: 10
until: del_lt is not failed
ignore_errors: true
- "{{ default_resource_name }}"

- ansible.builtin.include_role:
name: setup_ec2_vpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# Note: main autoscaling tests use ASG "Launch Configs", these are being phased out in favour of EC2
# Launch Templates
- name: ensure launch templates exist
community.aws.ec2_launch_template:
amazon.aws.ec2_launch_template:
name: "{{ item }}"
network_interfaces:
- device_index: 0
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/autoscaling_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
collections:
- community.aws
block:
- ansible.builtin.include_tasks: env_setup.yml
- ansible.builtin.include_tasks: tests.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@
- "{{ lc_name_1 }}"
- "{{ lc_name_2 }}"

- name: Delete launch template
community.aws.ec2_launch_template:
name: "{{ resource_prefix }}-lt"
state: absent
register: del_lt
retries: 10
until: del_lt is not failed
ignore_errors: true

- name: Remove the security group
amazon.aws.ec2_security_group:
name: "{{ sg_name }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
- hosts: localhost
gather_facts: false
collections:
- amazon.aws
module_defaults:
group/aws:
access_key: "{{ aws_access_key }}"
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/cloudtrail/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
amazon.aws.cloudtrail:
s3_bucket_name: "{{ s3_bucket_name }}"
region: "{{ aws_region }}"
collections:
- amazon.aws
block:
# ============================================================
# Argument Tests
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_ami/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
access_key: "{{ aws_access_key }}"
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
collections:
- amazon.aws
block:
# ============================================================

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_ami_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
access_key: "{{ aws_access_key }}"
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
collections:
- amazon.aws
block:
# ============================================================

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_ami_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
access_key: "{{ aws_access_key }}"
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
collections:
- amazon.aws
block:
# ============================================================

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_ami_tpm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
access_key: "{{ aws_access_key }}"
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
collections:
- amazon.aws
block:
# ============================================================

Expand Down
5 changes: 0 additions & 5 deletions tests/integration/targets/ec2_eni/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"

collections:
- amazon.aws
- ansible.utils
- community.aws

block:
# ============================================================
- name: create a VPC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

hosts: localhost

collections:
- amazon.aws
- community.aws

vars:
vpc_name: "{{ resource_prefix }}-vpc"
vpc_seed: "{{ resource_prefix }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

hosts: localhost

collections:
- amazon.aws
- community.aws

tasks:
# ============================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
Description: Created by ansible-test
register: vpc_result_2
- name: Peer the secondary-VPC to the main VPC
community.aws.ec2_vpc_peering:
amazon.aws.ec2_vpc_peering:
vpc_id: "{{ vpc_result_2.vpc.id }}"
peer_vpc_id: "{{ vpc_result.vpc.id }}"
peer_owner_id: "{{ caller_facts.account }}"
peer_region: "{{ aws_region }}"
register: peer_origin
- name: Accept the secondary-VPC peering connection in the main VPC
community.aws.ec2_vpc_peering:
amazon.aws.ec2_vpc_peering:
peer_vpc_id: "{{ vpc_result_2.vpc.id }}"
vpc_id: "{{ vpc_result.vpc.id }}"
state: accept
Expand Down Expand Up @@ -83,7 +83,7 @@
always:
- ansible.builtin.pause: seconds=5
- name: Delete secondary-VPC side of peer
community.aws.ec2_vpc_peering:
amazon.aws.ec2_vpc_peering:
vpc_id: "{{ vpc_result_2.vpc.id }}"
peer_vpc_id: "{{ vpc_result.vpc.id }}"
peering_id: "{{ peer_origin.peering_id }}"
Expand All @@ -92,7 +92,7 @@
peer_region: "{{ aws_region }}"
ignore_errors: true
- name: Delete main-VPC side of peer
community.aws.ec2_vpc_peering:
amazon.aws.ec2_vpc_peering:
peer_vpc_id: "{{ vpc_result_2.vpc.id }}"
vpc_id: "{{ vpc_result.vpc.id }}"
state: absent
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"

collections:
- amazon.aws
- community.aws

block:
- name: Gather availability zones
amazon.aws.aws_az_info:
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/targets/ec2_spot_instance/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"

collections:
- amazon.aws
- community.aws

block:
- name: Get available AZs
amazon.aws.aws_az_info:
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/targets/ec2_transit_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
- create_result.changed == False

- name: Test success with filter
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
filters:
options.multicast-support: enable
register: result
Expand All @@ -229,7 +229,7 @@

# ==== Combine ec2_transit_gateway_info ======================
- name: Test success with no parameters
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
register: result
- name: Assert success with no parameters
ansible.builtin.assert:
Expand All @@ -238,7 +238,7 @@
- result.transit_gateways != []

- name: Test success with single filter
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
filters:
transit-gateway-id: '{{ create_result.transit_gateway.transit_gateway_id }}'
register: result
Expand All @@ -250,7 +250,7 @@
- result.transit_gateways != []

- name: Test empty result set for non-existent tgw id via filter
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
filters:
transit-gateway-id: tgw-00000011111111122
register: result
Expand All @@ -262,7 +262,7 @@
- result.transit_gateways == []

- name: Test NotFound exception caught and returned empty result set
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
transit_gateway_id: tgw-00000011111111122
register: result

Expand All @@ -273,7 +273,7 @@
- result.transit_gateways == []

- name: Test success with multiple filters
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
filters:
options.dns-support: enable
options.vpn-ecmp-support: enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ignore_errors: true

- name: Gather info about all transit gateways
community.aws.ec2_transit_gateway_info:
amazon.aws.ec2_transit_gateway_info:
transit_gateway_ids:
- '{{ tgw_id }}'
- '{{ tgw_id_2 }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
tags:
Name: '{{ item.name }}'
loop:
- description: Transit Gateway for testing community.aws.ec2_transit_gateway_attachment
- description: Transit Gateway for testing ec2_transit_gateway_attachment
name: '{{ tgw_name }}'
- description: Second Transit Gateway for testing community.aws.ec2_transit_gateway_attachment
- description: Second Transit Gateway for testing ec2_transit_gateway_attachment
name: '{{ tgw_name_2 }}'
register: create_tgws

Expand Down
4 changes: 0 additions & 4 deletions tests/integration/targets/ec2_vol/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"

collections:
- amazon.aws
- community.aws

block:
- name: Create a test VPC
amazon.aws.ec2_vpc_net:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
secret_key: "{{ aws_secret_key }}"
session_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
collections:
- amazon.aws
- community.aws
block:
- name: List all available services (Check Mode)
amazon.aws.ec2_vpc_endpoint_service_info:
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/ec2_vpc_route_table/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
register: transit_gateway

- name: Create VPC attachment
community.aws.ec2_transit_gateway_vpc_attachment:
amazon.aws.ec2_transit_gateway_vpc_attachment:
state: present
name: "{{ resource_prefix }}_vpc_attachment"
transit_gateway: "{{ transit_gateway.transit_gateway.transit_gateway_id }}"
Expand Down Expand Up @@ -1355,7 +1355,7 @@
# ------------------------------------------------------------------------------------------

- name: Create vgw for gateway route table
community.aws.ec2_vpc_vgw:
amazon.aws.ec2_vpc_vgw:
state: present
vpc_id: "{{ vpc.vpc.id }}"
type: ipsec.1
Expand Down Expand Up @@ -1560,14 +1560,14 @@
state: absent
ignore_errors: true
- name: Destroy VGW
community.aws.ec2_vpc_vgw:
amazon.aws.ec2_vpc_vgw:
state: absent
type: ipsec.1
name: "{{ resource_prefix }}_vpc"
vpc_id: "{{ vpc.vpc.id }}"
ignore_errors: true
- name: Delete VPC attachment
community.aws.ec2_transit_gateway_vpc_attachment:
amazon.aws.ec2_transit_gateway_vpc_attachment:
state: absent
id: "{{ vpc_attachment.attachments[0].transit_gateway_attachment_id }}"
wait: true
Expand Down
Loading

0 comments on commit 62a934b

Please sign in to comment.