Skip to content

Commit

Permalink
tests: split up ec2_instance
Browse files Browse the repository at this point in the history
Use on target per sub-test to have a better control on the global execution
time and simplify the troubleshooting.
  • Loading branch information
goneri committed Aug 25, 2022
1 parent 9e7ae6c commit 36f887a
Show file tree
Hide file tree
Showing 82 changed files with 802 additions and 156 deletions.
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.

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# duration: 25
slow

cloud/aws
ec2_instance_info
ec2_instance

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: "1.20.30"
boto3_version: 1.20.30
- role: setup_ec2_instance_env
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
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,21 @@
---
# 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 }}'

vpc_name: '{{ resource_prefix }}-vpc'
vpc_seed: '{{ resource_prefix }}'
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_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.'

first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: 1.20.30
- role: setup_ec2_instance_env
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,21 @@
---
# 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 }}'

vpc_name: '{{ resource_prefix }}-vpc'
vpc_seed: '{{ resource_prefix }}'
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_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.'

first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: 1.20.30
- role: setup_ec2_instance_env
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
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,21 @@
---
# 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 }}'

vpc_name: '{{ resource_prefix }}-vpc'
vpc_seed: '{{ resource_prefix }}'
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_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.'

first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: 1.20.30
- role: setup_ec2_instance_env
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,21 @@
---
# 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 }}'

vpc_name: '{{ resource_prefix }}-vpc'
vpc_seed: '{{ resource_prefix }}'
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_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.'

first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: 1.20.30
- role: setup_ec2_instance_env
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 EBS optimized instance in the testing subnet of the test VPC"
ec2_instance:
state: present
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/targets/ec2_instance_env_cleanup/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,21 @@
---
# 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 }}'

vpc_name: '{{ resource_prefix }}-vpc'
vpc_seed: '{{ resource_prefix }}'
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_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.'

first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
# Zuul resource prefixes are very long, and IAM roles can only be 64 characters
unique_id: "{{ resource_prefix | hash('md5') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this just makes sure they're in the right place
dependencies:
- role: setup_ec2_facts
- role: setup_botocore_pip
vars:
boto3_version: 1.20.30
- role: setup_ec2_instance_env
Loading

0 comments on commit 36f887a

Please sign in to comment.