Skip to content

Commit

Permalink
Adding gnmi port breakout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kishanps authored and Bibhuprasad Singh committed Feb 5, 2025
1 parent b2fc121 commit 18db0cc
Show file tree
Hide file tree
Showing 4 changed files with 499 additions and 260 deletions.
19 changes: 0 additions & 19 deletions tests/thinkit_gnmi_interface_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,6 @@ void BreakoutDuringPortInUse(thinkit::Switch &sut,
}
ASSERT_OK(ValidateBreakoutState(sut_gnmi_stub, new_breakout_info,
non_existing_port_list));

// Restore original port breakout config on port under test.
ASSERT_OK(GetBreakoutModeConfigFromString(req, sut_gnmi_stub, port_index,
port_info.port_name,
port_info.curr_breakout_mode));

LOG(INFO) << "Restoring original breakout mode "
<< port_info.curr_breakout_mode << " on port "
<< port_info.port_name << " on DUT";
grpc::ClientContext context3;
ASSERT_OK(sut_gnmi_stub->Set(&context3, req, &resp));
// TODO: Investigate changing to polling loop.
absl::SleepFor(absl::Seconds(60));

// Verify that the config is successfully applied.
non_existing_port_list = GetNonExistingPortsAfterBreakout(
orig_breakout_info, new_breakout_info, false);
ASSERT_OK(ValidateBreakoutState(sut_gnmi_stub, orig_breakout_info,
non_existing_port_list));
}

void TestGNMIParentPortInUseDuringBreakout(
Expand Down
31 changes: 31 additions & 0 deletions tests/thinkit_gnmi_interface_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ absl::StatusOr<bool> IsChannelizedBreakoutMode(const std::string& mode) {
return ((num_breakouts > 1) || absl::StrContains(mode, "+"));
}

absl::StatusOr<bool> IsSfpPlusPort(gnmi::gNMI::StubInterface& sut_gnmi_stub,
absl::string_view port_name) {
absl::flat_hash_map<std::string, std::string> interface_to_transceiver_map,
transceiver_to_ethernet_pmd_type_map;
ASSIGN_OR_RETURN(interface_to_transceiver_map,
pins_test::GetInterfaceToTransceiverMap(sut_gnmi_stub));
ASSIGN_OR_RETURN(transceiver_to_ethernet_pmd_type_map,
pins_test::GetTransceiverToEthernetPmdMap(sut_gnmi_stub));
if (!interface_to_transceiver_map.contains(port_name)) {
return gutil::InternalErrorBuilder().LogError()
<< "Interface " << port_name
<< " not found in interfaces to transceiver map";
}
if (!transceiver_to_ethernet_pmd_type_map.contains(
interface_to_transceiver_map[port_name])) {
return gutil::InternalErrorBuilder().LogError()
<< "Transceiver not found for interface " << port_name;
}
return absl::StrContains(transceiver_to_ethernet_pmd_type_map
[interface_to_transceiver_map[port_name]],
"LR");
}

absl::StatusOr<RandomPortBreakoutInfo> GetRandomPortWithSupportedBreakoutModes(
gnmi::gNMI::StubInterface& sut_gnmi_stub,
const std::string& platform_json_contents,
Expand Down Expand Up @@ -297,6 +320,14 @@ absl::StatusOr<RandomPortBreakoutInfo> GetRandomPortWithSupportedBreakoutModes(
}
}

// Skip SFP+ ports as breakout is not applicable to them.
ASSIGN_OR_RETURN(const bool is_sfpp_port,
IsSfpPlusPort(sut_gnmi_stub, port));
if (is_sfpp_port) {
LOG(INFO) << "Skipping SFP+ port " << port;
continue;
}

// Get the port entry from platform.json interfaces info.
const auto interface_json = interfaces_json->find(port);
if (interface_json == interfaces_json->end()) {
Expand Down
3 changes: 3 additions & 0 deletions tests/thinkit_gnmi_interface_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ absl::StatusOr<bool> BreakoutResultsInSpeedChangeOnly(
const std::string& port, const std::string& current_breakout_mode,
const std::string& new_breakout_mode);

absl::StatusOr<bool> IsSfpPlusPort(gnmi::gNMI::StubInterface &sut_gnmi_stub,
absl::string_view port_name);

// GetRandomPortWithSupportedBreakoutModes attempts to get a random port from
// list of front panel ports that supports at least one more breakout mode other
// than the currently configured breakout mode.
Expand Down
Loading

0 comments on commit 18db0cc

Please sign in to comment.