Skip to content

Commit 0818bad

Browse files
Shrikrishna (Shri) Kharemeta-codesync[bot]
authored andcommitted
Util to verify QSFP run state
Summary: As titled. Refactoring code in MultiNodeAgentVoqSwitchTests.cpp, lib/multinode for better maintainabilty, readability. The old code will be removed post this refactor. Reviewed By: jasmeetbagga Differential Revision: D86049336 Privacy Context Container: L1297311 fbshipit-source-id: ddc4cdf8eb37312d75a84d5e40dc45526d1a28dd
1 parent a483e8d commit 0818bad

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

fboss/agent/test/agent_multinode_tests/AgentMultiNodeUtils.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ bool verifySwSwitchRunState(
2525
true /* retry on exception */);
2626
}
2727

28+
bool verifyQsfpServiceRunState(
29+
const std::string& switchName,
30+
const QsfpServiceRunState& expectedQsfpRunState) {
31+
auto qsfpServiceRunStateMatches = [switchName, expectedQsfpRunState]() {
32+
auto gotQsfpServiceRunState = getQsfpServiceRunState(switchName);
33+
return gotQsfpServiceRunState == expectedQsfpRunState;
34+
};
35+
36+
// Thrift client queries will throw exception while QSFP is initializing.
37+
// Thus, continue to retry while absorbing exceptions.
38+
return checkWithRetryErrorReturn(
39+
qsfpServiceRunStateMatches,
40+
30 /* num retries */,
41+
std::chrono::milliseconds(5000) /* sleep between retries */,
42+
true /* retry on exception */);
43+
}
44+
2845
void logNdpEntry(
2946
const std::string& rdsw,
3047
const facebook::fboss::NdpEntryThrift& ndpEntry) {

fboss/agent/test/agent_multinode_tests/AgentMultiNodeUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ namespace facebook::fboss::utility {
1818
bool verifySwSwitchRunState(
1919
const std::string& switchName,
2020
const SwitchRunState& expectedSwitchRunState);
21+
bool verifyQsfpServiceRunState(
22+
const std::string& switchName,
23+
const QsfpServiceRunState& expectedQsfpRunState);
2124

2225
std::vector<NdpEntryThrift> getNdpEntriesOfType(
2326
const std::string& rdsw,

0 commit comments

Comments
 (0)