Skip to content

Commit b78e87b

Browse files
Mohammed Al-Sanabanimeta-codesync[bot]
authored andcommitted
Dump i2c log using a flag (at end of test)
Summary: This will help us debug issues when running specific tests which fail on certain transceivers. This diff was used during debug of some Source Photonics issues Reviewed By: harshitgulati18 Differential Revision: D90719842 fbshipit-source-id: 1bf6b404bfb143ec86df90eb39e6d5549ca6d8a9
1 parent 8f6b9e2 commit b78e87b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

fboss/agent/test/link_tests/AgentEnsembleLinkTest.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ void AgentEnsembleLinkTest::TearDown() {
106106
qsfpServiceClient.get()->sync_getQsfpServiceRunState())
107107
<< "QSFP Service run state no longer active after the test";
108108

109+
// Dump the I2C Logs at the end of the test.
110+
dumpTransceiverI2cLogs(*qsfpServiceClient);
111+
109112
} catch (const std::exception& ex) {
110113
XLOG(ERR) << "Failed to call qsfp_service getStatus(). " << ex.what();
111114
}
@@ -126,6 +129,47 @@ void AgentEnsembleLinkTest::TearDown() {
126129
AgentEnsembleTest::TearDown();
127130
}
128131

132+
std::vector<std::string>
133+
AgentEnsembleLinkTest::getPrimaryPortNamesCabledPorts() {
134+
const auto& ports = getCabledPorts();
135+
std::unordered_set<std::string> uniqueSet;
136+
std::vector<std::string> result_list;
137+
for (const auto& port : ports) {
138+
auto portName =
139+
getSw()->getPlatformMapping()->getPortNameByPortId(port).value_or("");
140+
if (portName.empty()) {
141+
continue;
142+
}
143+
size_t firstSlash = portName.find('/');
144+
size_t secondSlash = portName.find('/', firstSlash + 1);
145+
if (firstSlash == std::string::npos || secondSlash == std::string::npos) {
146+
// Skip wrong input
147+
continue;
148+
}
149+
std::string firstTwoParams = portName.substr(0, secondSlash);
150+
if (uniqueSet.find(firstTwoParams) == uniqueSet.end()) {
151+
uniqueSet.insert(firstTwoParams);
152+
result_list.push_back(portName);
153+
}
154+
}
155+
return result_list;
156+
}
157+
158+
void AgentEnsembleLinkTest::dumpTransceiverI2cLogs(
159+
apache::thrift::Client<facebook::fboss::QsfpService>& qsfpServiceClient) {
160+
auto ports = getPrimaryPortNamesCabledPorts();
161+
for (auto& port : ports) {
162+
try {
163+
qsfpServiceClient.sync_dumpTransceiverI2cLog(port);
164+
} catch (const std::exception& ex) {
165+
// Passive cables may not have EEPROM, ignore the error if the i2c log
166+
// does not exist.
167+
XLOG(ERR) << "Failed to dump i2c log for port " << port << " Exception "
168+
<< ex.what();
169+
}
170+
}
171+
}
172+
129173
void AgentEnsembleLinkTest::checkAgentMemoryInBounds() const {
130174
#ifndef IS_OSS
131175
int64_t memUsage = facebook::Proc::getMemoryUsage();

fboss/agent/test/link_tests/AgentEnsembleLinkTest.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "fboss/agent/test/link_tests/gen-cpp2/link_test_production_features_types.h"
1010
#include "fboss/agent/types.h"
1111
#include "fboss/lib/phy/gen-cpp2/phy_types.h"
12+
#include "fboss/qsfp_service/if/gen-cpp2/qsfp_clients.h"
1213

1314
DECLARE_string(config);
1415
DECLARE_bool(disable_neighbor_updates);
@@ -78,6 +79,17 @@ class AgentEnsembleLinkTest : public AgentEnsembleTest {
7879
return xphyPorts;
7980
}
8081

82+
/*
83+
* Get Primary port names (e.g. eth1/1/1) from list of cabled ports
84+
*/
85+
std::vector<std::string> getPrimaryPortNamesCabledPorts();
86+
87+
/*
88+
* Dumps The transceiver I2c Logs at the end of a test run.
89+
*/
90+
void dumpTransceiverI2cLogs(
91+
apache::thrift::Client<facebook::fboss::QsfpService>& qsfpClient);
92+
8193
void checkAgentMemoryInBounds() const;
8294

8395
/*

0 commit comments

Comments
 (0)