Skip to content

Commit

Permalink
Update some tests to account for 'present' now only waiting for the i…
Browse files Browse the repository at this point in the history
…nstance to exist rather than start
  • Loading branch information
tremble committed Sep 5, 2021
1 parent 79a0d75 commit 1e45fd8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
5 changes: 2 additions & 3 deletions tests/integration/targets/ec2_instance/inventory
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tests]
# Sorted fastest to slowest
checkmode_tests
termination_protection
ebs_optimized
block_devices
cpu_options
Expand All @@ -8,9 +9,7 @@ default_vpc_tests
external_resource_attach
instance_no_wait
iam_instance_role
termination_protection
tags_and_vpc_settings
checkmode_tests
security_group
state_config_updates

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/ec2_instance/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
- hosts: all
gather_facts: no
strategy: free
#serial: 10
serial: 3
roles:
- ec2_instance
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- block:
- name: "New instance with an extra block device"
ec2_instance:
state: present
state: running
name: "{{ resource_prefix }}-test-ebs-vols"
image_id: "{{ ec2_ami_id }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
Expand Down Expand Up @@ -77,7 +77,7 @@

- name: "New instance with an extra block device - gp3 volume_type and throughput"
ec2_instance:
state: present
state: running
name: "{{ resource_prefix }}-test-ebs-vols-gp3"
image_id: "{{ ec2_ami_id }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
- name: "Verify that it was not stopped."
assert:
that:
- '"{{ confirm_checkmode_stopinstance_fact.instances[0].state.name }}" != "stopped"'
- confirm_checkmode_stopinstance_fact.instances[0].state.name not in ["stopped", "stopping"]

- name: "Stop instance."
ec2_instance:
Expand All @@ -73,9 +73,8 @@
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
TestTag: "Some Value"
wait: true
register: instance_stop
until: not instance_stop.failed
retries: 10

- name: "fact stopped ec2 instance"
ec2_instance_info:
Expand All @@ -86,7 +85,7 @@
- name: "Verify that it was stopped."
assert:
that:
- '"{{ confirm_stopinstance_fact.instances[0].state.name }}" in ["stopped", "stopping"]'
- confirm_stopinstance_fact.instances[0].state.name in ["stopped", "stopping"]

- name: "Running instance in check mode."
ec2_instance:
Expand Down Expand Up @@ -158,6 +157,7 @@
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
TestTag: "Some Value"
wait: True
check_mode: yes

- name: "fact ec2 instance"
Expand All @@ -179,6 +179,7 @@
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
TestTag: "Some Value"
wait: True

- name: "fact ec2 instance"
ec2_instance_info:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cpu_options:
core_count: 1
threads_per_core: 1
wait: false
wait: true
register: instance_creation

- name: "instance with cpu_options created with the right options"
Expand All @@ -32,7 +32,7 @@
cpu_options:
core_count: 1
threads_per_core: 2
wait: false
wait: true
register: cpu_options_update
ignore_errors: yes

Expand All @@ -54,6 +54,7 @@

- name: "create t3.nano instance with cpu_options(check mode)"
ec2_instance:
state: running
name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core-checkmode"
image_id: "{{ ec2_ami_id }}"
tags:
Expand All @@ -63,6 +64,7 @@
cpu_options:
core_count: 1
threads_per_core: 1
wait: true
check_mode: yes

- name: "fact checkmode ec2 instance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ec2_eni:
state: absent
eni_id: "{{ item.id }}"
register: removed
until: removed is not failed
with_items: "{{ enis.network_interfaces }}"
ignore_errors: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- block:
- name: "Make instance with sg and termination protection enabled"
ec2_instance:
state: present
state: running
name: "{{ resource_prefix }}-test-state-param-changes"
image_id: "{{ ec2_ami_id }}"
tags:
Expand Down Expand Up @@ -111,6 +111,7 @@
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
termination_protection: False
instance_type: "{{ ec2_instance_type }}"
wait: True
register: change_params_start_result

- assert:
Expand All @@ -120,8 +121,8 @@
- '"instances" in change_params_start_result'
- '"instance_ids" in change_params_start_result'
- '"changes" in change_params_start_result'
- '"reboot_success" in change_params_start_result'
- '"reboot_failed" in change_params_start_result'
- '"start_success" in change_params_start_result'
- '"start_failed" in change_params_start_result'
- change_params_start_result.instances[0].security_groups[0].group_id == "{{ sg.group_id }}"
- change_params_start_result.changes[0].DisableApiTermination.Value == False

Expand Down

0 comments on commit 1e45fd8

Please sign in to comment.