Skip to content

Commit

Permalink
tests: split up ec2_instance (#979)
Browse files Browse the repository at this point in the history
tests: split up ec2_instance

Use on target per sub-test to have a better control on the global execution
time and simplify the troubleshooting.

Reviewed-by: Mark Chappell <None>
  • Loading branch information
goneri authored Aug 29, 2022
1 parent 9e7ae6c commit 08746a1
Show file tree
Hide file tree
Showing 78 changed files with 496 additions and 419 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/979-ec2_instance_tests_split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- "ec2_instance tests - ec2_instance integration test is now splitted up in several independent tests (https://github.com/ansible-collections/amazon.aws/pull/979)."
20 changes: 0 additions & 20 deletions tests/integration/targets/ec2_instance/inventory

This file was deleted.

40 changes: 0 additions & 40 deletions tests/integration/targets/ec2_instance/main.yml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions tests/integration/targets/ec2_instance/runme.sh

This file was deleted.

5 changes: 5 additions & 0 deletions tests/integration/targets/ec2_instance_block_devices/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for ec2_instance
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-block-devices'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_ec2_instance_env
vars:
ec2_instance_test_name: block_devices
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
- block:

- module_defaults:
group/aws:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
block:
- name: "New instance with an extra block device"
ec2_instance:
state: running
Expand Down Expand Up @@ -103,12 +108,3 @@
- block_device_instances_gp3.spec.BlockDeviceMappings[0].Ebs.VolumeType == 'gp3'
- block_device_instances_gp3.spec.BlockDeviceMappings[0].Ebs.VolumeSize == 20
- block_device_instances_gp3.spec.BlockDeviceMappings[0].Ebs.Throughput == 500

always:
- name: "Terminate block_devices instances"
ec2_instance:
state: absent
filters:
"tag:TestId": "{{ ec2_instance_tag_TestId }}"
wait: yes
ignore_errors: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for ec2_instance
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-instance-checkmode'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_ec2_instance_env
vars:
ec2_instance_test_name: check_mode
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
- block:
- module_defaults:
group/aws:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
block:
- name: "Make basic instance"
ec2_instance:
state: present
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/targets/ec2_instance_cpu_options/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for ec2_instance
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-cpu-options'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_ec2_instance_env
vars:
ec2_instance_test_name: cpu_options
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
- block:
- module_defaults:
group/aws:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
block:
- name: "create t3.nano instance with cpu_options"
ec2_instance:
state: present
Expand Down Expand Up @@ -77,12 +83,3 @@
assert:
that:
- "{{ checkmode_instance_fact.instances | length }} == 0"

always:
- name: "Terminate cpu_options instances"
ec2_instance:
state: absent
filters:
"tag:TestId": "{{ ec2_instance_tag_TestId }}"
wait: yes
ignore_errors: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for ec2_instance
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-default-vpc'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_ec2_instance_env
vars:
ec2_instance_test_name: default_vpc
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
- block:
- module_defaults:
group/aws:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
block:
- name: "Make instance in a default subnet of the VPC"
ec2_instance:
state: present
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/targets/ec2_instance_ebs_optimized/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for ec2_instance
ec2_instance_type: 't3.micro'
ec2_instance_tag_TestId: '{{ resource_prefix }}-ebs-optimized'
Loading

0 comments on commit 08746a1

Please sign in to comment.