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

Issue #3754: Modify AAA config commands to use pass_db decorator #3755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anders-nexthop
Copy link

What I did

Currently all AAA config commands create a new ConfigDBConnector object for every operation. This doesn't interact well with the pytest mock infrastructure used in the unit tests. I changed the AAA config commands to accept a ConfigDBConnector from the top-level command, which follows the standard pattern used by other config commands (such as those in sonic-utilities/config/main.py).

I fixed up tests so that they actually test config functionality, instead of manually manipulating the mock DB to return valid show results.

Some expected output in tests was not in line with actual product output. I updated the expected output in these cases.

fixes #3754

How I did it

Convert AAA config commands to use the pass_db decorator pattern, which is used by most other commands in sonic-utilities. This decorator allows the ConfigDBConnector to be passed in directly.

I went through sonic-utilities/tests/aaa_test.py and sonic-utilities/tests/radius_test.py, and removed all instances where manual database manipulation was being done unnecessarily (such as here, for example).

How to verify it

Removing the db modification from the AAA tests causes them to fail before my changes. After my changes, all AAA tests pass.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

linux-foundation-easycla bot commented Feb 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: anders-nexthop / name: Anders Linn (6d966c8)

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@anders-nexthop anders-nexthop marked this pull request as ready for review February 7, 2025 23:18
@anders-nexthop anders-nexthop marked this pull request as draft February 7, 2025 23:57
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

* Convert AAA config comamnds to use the pass_db decorator pattern
* Remove manual db manipulation from AAA/Radius tests so that they test
  actual config command behavior
* Modify some expected test output based on what config commands
  actually produce
* Add/update test cases which were missing coverage
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@anders-nexthop anders-nexthop marked this pull request as ready for review February 8, 2025 03:51
@anders-nexthop
Copy link
Author

I filled in some missing test cases to pass the code coverage threshold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] AAA tests do not handle mock DB connection correctly
2 participants