Skip to content

Commit 3c4ffed

Browse files
kishanpsVSuryaprasad-HCL
authored andcommitted
[Thinkit] Export pushed P4Info as test artifacts for P4Info push test.Don't craft packets with UDP headers if UDP port is already reserved.Increase BERT test duration when disabling the ports during the test.Skip BERT on certain links.
1 parent ae258b0 commit 3c4ffed

8 files changed

+345
-186
lines changed

tests/forwarding/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,14 @@ cc_library(
454454
":util",
455455
"//dvaas:test_vector_cc_proto",
456456
"//gutil:collections",
457+
"//gutil:status",
457458
"//gutil:status_matchers",
458459
"//gutil:testing",
459460
"//lib/gnmi:gnmi_helper",
461+
"//lib/gnmi:openconfig_cc_proto",
460462
"//lib/p4rt:p4rt_port",
461463
"//lib/validator:validator_lib",
464+
"//p4_pdpi:ir",
462465
"//p4_pdpi:ir_cc_proto",
463466
"//p4_pdpi:p4_runtime_session",
464467
"//p4_pdpi:pd",
@@ -468,6 +471,7 @@ cc_library(
468471
"//sai_p4/instantiations/google:sai_pd_cc_proto",
469472
"//tests:thinkit_sanity_tests",
470473
"//tests/lib:p4rt_fixed_table_programming_helper",
474+
"//tests/lib:switch_test_setup_helpers",
471475
"//thinkit:mirror_testbed",
472476
"//thinkit:mirror_testbed_fixture",
473477
"//thinkit:switch",

tests/forwarding/p4info_push_test.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -31,13 +31,16 @@ namespace {
3131
// Sends P4Info to the switch and makes sure it works.
3232
TEST_P(P4InfoPushTestFixture, P4InfoPushTest) {
3333
LOG(INFO) << "Test started";
34-
34+
ASSERT_OK(GetParam()
35+
.mirror_testbed->GetMirrorTestbed()
36+
.Environment()
37+
.StoreTestArtifact("pushed_p4info.pb.txt", GetParam().p4info));
3538
// Push the gNMI configuration and P4Info to the SUT.
3639
LOG(INFO) << "Pushing gNMI config & P4info";
37-
ASSERT_OK_AND_ASSIGN(
38-
std::unique_ptr<pdpi::P4RuntimeSession> sut_p4rt_session,
39-
pins_test::ConfigureSwitchAndReturnP4RuntimeSession(
40-
GetTestbed().Sut(), GetParam().gnmi_config, GetParam().p4info));
40+
ASSERT_OK_AND_ASSIGN(std::unique_ptr<pdpi::P4RuntimeSession> sut_p4rt_session,
41+
pins_test::ConfigureSwitchAndReturnP4RuntimeSession(
42+
GetParam().mirror_testbed->GetMirrorTestbed().Sut(),
43+
GetParam().gnmi_config, GetParam().p4info));
4144

4245
// Pull P4Info, make sure it is the same as the pushed one.
4346
LOG(INFO) << "Pulling P4Info";

tests/forwarding/p4info_push_test.h

+9-18
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,27 @@
1717

1818
#include <string>
1919

20-
#include "gutil/status_matchers.h"
21-
#include "tests/thinkit_sanity_tests.h"
22-
#include "thinkit/mirror_testbed.h"
2320
#include "thinkit/mirror_testbed_fixture.h"
2421

2522
namespace pins {
2623

2724
struct P4InfoPushTestParams {
2825
std::string description;
2926
// TODO: use GenericTestbed instead.
30-
thinkit::MirrorTestbedInterface *testbed_interface;
31-
std::string gnmi_config;
27+
std::shared_ptr<thinkit::MirrorTestbedInterface> mirror_testbed;
28+
// The test assumes that the switch is pre-configured if no `gnmi_config` is
29+
// given (default), or otherwise pushes the given config before starting.
30+
std::optional<std::string> gnmi_config;
3231
p4::config::v1::P4Info p4info;
3332
};
3433

3534
class P4InfoPushTestFixture
3635
: public testing::TestWithParam<P4InfoPushTestParams> {
37-
protected:
38-
void SetUp() override { testbed_interface_->SetUp(); }
39-
void TearDown() override { testbed_interface_->TearDown(); }
40-
41-
thinkit::MirrorTestbed &GetTestbed() {
42-
return testbed_interface_->GetMirrorTestbed();
43-
}
44-
45-
private:
46-
std::unique_ptr<thinkit::MirrorTestbedInterface> testbed_interface_ =
47-
absl::WrapUnique(GetParam().testbed_interface);
36+
protected:
37+
void SetUp() override { GetParam().mirror_testbed->SetUp(); }
38+
void TearDown() override { GetParam().mirror_testbed->TearDown(); }
4839
};
4940

50-
} // namespace pins
41+
} // namespace pins
5142

52-
#endif // PINS_TESTS_FORWARDING_P4INFO_PUSH_TEST_H_
43+
#endif // PINS_TESTS_FORWARDING_P4INFO_PUSH_TEST_H_

0 commit comments

Comments
 (0)