Fix in 'nbrhosts' pytest fixture#1594
Fix in 'nbrhosts' pytest fixture#1594yvolynets-mlnx wants to merge 2 commits intosonic-net:masterfrom
Conversation
Signed-off-by: Yuriy Volynets <[email protected]>
Signed-off-by: Yuriy Volynets <[email protected]>
|
This pull request fixes 1 alert when merging bed8be4 into 2254d9b - view on LGTM.com fixed alerts:
|
|
when we run pytest, we specify the inventory option, such as what if the ansible/inventory file is not available on the disk. it will give errors. |
| 'common.plugins.psu_controller', | ||
| 'common.plugins.sanity_check') | ||
|
|
||
| VEOS_INVENTORY = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../ansible/veos")) |
There was a problem hiding this comment.
it does not look like a correct approach to hardcode another inventory file.
"are you saying you need hardcode another inventory file?" So this is a fix for current implementation, which does not change anything except extends "nbrhosts" fixture. "if you need to run the test on both testbed, why not combine two inventory files?" So how do you suggest to proceed with this fix? |
|
by design ansible use one inventory file, why not stick to that design guide. another way is to introduce dynamic inventory and then basically introduce another level of abstraction to allow us to define whatever inventory format we want. |
|
@yvolynets-mlnx I am with @lguohan , I don't fully understand the need of using more than 1 inventory file. Why VMs were defined in another inventory? Are these VMs serving another test in the second inventory? If so, are these VMs the same set of VMs supporting another DUT in another inventory? If these 2 sets of VMs just looks same but they are different instances, they the information can be duplicated into 2 inventories. If they are the same set of VMs, then I think we should merge the 2 inventory files. There must be reason that you didn't take merging inventory approach. Can you elaborate the difficulty of doing so? |
|
I agree that hard code another inventory file in conftest.py is not a good design.
But regarding the VMs definition, it resides in two example inventory files:
And in So, I have couple of questions:
|
|
@yxieca
@yxieca @lguohan @wangxin |
|
@yvolynets-mlnx without investigating further. I suspect following: inventory 'inventory' defined some VM information overlapping with the other inventory test, I think in this case veos.vtb. I don't think merging would be a good idea. The reason for the 2 inventories to exist, is that 'inventory' is intended for physical DUTs. 'veos.vtb' is intended for VS tests. In the past, I noticed that veos.vtb defined duplicate VM names collides into another inventory file we used internally. after addressing the issue of reading proper inventory file. this issue was addressed. I think what you are facing here, is that veos.vtb is lack of certain definition (e.g. VM), and these definition happen to look the same as what was in 'inventory' but they are different instances. I suggest you add whatever you need into the veos.vtb and not changing 'inventory'. We do need to find a non-intrusive way to rename veos.vtb resources to not collide with physical testbeds in the future. Please let me know if my guess is different from reality. |
|
The inventory file was designed for supporting a specific test, support dynamic inventory file injection seems not much help here. In other hand, the playbook version tests are not using ansible inventory file to access vmhost, instead they use mgmtip and user/pwd to access directly, that's why no same failure happens on original tests. If so, we can have a script to build a complete inventory file from template, and make a pre-test script to generate the full inventory file before do testing instead of combine them in test runtime. In my mind, the inventory file is a kind of "input" rather than code. It is make sense to get a false result when you put false input. I vote for fixing the inventory file. |
|
I got another idea of fixing the issue of DUT host and VM host info in different inventory files. Ansible supports accepting multiple inventory files. But pytest-ansible always passes a single string to argument With this fixture, we can pass comma separated inventory files to --inventory CLI argument. For example: The If we use this approach, fixture conn_graph_facts in tests/common/fixtures/conn_graph_facts.py need to be refactored. Because this fixture assumes single inventory file is used, and uses that inventory file name to look up corresponding lab_conn_graph.xml file from ansible/group_vars/all/inv_mapping.json. |
Nice! |
Idea is good. But in such case there is a need to some how distinguish which of the provided inventory files should be used for: SonicHost, EosHost and another possible hosts? |
|
If use my proposed approach, the InventoryManager object created by pytest-ansible will accept multiple inventory files as sources. Then it should be able to "merge" the inventory files. When we create SonicHost, EosHost or other hosts from ansible_adhoc, we do not need to care about in which inventory file the host is defined. |
In such case it is good approach, I will update code with this new approach. |
|
@yvolynets-mlnx Actually, I have already created a PR using the approach: #1645 |
|
Do we still need this change? |
Let me check that this #1645 PR fixed this issue, then I will close it. |
Including below commits: 36f7332 2021-01-14 | modified ERR log to NOTICE log for FDB notification failure after VLAN delete (sonic-net#1595) [madhanmellanox] c21c883 2021-01-12 | [ci]: download artifacts from master branch build (sonic-net#1597) [lguohan] a1d03a4 2021-01-12 | [fgnhgorch] Match mode changes for Fine Grained ECMP (sonic-net#1565) [anish-n] 1b65f3d 2021-01-12 | [ci]: use sonicbld pool (sonic-net#1594) [lguohan] 48ae866 2021-01-12 | [pfcwd] Update PFC storm detection logic for Mellanox platforms (sonic-net#1586) [Volodymyr Samotiy] 850001f 2021-01-12 | [FPMSYNCD] Evpn/Vxlan related changes to support FRR7.5(sonic-net#1585) [KISHORE KUNAL] 64ca9bb 2021-01-12 | [ci]: only copy artifacts when build is successful (sonic-net#1590) [lguohan] 17d0dae 2021-01-11 | [Fdborch] Fix for arm compilation (sonic-net#1592) [Prince Sunny] 693a02c 2021-01-08 | [gearbox] Add support for "hwinfo" field (sonic-net#1547) [Baptiste Covolato] 7e3b2c6 2021-01-09 | [Evpn Warmreboot] Added Dependancy check logic in VrfMgr (sonic-net#1466) [nkelapur] a960e2e 2021-01-09 | [Orchagent]: FdbOrch changes for EVPN VXLAN (sonic-net#1275) [Pankaj Jain] 097cfda 2021-01-08 | [swss test] update setup guide for swss tests (sonic-net#1582) [Ying Xie] b42253a 2021-01-05 | Fix for armhf build (sonic-net#1580) [Qi Luo] d8c1465 2021-01-05 | [dvs] Update/disable DVS tests with new FRR 7.5 behavior (sonic-net#1579) [Danny Allen] f6c7422 2021-01-05 | ASIC internal temperature sensors support (sonic-net#1517) [Santhosh Kumar T] 0aa9ef2 2021-01-01 | Simply by auto iterator type, because we will tune the return types of library functions (sonic-net#1577) [Qi Luo] 773238b 2020-12-31 | [build]: Fix format string for size_t (sonic-net#1576) [Qi Luo] 7ba4e43 2020-12-30 | [fgnhgorch] add warm reboot support for fgnhg (sonic-net#1538) [weixchen1215] 4cf6617 2020-12-30 | [ci]: add build for arm64 and armhf (sonic-net#1572) [lguohan] 6ebc0ed 2020-12-29 | [ci]: add azure-pipeline for amd64 (sonic-net#1571) [lguohan] e32b9d0 2020-12-29 | [FDBSYNCD] Added pytest for fdbsyncd (sonic-net#1560) [KISHORE KUNAL] a43f6be 2020-12-30 | [crm] Add support for snat, dnat and ipmc crm resources (sonic-net#1511) [Prabhu Sreenivasan] 7fc3888 2020-12-29 | PY Test script for EVPN L3 VxLAN (sonic-net#1330) [Tapash Das] 6eb36d9 2020-12-27 | vlanmgr changes related to EVPN VxLan warmboot (sonic-net#1460) [anilkpan] Signed-off-by: Guohan Lu <[email protected]>
…nic-net#7563) * [202012][swss/swss-common/utilities/platform-daemons] Update submodule sonic-swss - [flex-counters] Delay flex counters stats init for faster boot time [202012] (sonic-net#1736) sonic-swss-common - [swig] allow threads (sonic-net#477) sonic-utilities - [sfpshow] Gracefully handle improper 'specification_compliance' field (sonic-net#1594) sonic-platform-daemons - [xcvrd] Change the y_cable presence logic to use "mux_cable" table as identifier from Config DB (sonic-net#176) - [xcvrd] Enhance Media Settings (sonic-net#177) Signed-off-by: Danny Allen <[email protected]>
97d971372fac773b98d46bb8f800df7b845e518e (HEAD -> 201911, origin/201911) [sfpshow] Gracefully handle improper 'specification_compliance' field (sonic-net#1594) (sonic-net#1729) 2099c73cea81ff4524e680b6f9335c0b0f13b94e [CLI] Implement null_route_helper script (sonic-net#1740) b56659175986fe0e5b82c6bd6b3dde163164777b [minigraph][port_config] Consume port_config.json while reloading minigraph (sonic-net#1725) e840c42da2a40db2bf993672271f6b75c51c426f Change the method name to align with master, reduce diverge issue (sonic-net#1703) Signed-off-by: Abhishek Dosi <[email protected]>
Signed-off-by: Yuriy Volynets [email protected]
Description of PR
Summary: Fix "nbrhosts" fixture to use inventory file with defined VMs
Fixes # (issue)
Type of change
Approach
How did you do it?
During run tests which uses "nbrhosts" fixture it was observed the following error:
Description:
For now main inventory file which is used for test cases run is located in "ansible/inventory" file.
But also for now Virtual Machine hosts are defined in separate "ansible/veos" inventory file.
So to have possibility in test cases to simultaneously use devices like DUT/Fanouts and VMs there should be possibility to specify which inventory file to use for specific device type.
Base item what is used for create interface to the devices is pytest-ansible fixture "ansible_adhoc".
It uses inventory file which is specified by "--inventory" option.
For now as main inventory what is passed for test case run is "ansible/inventory", so it was added global variable which points to another inventory with defined VMs.
Later this can be enhanced by combining inventory files or by adding pytest option for passing specific inventory files.
How did you verify/test it?
Tested on the local setup.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation