-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ec2_vol: Add check_mode support to ec2_vol #509
ec2_vol: Add check_mode support to ec2_vol #509
Conversation
@mandar242 this PR contains the following merge commits: Please rebase your branch to remove these commits. |
86ebf55
to
46f327c
Compare
recheck |
1 similar comment
recheck |
recheck |
recheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mandar242. What you have here looks good but could you please add some tests for different update actions? As the code flows now it should be fine, but for example module_utils.ec2.ensure_ec2_tags
doesn't handle check_mode
so if the logic ever got changed around we could miss that if there wasn't a test for tag changes under check_mode
.
Not entirely true, it's handled down in remove_ec2_tags and add_ec2_tags which will return "changed" but not make the change in check mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandar242 Thank you very much for working on this. I have only one last suggestion. Could you please use as example the tests run without the check mode and add more tests for the check mode in an analogous way (where it makes sense)? We want to be sure the check mode covers all the functionalities.
To follow up on what @alinabuzachis said: where possible, the best way to write the tests is for each 'change' that you make within the tests you run the change 4 times:
This can get rather long and repetitive for the more complex modules, but catches a lot of annoying little bugs and when someone's reviewing the code it's much easier to see that things like idempotency and check mode are behaving consistently within the module. I'll often label each test as
|
recheck |
recheck @tremble saw your ping in irc after you'd gone. That's a really interesting CI failure that I don't know about! Let's see if it happens again? |
recheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandar242 Thank you. LGTM!
if module.check_mode: | ||
module.exit_json(changed=True, msg='Would have created a volume if not in check mode.') | ||
|
||
if volume is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor niggle for the future (not worth blocking this over). I find it's less likely to lead to weird edge cases if you make your check_mode tests as late as possible. Here for example, if someone re-wrote the flow of main() and you'd sometimes be passed a volume, performing the check_mode test before you test volume would result in broken idempotency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
SUMMARY
Add check_mode support to ec2_vol.
ISSUE TYPE
COMPONENT NAME
ec2_vol