Skip to content

Commit

Permalink
Update test to account for new default on purge_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Jul 6, 2022
1 parent 54129ed commit 6fc9397
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/integration/targets/ec2_ami/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@
name: '{{ ec2_ami_name }}_ami'
tags:
New: Tag
purge_tags: no
register: result

- name: assert a tag was added
Expand All @@ -464,7 +465,6 @@
name: '{{ ec2_ami_name }}_ami'
tags:
New: Tag
purge_tags: yes
register: result

- name: assert a tag was removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
Another: thing
purge_tags: false
security_groups: "{{ sg.group_id }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
instance_type: "{{ ec2_instance_type }}"
Expand All @@ -109,7 +110,6 @@
state: present
name: "{{ resource_prefix }}-test-basic-vpc-create"
image_id: "{{ ec2_ami_id }}"
purge_tags: true
tags:
TestId: "{{ ec2_instance_tag_TestId }}"
Another: thing
Expand Down
44 changes: 38 additions & 6 deletions tests/integration/targets/ec2_vol/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
"Title Case": 'Hello Cruel World ❤️'
CamelCase: 'SimpleCamelCase ❤️'
snake_case: 'simple_snake_case ❤️'
purge_tags: false
register: new_vol_attach_result

- name: check task return attributes
Expand All @@ -380,6 +381,41 @@
- new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix
- new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh'

- name: change some tag values
ec2_vol:
instance: "{{ test_instance.instance_ids[0] }}"
id: "{{ new_vol_attach_result.volume.id }}"
device_name: /dev/sdh
volume_size: 1
volume_type: standard
tags:
"lowercase spaced": 'hello cruel world ❤️'
"Title Case": 'Hello Cruel World ❤️'
snake_case: 'simple_snake_case ❤️'
ResourcePrefix: "{{ resource_prefix }}"
purge_tags: true
register: new_vol_attach_result

- name: check task return attributes
assert:
that:
- new_vol_attach_result.changed
- "'volume_id' in new_vol_attach_result"
- new_vol_attach_result.volume_id == "{{ new_vol_attach_result.volume_id }}"
- "'attachment_set' in new_vol_attach_result.volume"
- "'create_time' in new_vol_attach_result.volume"
- "'id' in new_vol_attach_result.volume"
- "'size' in new_vol_attach_result.volume"
- new_vol_attach_result.volume.size == 1
- "'volume_type' in new_vol_attach_result"
- new_vol_attach_result.volume_type == 'standard'
- "'tags' in new_vol_attach_result.volume"
- (new_vol_attach_result.volume.tags | length) == 4
- new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️'
- new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️'
- new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️'
- new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix

- name: create a volume from a snapshot and attach to the instance (check_mode)
ec2_vol:
instance: "{{ test_instance.instance_ids[0] }}"
Expand Down Expand Up @@ -482,13 +518,11 @@
- changed_gp3_volume.volume.iops == 3000
# Ensure our tags are still here
- "'tags' in changed_gp3_volume.volume"
- (changed_gp3_volume.volume.tags | length) == 6
- (changed_gp3_volume.volume.tags | length) == 4
- new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️'
- new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️'
- new_vol_attach_result.volume.tags["CamelCase"] == 'SimpleCamelCase ❤️'
- new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️'
- new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix
- new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh'

- name: volume must be from type gp3 (idempotent)
ec2_vol:
Expand Down Expand Up @@ -518,13 +552,11 @@
- changed_gp3_volume.volume.iops == 3000
- "'throughput' in changed_gp3_volume.volume"
- "'tags' in changed_gp3_volume.volume"
- (changed_gp3_volume.volume.tags | length) == 6
- (changed_gp3_volume.volume.tags | length) == 4
- new_vol_attach_result.volume.tags["lowercase spaced"] == 'hello cruel world ❤️'
- new_vol_attach_result.volume.tags["Title Case"] == 'Hello Cruel World ❤️'
- new_vol_attach_result.volume.tags["CamelCase"] == 'SimpleCamelCase ❤️'
- new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️'
- new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix
- new_vol_attach_result.volume.tags["Name"] == '{{ resource_prefix }} - sdh'

- name: re-read volume information to validate new volume_type
ec2_vol_info:
Expand Down

0 comments on commit 6fc9397

Please sign in to comment.