Enable caching of host and group ansible variables#2873
Merged
wangxin merged 1 commit intosonic-net:masterfrom Jan 29, 2021
wangxin:more-cache-pr
Merged
Enable caching of host and group ansible variables#2873wangxin merged 1 commit intosonic-net:masterfrom wangxin:more-cache-pr
wangxin merged 1 commit intosonic-net:masterfrom
wangxin:more-cache-pr
Conversation
Contributor
|
@wangxin - can you expedite merging this PR as would like to use that in my optimization for pytest_generate_test PR as well. |
Collaborator
Author
|
Force pushed to resolve conflicts. |
Collaborator
|
retest this, please |
bingwang-ms
approved these changes
Jan 28, 2021
Loading variables from inventory files also takes time. Caching them could futher improve testing performance. This change enabled caching of below items: * Ansible InventoryManager * Ansible VariableManager * Host visible variables * Group visible variables * Test server variables Another change is to use a lock to guard writing to cache. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
3 tasks
wangxin
pushed a commit
that referenced
this pull request
Feb 6, 2021
…xtures (#2811) What is the motivation for this PR? pytest_generate_tests dynamically adds enum_* fixtures that select DUTs on which the tests are to be parameterized. In order to select the DUTs on which the tests are to run, we need to get the TestbedInfo and also all variables defined in the inventory file for each DUT. These operations are time consuming - like creating TestbedInfo taking 1-9 seconds, and getting variables from inventory taking 3-5 seconds. pytest_generate_tests is called for all the tests/fixtures that needs to run in a pytest session. This was adding a long time when trying to execute many tests. This issue was reported in issue #2790 - pytest_generate_tests in tests/conftest.py takes much more time than before How did you do it? To fix this, we need to create the TestbedInfo only once, store it, and then use the stored value in the next execution of pytest_generate_tests, rather than re-creating TestbedInfo. Similary, the variables for all the DUTs in the testbed should be read once from the inventory files, stored, and the re-used in the next execution of pytest_generate_tests. PR #2789 Added caching capability to store any facts using pickle. PR #2856 added caching capability for TestbedInfo PR #2873 added caching capability for variables for DUTs in the inventory files. We use the cached TestbedInfo and DUT variables in the selection of DUTs in pytest_generate_tests. How did you verify/test it? Ran tests that use the dut selection fixtures and validated that the delay is seen only once, and not in every call to pytest_generate_tests. Validated the execution time reduced significantly when using caching when executing iface_namingmode test cases which have ~30 tests.
kazinator-arista
pushed a commit
to kazinator-arista/sonic-mgmt
that referenced
this pull request
Mar 4, 2026
…AD (sonic-net#15532) #### Why I did it Update submodule sonic-utilities to the latest HEAD ``` 50296b90 - [202012][dhcp-relay] Fix dhcp6relay counter issue (sonic-net#2866) (sonic-net#2873) (Fri Jun 30 18:08:53 2023 +0800) <Yaqiang Zhu> 160030c4 - [202012][dhcp_relay] Add "Reconfigure", "Information-Request", "Malformed" counter options (sonic-net#2844) (Sun Jun 11 20:35:30 2023 -0700) <kellyyeh> e6289ced - [vlan][dhcp_relay] Clear dhcpv6 relay counter while deleting vlan (sonic-net#2852) (Fri Jun 2 18:20:21 2023 +0000) <Yaqiang Zhu> 885082ec - correctly parsing complete ipv6 vnet info (sonic-net#2827) (Thu May 25 06:01:40 2023 +0000) <Keith Lu> ``` ##### Work item tracking - Microsoft ADO 22635770
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes # (issue)
Type of change
Approach
What is the motivation for this PR?
Loading variables from inventory files is a kind of expensive operation. Caching them could further improve testing performance.
How did you do it?
This change enabled caching of below items:
Another change is to use a lock to guard writing to cache.
How did you verify/test it?
Tested the change using a test script like below:
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation