Skip to content
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

Merged
merged 5 commits into from
Oct 31, 2017
Merged

ios_logging: Fix some smaller issues, add unit test #32321

merged 5 commits into from
Oct 31, 2017

Conversation

paneu
Copy link
Contributor

@paneu paneu commented Oct 29, 2017

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
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.

@ansibot
Copy link
Contributor

ansibot commented Oct 29, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests. labels Oct 29, 2017
@ansibot
Copy link
Contributor

ansibot commented Oct 29, 2017

The test ansible-test sanity --test pep8 [?] failed with the following error:

test/units/modules/network/ios/test_ios_logging.py:59:1: W391 blank line at end of file

The test ansible-test sanity --test pylint [?] failed with the following error:

test/units/modules/network/ios/test_ios_logging.py:59:0: trailing-newlines Trailing newlines

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 29, 2017
@gundalow
Copy link
Contributor

@paneu This is great, thank you. Will review and look at backporting to stable-2.4.
If were not aware, feel free to join #ansible-network on Freenode IRC.

@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Oct 29, 2017
@trishnaguha trishnaguha self-assigned this Oct 29, 2017
@@ -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.
Copy link
Member

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))
Copy link
Member

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.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 30, 2017
@@ -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)
Copy link
Member

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):

@bcoca bcoca added this to Nominated in 2.4.x Blocker List Oct 30, 2017
…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.
@paneu
Copy link
Contributor Author

paneu commented Oct 30, 2017

I have tried to incorporate your feedback. Please let me know whether there are still issues with the code.

@trishnaguha trishnaguha merged commit 53fead7 into ansible:devel Oct 31, 2017
@trishnaguha trishnaguha moved this from Nominated to Nice to have in 2.4.x Blocker List Oct 31, 2017
@abadger
Copy link
Contributor

abadger commented Nov 1, 2017

Cherry-picked to stable-2.4 for 2.4.2beta2

abadger pushed a commit that referenced this pull request Nov 1, 2017
* 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)
@abadger abadger moved this from Nice to have to Done in 2.4.2 in 2.4.x Blocker List Nov 1, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@dagwieers dagwieers added ios Cisco IOS community cisco Cisco technologies labels Feb 27, 2019
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. cisco Cisco technologies ios Cisco IOS community module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. networking Network category support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests.
Projects
No open projects
2.4.x Blocker List
Done in 2.4.2
Development

Successfully merging this pull request may close these issues.

None yet

6 participants