Skip to content

Commit 7e93e7b

Browse files
huruinanmeta-codesync[bot]
authored andcommitted
Ladakh800bcls: fixup HwSwitchMatcher exception in AgentNeighborTest
Summary: Desciption: AgentNeighborTest* failed with following exception C++ exception with description "HwSwitchMatcher::switchId api must be called only when there is a single switchId" thrown in the test body. Root Cause: On multi NPU platform, in function facebook::fboss::utility::NeighborInfo getNeighborInfo, when calling following auto switchId = ensemble.getSw() ->getScopeResolver() ->scope(ensemble.masterLogicalPortIds()) .switchId(); scope(ensemble.masterLogicalPortIds()) returns an array, so can't get switchId(). Fix: As this function is designed to retrieve the current state of neighbor entry for a specific interfaceId directly from the ASIC, so changed to get the switchId based on the interfaceId information. Reviewed By: daiwei1983 Differential Revision: D90621646 fbshipit-source-id: 1e9f785b2da532c46052c9fe8d1ee607dd791cef
1 parent 7468cad commit 7e93e7b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fboss/agent/test/agent_hw_tests/AgentNeighborTests.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ facebook::fboss::utility::NeighborInfo getNeighborInfo(
3636
const facebook::fboss::InterfaceID& interfaceId,
3737
const folly::IPAddress& ip,
3838
facebook::fboss::AgentEnsemble& ensemble) {
39-
auto switchId = ensemble.getSw()
40-
->getScopeResolver()
41-
->scope(ensemble.masterLogicalPortIds())
42-
.switchId();
39+
auto state = ensemble.getProgrammedState();
40+
auto intf = state->getInterfaces()->getNodeIf(interfaceId);
41+
if (!intf) {
42+
throw facebook::fboss::FbossError("no such interface ", interfaceId);
43+
}
44+
auto switchId =
45+
ensemble.getSw()->getScopeResolver()->scope(intf, state).switchId();
4346
auto client = ensemble.getHwAgentTestClient(switchId);
4447
facebook::fboss::IfAndIP neighbor;
4548
neighbor.interfaceID() = interfaceId;

0 commit comments

Comments
 (0)