-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
ios_logging: Fix some smaller issues, add unit test #32321
Conversation
The test
The test
|
@paneu This is great, thank you. Will review and look at backporting to |
@@ -47,7 +47,8 @@ | |||
size: | |||
description: | |||
- Size of buffer. The acceptable value is in range from 4096 to | |||
4294967295 bytes. | |||
4294967295 bytes. If value of C(dest) is I(buffered), the default value | |||
is 4096. |
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.
you can have a key named default
instead.
This should look like the following:
size:
description:
- Size of buffer. The acceptable value is in range from 4096 to
4294967295 bytes.
default: 4096
self.execute_module(changed=True, commands=commands) | ||
|
||
def test_ios_logging_buffer_size_changed_explicit(self): | ||
set_module_args(dict(dest='buffered', size=4096)) |
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.
A different input is suggested for the size for the explicit test here to make sure it works as expected.
@@ -297,7 +298,7 @@ def map_params_to_obj(module, required_if=None): | |||
|
|||
if module.params['dest'] == 'buffered': | |||
if not module.params['size']: | |||
module.params['size'] = str(4096) | |||
module.params['size'] = int(4096) |
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.
Converting the value to int
here would cause idempotence issue.
Rather you can convert the value to int
inside the function validate_size
itself to make the default value work.
This would be the consistent way to do it:
def validate_size(value, module):
if value:
- if not int(4096) <= value <= int(4294967295):
+ if not int(4096) <= int(value) <= int(4294967295):
…size When the size parameter is not configured while configuring the buffered destination, a traceback occurs due to the fact that validate_size expects the parameter to be an int. Explicitely converting value to int makes the check work for every case.
Update the documentation of the size paramter to reflect the current behaviour of setting a default of 4096 for the buffered dest.
Add unit test for ios_logging testing the behaviour clarified in the previous commits.
I have tried to incorporate your feedback. Please let me know whether there are still issues with the code. |
Cherry-picked to stable-2.4 for 2.4.2beta2 |
* ios_logging: Fix typo in documentation * ios_logging: Fix traceback when setting buffered destination without size When the size parameter is not configured while configuring the buffered destination, a traceback occurs due to the fact that validate_size expects the parameter to be an int. Explicitely converting value to int makes the check work for every case. * ios_logging: Update size parameter documentation Update the documentation of the size paramter to reflect the current behaviour of setting a default of 4096 for the buffered dest. * ios_logging: Add unit test Add unit test for ios_logging testing the behaviour clarified in the previous commits. * ios_logging: Fix python 2.6 compliance (cherry picked from commit 53fead7)
SUMMARY
ISSUE TYPE
COMPONENT NAME
ios_logging
ADDITIONAL INFORMATION
Fix smaller issues with ios_logging (e.g. documentation). Also add a unit test for testing for the bug fixed.