Skip to content

Commit bc6eb93

Browse files
kishanpsVSuryaprasad-HCL
authored andcommitted
[Thinkit] Update P4Info configuration API calls. Remove thread-unsafe TryCancel method; migrate users to Finish and make it safe.remove deprecated P4RuntimeSession API.Adds StreamableStatusOr utility and removed absl::StatusOr operator<< overloads.
1 parent 8d1c7b8 commit bc6eb93

8 files changed

+801
-67
lines changed

tests/forwarding/watch_port_test.cc

+21
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ void WatchPortTestFixture::TearDown() {
581581
ASSERT_OK(testbed.SaveSwitchLogs("before_reboot_"));
582582
LOG(INFO) << "Switch is in critical state, rebooting the switch.";
583583
pins_test::TestGnoiSystemColdReboot(testbed.GetMirrorTestbed().Sut());
584+
EXPECT_OK(control_p4_session_->Finish());
585+
if (receive_packet_thread_.joinable()) {
586+
receive_packet_thread_.join();
587+
}
584588
pins_test::TestGnoiSystemColdReboot(
585589
testbed.GetMirrorTestbed().ControlSwitch());
586590

@@ -593,6 +597,23 @@ void WatchPortTestFixture::TearDown() {
593597
EXPECT_OK(pdpi::ClearTableEntries(sut_p4_session_.get()));
594598
EXPECT_OK(sut_p4_session_->Finish());
595599
}
600+
// Stop RPC sessions.
601+
if (control_p4_session_ != nullptr) {
602+
EXPECT_OK(pdpi::ClearTableEntries(control_p4_session_.get()));
603+
EXPECT_OK(control_p4_session_->Finish());
604+
}
605+
if (receive_packet_thread_.joinable()) {
606+
receive_packet_thread_.join();
607+
}
608+
if (control_gnmi_stub_) {
609+
ASSERT_OK_AND_ASSIGN(const auto port_name_per_port_id,
610+
GetPortNamePerPortId(*control_gnmi_stub_));
611+
// Restore the admin state to UP.
612+
for (const auto& [port_id, name] : port_name_per_port_id) {
613+
EXPECT_OK(SetInterfaceAdminState(*control_gnmi_stub_, name,
614+
InterfaceState::kUp));
615+
}
616+
}
596617

597618
testbed.TearDown();
598619
}

tests/mtu_tests/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ cc_library(
4848
"//p4_pdpi/packetlib:packetlib_cc_proto",
4949
"//sai_p4/instantiations/google:sai_pd_cc_proto",
5050
"//tests/forwarding:util",
51+
"//tests/lib:switch_test_setup_helpers",
5152
"//thinkit:control_device",
5253
"//thinkit:generic_testbed",
5354
"//thinkit:generic_testbed_fixture",

tests/mtu_tests/mtu_tests.cc

+9-8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "sai_p4/instantiations/google/instantiations.h"
3939
#include "sai_p4/instantiations/google/sai_pd.pb.h"
4040
#include "tests/forwarding/util.h"
41+
#include "tests/lib/switch_test_setup_helpers.h"
4142
#include "thinkit/control_device.h"
4243
#include "thinkit/generic_testbed.h"
4344
#include "thinkit/proto/generic_testbed.pb.h"
@@ -252,10 +253,10 @@ TEST_P(MtuRoutingTestFixture, MtuTest) {
252253
ASSERT_TRUE(absl::SimpleAtoi(state_path_response, &orig_mtu));
253254

254255
// Set up a route between the source and destination interfaces.
255-
ASSERT_OK_AND_ASSIGN(
256-
std::unique_ptr<pdpi::P4RuntimeSession> p4_session,
257-
pdpi::P4RuntimeSession::CreateWithP4InfoAndClearTables(
258-
testbed_->Sut(), MtuRoutingTestFixture::GetParam().p4_info));
256+
ASSERT_OK_AND_ASSIGN(std::unique_ptr<pdpi::P4RuntimeSession> p4_session,
257+
pins_test::ConfigureSwitchAndReturnP4RuntimeSession(
258+
testbed_->Sut(), /*gnmi_config=*/std::nullopt,
259+
MtuRoutingTestFixture::GetParam().p4_info));
259260
P4rtProgrammingContext p4rt_context(p4_session.get(),
260261
pdpi::SetMetadataAndSendPiWriteRequest);
261262
ASSERT_OK(SetupRoute(&p4rt_context));
@@ -319,10 +320,10 @@ TEST_P(MtuRoutingTestFixture, VerifyTrafficWithMtuChangeTest) {
319320
std::to_string(kMtu4500));
320321

321322
// Set up a route between the source and destination interfaces.
322-
ASSERT_OK_AND_ASSIGN(
323-
std::unique_ptr<pdpi::P4RuntimeSession> p4_session,
324-
pdpi::P4RuntimeSession::CreateWithP4InfoAndClearTables(
325-
testbed_->Sut(), MtuRoutingTestFixture::GetParam().p4_info));
323+
ASSERT_OK_AND_ASSIGN(std::unique_ptr<pdpi::P4RuntimeSession> p4_session,
324+
pins_test::ConfigureSwitchAndReturnP4RuntimeSession(
325+
testbed_->Sut(), /*gnmi_config=*/std::nullopt,
326+
MtuRoutingTestFixture::GetParam().p4_info));
326327
P4rtProgrammingContext p4rt_context(p4_session.get(),
327328
pdpi::SetMetadataAndSendPiWriteRequest);
328329
ASSERT_OK(SetupRoute(&p4rt_context));

tests/qos/BUILD.bazel

+4-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ cc_test(
165165
deps = [
166166
":gnmi_parsers",
167167
"//gutil:proto",
168+
"//gutil:status",
169+
"@com_google_absl//absl/status:statusor",
168170
"@com_google_absl//absl/strings",
169171
"@com_google_protobuf//:protobuf",
170172
],
@@ -210,6 +212,7 @@ cc_library(
210212
hdrs = ["packet_in_receiver.h"],
211213
deps = [
212214
"//p4_pdpi:p4_runtime_session",
213-
"@com_google_absl//absl/synchronization",
215+
"@com_google_absl//absl/synchronization",
216+
"@com_google_absl//absl/time",
214217
],
215218
)

0 commit comments

Comments
 (0)