Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Jun 22, 2021
1 parent d12b4bd commit 00f8c5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
22 changes: 10 additions & 12 deletions plugins/modules/ec2_vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,10 @@ def update_volume(module, ec2_conn, volume):
target_multi_attach = module.params.get('multi_attach')
multi_attach_changed = False
if target_multi_attach is not None:
if "io1" in [target_type, original_type] or "io2" in [target_type, original_type]:
original_multi_attach = volume['multi_attach_enabled']
if target_multi_attach != original_multi_attach:
multi_attach_changed = True
req_obj['MultiAttachEnabled'] = target_multi_attach
else:
module.warn("multi_attach is supported with io1 and io2 volumes only.")
original_multi_attach = volume['multi_attach_enabled']
if target_multi_attach != original_multi_attach:
multi_attach_changed = True
req_obj['MultiAttachEnabled'] = target_multi_attach

changed = iops_changed or size_changed or type_changed or throughput_changed or multi_attach_changed

Expand Down Expand Up @@ -489,11 +486,8 @@ def create_volume(module, ec2_conn, zone):

if throughput:
additional_params['Throughput'] = int(throughput)
if multi_attach is True:
if volume_type not in ("io1", "io2"):
module.warn("multi_attach is supported with io1 and io2 volumes only.")
else:
additional_params['MultiAttachEnabled'] = multi_attach
if multi_attach is not None:
additional_params['MultiAttachEnabled'] = multi_attach

create_vol_response = ec2_conn.create_volume(
aws_retry=True,
Expand Down Expand Up @@ -721,6 +715,7 @@ def main():
iops = module.params.get('iops')
volume_type = module.params.get('volume_type')
throughput = module.params.get('throughput')
multi_attach = module.params.get('multi_attach')

if state == 'list':
module.deprecate(
Expand Down Expand Up @@ -757,6 +752,9 @@ def main():
if throughput < 125 or throughput > 1000:
module.fail_json(msg='Throughput values must be between 125 and 1000.')

if multi_attach is True and volume_type not in ('io1', 'io2'):
module.fail_json(msg='multi_attach is only supported for io1 and io2 volumes.')

# Set changed flag
changed = False

Expand Down
14 changes: 7 additions & 7 deletions tests/integration/targets/ec2_vol/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,11 @@

- name: test create a new gp3 volume
ec2_vol:
volume_size: 7
volume_size: 70
zone: "{{ availability_zone }}"
volume_type: gp3
throughput: 130
iops: 300
iops: 3001
name: "GP3-TEST-{{ resource_prefix }}"
tags:
ResourcePrefix: "{{ resource_prefix }}"
Expand All @@ -581,11 +581,11 @@
- "'create_time' in gp3_volume.volume"
- "'id' in gp3_volume.volume"
- "'size' in gp3_volume.volume"
- gp3_volume.volume.size == 7
- gp3_volume.volume.size == 70
- "'volume_type' in gp3_volume"
- gp3_volume.volume_type == 'gp3'
- "'iops' in gp3_volume.volume"
- gp3_volume.volume.iops == 300
- gp3_volume.volume.iops == 3001
- "'throughput' in gp3_volume.volume"
- gp3_volume.volume.throughput == 130
- "'tags' in gp3_volume.volume"
Expand Down Expand Up @@ -628,7 +628,7 @@

- name: increase throughput
ec2_vol:
volume_size: 7
volume_size: 70
zone: "{{ availability_zone }}"
volume_type: gp3
throughput: 131
Expand All @@ -647,11 +647,11 @@
- "'create_time' in gp3_volume.volume"
- "'id' in gp3_volume.volume"
- "'size' in gp3_volume.volume"
- gp3_volume.volume.size == 7
- gp3_volume.volume.size == 70
- "'volume_type' in gp3_volume"
- gp3_volume.volume_type == 'gp3'
- "'iops' in gp3_volume.volume"
- gp3_volume.volume.iops == 300
- gp3_volume.volume.iops == 3001
- "'throughput' in gp3_volume.volume"
- gp3_volume.volume.throughput == 131

Expand Down

0 comments on commit 00f8c5e

Please sign in to comment.