From 3d071cb288d6c73decbb187b11c72418b8219d72 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 9 Nov 2022 23:23:44 +0100 Subject: [PATCH] ec2_instance integration test fixups (#1259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ec2_instance integration test fixups SUMMARY Attempt to fix ec2_instance test instability ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis Reviewed-by: Gonéri Le Bouder --- changelogs/fragments/1258-ec2_instance.yml | 2 ++ .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../defaults/main.yml | 2 +- .../ec2_instance_uptime/defaults/main.yml | 2 +- .../targets/ec2_snapshot/tasks/main.yml | 4 +-- .../setup_ec2_instance_env/defaults/main.yml | 15 +++++++---- .../setup_ec2_instance_env/tasks/main.yml | 26 +++++++++++++++---- 21 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 changelogs/fragments/1258-ec2_instance.yml diff --git a/changelogs/fragments/1258-ec2_instance.yml b/changelogs/fragments/1258-ec2_instance.yml new file mode 100644 index 00000000000..e1c4dd75508 --- /dev/null +++ b/changelogs/fragments/1258-ec2_instance.yml @@ -0,0 +1,2 @@ +trivial: +- ec2_instance - changes to integration tests to fix failures diff --git a/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml b/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml index 0b6859c6ad7..364c37f8226 100644 --- a/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_block_devices ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-block-devices' diff --git a/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml b/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml index da06ab2bfa9..829070a1ee6 100644 --- a/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_checkmode_tests ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-checkmode' diff --git a/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml b/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml index 96a3d24a584..eb1859b3f3a 100644 --- a/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_cpu_options ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-cpu-options' diff --git a/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml b/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml index 04d57864e5b..b233d454756 100644 --- a/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_default_vpc ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-default-vpc' diff --git a/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml b/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml index 0ceb6671d8f..feec2e7c145 100644 --- a/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_ebs_optimized ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-ebs-optimized' diff --git a/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml b/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml index 1d7ab83c867..7dca186d8a6 100644 --- a/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_external_resource_attach ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-external-attach' diff --git a/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml b/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml index 1e51a336a63..28e57b9483c 100644 --- a/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_hibernation_options ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-hibernation-options' diff --git a/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml b/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml index 51b1df85392..2dc4d467bd4 100644 --- a/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml @@ -1,5 +1,5 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_iam_instance_profile ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-profile' diff --git a/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml index b43f94a50b8..d5a60251ee8 100644 --- a/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_minimal ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-minimal' diff --git a/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml index 5c81b54880c..065610b009e 100644 --- a/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_multiple ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-multiple' diff --git a/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml index 0f422a6f5bd..154ca799c03 100644 --- a/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_no_wait ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-no-wait' diff --git a/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml b/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml index cc18f67ce36..07d18b5a8e3 100644 --- a/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_metadata_options ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-metadata' diff --git a/tests/integration/targets/ec2_instance_security_group/defaults/main.yml b/tests/integration/targets/ec2_instance_security_group/defaults/main.yml index f7a141a62f2..3645fcabd86 100644 --- a/tests/integration/targets/ec2_instance_security_group/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_security_group/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_security_group ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-sg' diff --git a/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml b/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml index 6cc33af3796..269677f928a 100644 --- a/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_state_config_updates ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-state-config-updates' diff --git a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml index 8e81c2fe8db..0c09a7aab3e 100644 --- a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_tags_and_vpc_settings ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-tags-vpc' diff --git a/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml b/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml index 129821f2ef7..a5cac742330 100644 --- a/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_termination_protection ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-temination' diff --git a/tests/integration/targets/ec2_instance_uptime/defaults/main.yml b/tests/integration/targets/ec2_instance_uptime/defaults/main.yml index 73045da6b82..a51f9bf2c7b 100644 --- a/tests/integration/targets/ec2_instance_uptime/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_uptime/defaults/main.yml @@ -1,4 +1,4 @@ --- -# defaults file for ec2_instance +# defaults file for ec2_instance_uptime ec2_instance_type: 't3.micro' ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-uptime' diff --git a/tests/integration/targets/ec2_snapshot/tasks/main.yml b/tests/integration/targets/ec2_snapshot/tasks/main.yml index 7e433472368..5feff2012c6 100644 --- a/tests/integration/targets/ec2_snapshot/tasks/main.yml +++ b/tests/integration/targets/ec2_snapshot/tasks/main.yml @@ -233,12 +233,12 @@ # Anything under 15 will trigger SnapshotCreationPerVolumeRateExceeded, # this should now be automatically handled, but pause a little anyway to # avoid being aggressive - pause: 10 + pause: 15 label: "Generate extra snapshots - {{ item }}" - name: Pause to allow creation to finish pause: - minutes: 2 + minutes: 3 # check that snapshot_ids and max_results are mutually exclusive - name: Check that max_results and snapshot_ids are mutually exclusive diff --git a/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml b/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml index b3858247831..e73afad8ff1 100644 --- a/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml +++ b/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml @@ -1,11 +1,11 @@ --- -# defaults file for ec2_instance -ec2_instance_owner: 'integration-run-{{ resource_prefix }}' -ec2_instance_type: 't3.micro' -ec2_instance_tag_TestId: '{{ resource_prefix }}-{{ inventory_hostname }}' - +# defaults file for ec2_instance tests ec2_instance_test_name: 'ec2_instance' +ec2_instance_owner: 'integration-run-{{ ec2_instance_test_name }}' +ec2_instance_type: 't3.micro' +ec2_instance_tag_TestId: '{{ resource_prefix }}-{{ ec2_instance_test_name }}' + vpc_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}' vpc_seed: '{{ resource_prefix }}-{{ ec2_instance_test_name }}' @@ -14,6 +14,11 @@ vpc_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.0.0/16' subnet_a_az: '{{ ec2_availability_zone_names[0] }}' subnet_a_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.32.0/24' subnet_a_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.32.' +subnet_a_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-a' subnet_b_az: '{{ ec2_availability_zone_names[1] }}' subnet_b_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.33.0/24' subnet_b_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.33.' +subnet_b_name: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-b' + +security_group_name_1: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-1' +security_group_name_2: '{{ resource_prefix }}-{{ ec2_instance_test_name }}-2' diff --git a/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml b/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml index c38991209e4..42d53c0e571 100644 --- a/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml +++ b/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml @@ -12,7 +12,7 @@ name: "{{ vpc_name }}" cidr_block: "{{ vpc_cidr }}" tags: - Name: Ansible ec2_instance Testing VPC + Name: "{{ vpc_name }}" tenancy: default register: testing_vpc notify: @@ -25,7 +25,7 @@ cidr: "{{ subnet_a_cidr }}" az: "{{ subnet_a_az }}" resource_tags: - Name: "{{ resource_prefix }}-subnet-a" + Name: "{{ subnet_a_name }}" register: testing_subnet_a - name: "Create secondary subnet in zone B" @@ -35,13 +35,13 @@ cidr: "{{ subnet_b_cidr }}" az: "{{ subnet_b_az }}" resource_tags: - Name: "{{ resource_prefix }}-subnet-b" + Name: "{{ subnet_b_name }}" register: testing_subnet_b - name: "create a security group with the vpc" ec2_security_group: state: present - name: "{{ resource_prefix }}-sg" + name: "{{ security_group_name_1 }}" description: a security group for ansible tests vpc_id: "{{ testing_vpc.vpc.id }}" rules: @@ -57,7 +57,7 @@ - name: "create secondary security group with the vpc" ec2_security_group: - name: "{{ resource_prefix }}-sg-2" + name: "{{ security_group_name_2 }}" description: a secondary security group for ansible tests vpc_id: "{{ testing_vpc.vpc.id }}" rules: @@ -70,3 +70,19 @@ to_port: 80 cidr_ip: 0.0.0.0/0 register: sg2 + + - name: Preserve defaults for other roles + set_fact: + # Ensure variables are available outside of this role + vpc_cidr: '{{ vpc_cidr }}' + vpc_name: '{{ vpc_name }}' + subnet_a_az: '{{ subnet_a_az }}' + subnet_a_cidr: '{{ subnet_a_cidr }}' + subnet_a_startswith: '{{ subnet_a_startswith }}' + subnet_a_name: '{{ subnet_a_name }}' + subnet_b_az: '{{ subnet_b_az }}' + subnet_b_cidr: '{{ subnet_b_cidr }}' + subnet_b_startswith: '{{ subnet_b_startswith }}' + subnet_b_name: '{{ subnet_b_name }}' + security_group_name_1: '{{ security_group_name_1 }}' + security_group_name_2: '{{ security_group_name_2 }}'