Skip to content

Commit b24ec4d

Browse files
kishanpsdivyagayathri-hcl
authored andcommitted
[Thinkit/Tests] Add tunnel-decap tests for different tunnel-types and Adding NSF Reboot to CPU QoS With and Without Ixia tests
1 parent bf82afc commit b24ec4d

File tree

15 files changed

+199
-61
lines changed

15 files changed

+199
-61
lines changed

tests/forwarding/tunnel_decap_test.cc

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ static const auto dst_mac =
5555
netaddr::MacAddress(0x00, 0xaa, 0xbb, 0xcc, 0xcc, 0xdd);
5656
static const auto tunnel_dst_ipv6 = netaddr::Ipv6Address(
5757
0x11, 0x2233, 0x4455, 0x6677, 0x8899, 0xaabb, 0xccdd, 0xeeff);
58+
static const auto tunnel_dst_ipv6_wildcard =
59+
netaddr::Ipv6Address(0x11, 0x2233, 0x4455, 0x6677, 0x8899, 0xaabb, 0, 0);
5860
static const auto tunnel_src_ipv6 = netaddr::Ipv6Address(
5961
0x1122, 0x1122, 0x3344, 0x3344, 0x5566, 0x5566, 0x7788, 0x7788);
62+
static const auto tunnel_src_ipv6_wildcard =
63+
netaddr::Ipv6Address(0x1122, 0x1122, 0x3344, 0x3344, 0x5566, 0x5566, 0, 0);
6064
static const auto inner_dst_ipv4 = netaddr::Ipv4Address(0x10, 0, 0, 0x1);
6165
static const auto incorrect_dst_ipv6 = netaddr::Ipv6Address(
6266
0x77, 0x2233, 0x4455, 0x5577, 0x8899, 0xaabb, 0xccdd, 0xeeff);
6367
static const auto exact_match_mask = netaddr::Ipv6Address(
6468
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff);
69+
static const auto ternary_match_mask =
70+
netaddr::Ipv6Address(0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 0);
6571
static const auto inner_dst_ipv6 = netaddr::Ipv6Address(
6672
0x2001, 0xdb8, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888);
6773

@@ -250,14 +256,24 @@ dvaas::PacketTestVector Ipv4InIpv6DecapTestVector(
250256

251257
// Helper routine to install L3 route
252258
absl::StatusOr<std::vector<p4::v1::Entity>> InstallTunnelTermTable(
253-
pdpi::P4RuntimeSession& switch_session, pdpi::IrP4Info& ir_p4info) {
259+
pdpi::P4RuntimeSession& switch_session, pdpi::IrP4Info& ir_p4info,
260+
const pins_test::TunnelMatchType tunnel_type) {
254261
std::vector<p4::v1::Entity> pi_entities;
255262
LOG(INFO) << "Installing Tunnel term table";
256-
sai::Ipv6TunnelTerminationParams params;
257-
params.dst_ipv6_value = tunnel_dst_ipv6;
258-
params.dst_ipv6_mask = exact_match_mask;
259-
params.src_ipv6_value = tunnel_src_ipv6;
260-
params.src_ipv6_mask = exact_match_mask;
263+
sai::Ipv6TunnelTerminationParams params{
264+
.src_ipv6_value = tunnel_src_ipv6,
265+
.src_ipv6_mask = exact_match_mask,
266+
.dst_ipv6_value = tunnel_dst_ipv6,
267+
.dst_ipv6_mask = exact_match_mask,
268+
};
269+
270+
if (tunnel_type == pins_test::TunnelMatchType::kTernaryMatchSrcIp) {
271+
params.src_ipv6_value = tunnel_src_ipv6_wildcard;
272+
params.src_ipv6_mask = ternary_match_mask;
273+
} else if (tunnel_type == pins_test::TunnelMatchType::kTernaryMatchDstIp) {
274+
params.dst_ipv6_value = tunnel_dst_ipv6_wildcard;
275+
params.dst_ipv6_mask = ternary_match_mask;
276+
}
261277

262278
sai::EntryBuilder entry_builder =
263279
sai::EntryBuilder().AddIpv6TunnelTerminationEntry(params);
@@ -298,6 +314,16 @@ TEST_P(TunnelDecapTestFixture, BasicTunnelTermDecapv4Inv6) {
298314
thinkit::MirrorTestbed& testbed =
299315
GetParam().mirror_testbed->GetMirrorTestbed();
300316

317+
// Set testbed environment
318+
if (GetParam().tunnel_type == pins_test::TunnelMatchType::kExactMatch) {
319+
testbed.Environment().SetTestCaseID("80ddbc10-4b85-4021-8093-0ac48e72b2de");
320+
} else if (GetParam().tunnel_type ==
321+
pins_test::TunnelMatchType::kTernaryMatchSrcIp) {
322+
testbed.Environment().SetTestCaseID("d5bb5571-ecc0-4a46-aac4-02a0c7f79df9");
323+
} else {
324+
testbed.Environment().SetTestCaseID("e986d859-59ec-4a8f-acc0-c586cecf0eb2");
325+
}
326+
301327
// Initialize the connection, clear all entities, and (for the SUT) push
302328
// P4Info.
303329
ASSERT_OK_AND_ASSIGN(std::unique_ptr<pdpi::P4RuntimeSession> sut_p4rt_session,
@@ -324,7 +350,8 @@ TEST_P(TunnelDecapTestFixture, BasicTunnelTermDecapv4Inv6) {
324350
// Install tunnel term table entry on SUT
325351
ASSERT_OK_AND_ASSIGN(
326352
const auto tunnel_entities,
327-
InstallTunnelTermTable(*sut_p4rt_session.get(), sut_ir_p4info));
353+
InstallTunnelTermTable(*sut_p4rt_session.get(), sut_ir_p4info,
354+
GetParam().tunnel_type));
328355

329356
LOG(INFO) << "Sending IPv4-in-IPv6 Packet from ing:" << in_port
330357
<< " to eng:" << out_port;
@@ -347,14 +374,14 @@ TEST_P(TunnelDecapTestFixture, BasicTunnelTermDecapv4Inv6) {
347374
EXPECT_OK(validation_result.HasSuccessRateOfAtLeast(1.0));
348375

349376
// Send IPv4-in-IPv6 with wrong dst_ipv6 Packet and Verify
350-
pins_test::TunnelDecapTestVectorParams tunel_v6_mismatch{
377+
pins_test::TunnelDecapTestVectorParams tunnel_v6_mismatch{
351378
.in_port = in_port,
352379
.out_port = out_port,
353380
.dst_mac = dst_mac,
354381
.inner_dst_ipv4 = inner_dst_ipv4,
355382
.dst_ipv6 = incorrect_dst_ipv6};
356383
dvaas::PacketTestVector test_vector =
357-
Ipv4InIpv6DecapTestVector(tunel_v6_mismatch);
384+
Ipv4InIpv6DecapTestVector(tunnel_v6_mismatch);
358385

359386
for (dvaas::SwitchOutput& output :
360387
*test_vector.mutable_acceptable_outputs()) {
@@ -378,6 +405,16 @@ TEST_P(TunnelDecapTestFixture, BasicTunnelTermDecapv6Inv6) {
378405
thinkit::MirrorTestbed& testbed =
379406
GetParam().mirror_testbed->GetMirrorTestbed();
380407

408+
// Set testbed environment
409+
if (GetParam().tunnel_type == pins_test::TunnelMatchType::kExactMatch) {
410+
testbed.Environment().SetTestCaseID("79060cd7-6001-4925-85e5-4bb8b1ec56ae");
411+
} else if (GetParam().tunnel_type ==
412+
pins_test::TunnelMatchType::kTernaryMatchSrcIp) {
413+
testbed.Environment().SetTestCaseID("6b0297a7-75cd-412b-be24-61c8fb363399");
414+
} else {
415+
testbed.Environment().SetTestCaseID("b7716ba9-4266-48dc-9815-10093603f597");
416+
}
417+
381418
// Initialize the connection, clear all entities, and (for the SUT) push
382419
// P4Info.
383420
ASSERT_OK_AND_ASSIGN(std::unique_ptr<pdpi::P4RuntimeSession> sut_p4rt_session,
@@ -404,7 +441,8 @@ TEST_P(TunnelDecapTestFixture, BasicTunnelTermDecapv6Inv6) {
404441
// Install tunnel term table entry on SUT
405442
ASSERT_OK_AND_ASSIGN(
406443
const auto tunnel_entities,
407-
InstallTunnelTermTable(*sut_p4rt_session.get(), sut_ir_p4info));
444+
InstallTunnelTermTable(*sut_p4rt_session.get(), sut_ir_p4info,
445+
GetParam().tunnel_type));
408446

409447
LOG(INFO) << "Sending IPv6-in-IPv6 Packet for packet match from in:"
410448
<< in_port << " to out:" << out_port;

tests/forwarding/tunnel_decap_test.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@
3131

3232
namespace pins_test {
3333

34+
enum class TunnelMatchType {
35+
kExactMatch, // exact match on src-ip and dst-ip
36+
kTernaryMatchSrcIp, // ternary match on src-ip and exact match on dst-ip
37+
kTernaryMatchDstIp, // ternary match on dst-ip and exact match on src-ip
38+
};
39+
3440
struct TunnelDecapTestParams {
3541
// Using a shared_ptr because parameterized tests require objects to be
3642
// copyable.
3743
std::shared_ptr<thinkit::MirrorTestbedInterface> mirror_testbed;
3844
// Pushed to the SUT if given, otherwise assumes the correct one is already
3945
// configured.
4046
std::optional<p4::config::v1::P4Info> sut_p4info;
47+
TunnelMatchType tunnel_type;
4148
std::string test_name;
4249
dvaas::DataplaneValidationParams dvaas_params;
4350
std::shared_ptr<dvaas::DataplaneValidator> dvaas;

tests/integration/system/nsf/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ cc_library(
4444
"//thinkit:switch",
4545
"@com_github_google_glog//:glog",
4646
"@com_github_grpc_grpc//:grpc++",
47+
"@com_google_absl//absl/base:nullability",
4748
"@com_google_absl//absl/status",
4849
"@com_google_absl//absl/status:statusor",
4950
"@com_google_absl//absl/strings",
@@ -78,7 +79,7 @@ cc_library(
7879
"@com_google_absl//absl/strings",
7980
"@com_google_absl//absl/strings:string_view",
8081
"@com_google_absl//absl/time",
81-
"@com_google_googletest//:gtest_main",
82+
"@com_google_googletest//:gtest",
8283
],
8384
alwayslink = True,
8485
)

tests/integration/system/nsf/flow_programmers/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ cc_library(
2626
deps = [
2727
"//tests/integration/system/nsf/interfaces:flow_programmer",
2828
"//tests/integration/system/nsf/interfaces:testbed",
29+
"//thinkit:ssh_client",
2930
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
3031
"@com_google_absl//absl/status",
3132
],

tests/integration/system/nsf/flow_programmers/fuzzer_replay_programmer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
#include "p4/config/v1/p4info.pb.h"
2020
#include "tests/integration/system/nsf/interfaces/flow_programmer.h"
2121
#include "tests/integration/system/nsf/interfaces/testbed.h"
22+
#include "thinkit/ssh_client.h"
2223

2324
namespace pins_test {
2425

2526
class FuzzerReplayProgrammer : public FlowProgrammer {
2627
public:
2728
absl::Status ProgramFlows(const p4::config::v1::P4Info &p4_info,
28-
Testbed &testbed) override {
29+
Testbed &testbed,
30+
thinkit::SSHClient &ssh_client) override {
2931
return absl::OkStatus();
3032
};
3133
absl::Status ClearFlows(Testbed& testbed) override {

tests/integration/system/nsf/interfaces/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cc_library(
3737
hdrs = ["flow_programmer.h"],
3838
deps = [
3939
":testbed",
40+
"//thinkit:ssh_client",
4041
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
4142
"@com_google_absl//absl/status",
4243
],

tests/integration/system/nsf/interfaces/flow_programmer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "absl/status/status.h"
1919
#include "p4/config/v1/p4info.pb.h"
2020
#include "tests/integration/system/nsf/interfaces/testbed.h"
21+
#include "thinkit/ssh_client.h"
2122

2223
namespace pins_test {
2324

@@ -30,10 +31,10 @@ class FlowProgrammer {
3031
public:
3132
virtual ~FlowProgrammer() = default;
3233

33-
// Programs a predefined flow on the SUT based on the given IP version and
34-
// protocol.
34+
// Programs predefined flows on the SUT.
3535
virtual absl::Status ProgramFlows(const p4::config::v1::P4Info &p4_info,
36-
Testbed &testbed) = 0;
36+
Testbed &testbed,
37+
thinkit::SSHClient &ssh_client) = 0;
3738

3839
// Clears all flows on the SUT.
3940
virtual absl::Status ClearFlows(Testbed& testbed) = 0;

tests/integration/system/nsf/nsf_acl_flow_coverage_test.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ TEST_P(NsfAclFlowCoverageTestFixture, NsfAclFlowCoverageTest) {
114114
ImageConfigParams image_config_param = GetParam().image_config_params[0];
115115
thinkit::Switch& sut = GetSut(testbed_);
116116

117-
ASSERT_OK(ValidateTestbedState(image_config_param.image_label, testbed_,
118-
*ssh_client_, image_config_param.gnmi_config));
117+
ASSERT_OK(ValidateTestbedState(testbed_, *ssh_client_, &image_config_param));
119118
ASSERT_OK(StoreSutDebugArtifacts(
120119
absl::StrCat(image_config_param.image_label, "_before_nsf_reboot"),
121120
testbed_));
@@ -132,8 +131,8 @@ TEST_P(NsfAclFlowCoverageTestFixture, NsfAclFlowCoverageTest) {
132131

133132
// Program all the flows.
134133
LOG(INFO) << "Programming L3 flows before starting the traffic";
135-
ASSERT_OK(
136-
flow_programmer_->ProgramFlows(image_config_param.p4_info, testbed_));
134+
ASSERT_OK(flow_programmer_->ProgramFlows(image_config_param.p4_info, testbed_,
135+
*ssh_client_));
137136
LOG(INFO) << "Programming ACL flows";
138137
ASSERT_OK(ProgramAclFlows(sut, image_config_param.p4_info));
139138

@@ -152,8 +151,7 @@ TEST_P(NsfAclFlowCoverageTestFixture, NsfAclFlowCoverageTest) {
152151
ASSERT_OK(pins_test::NsfReboot(testbed_));
153152
ASSERT_OK(WaitForNsfReboot(testbed_, *ssh_client_));
154153

155-
ASSERT_OK(ValidateTestbedState(image_config_param.image_label, testbed_,
156-
*ssh_client_, image_config_param.gnmi_config));
154+
ASSERT_OK(ValidateTestbedState(testbed_, *ssh_client_, &image_config_param));
157155
ASSERT_OK(StoreSutDebugArtifacts(
158156
absl::StrCat(image_config_param.image_label, "_after_nsf_reboot"),
159157
testbed_));

tests/integration/system/nsf/upgrade_test.cc

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ using ::p4::v1::ReadResponse;
5252
constexpr int kErrorPercentage = 1;
5353
constexpr absl::Duration kTrafficRunDuration = absl::Minutes(15);
5454

55+
// TODO: Compare and look into possibility of using a better
56+
// approach than using std::variant (eg. type-erasure or typed tests).
5557
void NsfUpgradeTest::SetUp() {
5658
flow_programmer_ = GetParam().create_flow_programmer();
5759
traffic_helper_ = GetParam().create_traffic_helper();
@@ -69,9 +71,8 @@ absl::Status NsfUpgradeTest::NsfUpgradeOrReboot(
6971
LOG(INFO) << "Initiating NSF Upgrade from: " << curr_image_config.image_label
7072
<< " to: " << next_image_config.image_label;
7173

72-
RETURN_IF_ERROR(ValidateTestbedState(curr_image_config.image_label, testbed_,
73-
*ssh_client_,
74-
curr_image_config.gnmi_config));
74+
RETURN_IF_ERROR(
75+
ValidateTestbedState(testbed_, *ssh_client_, &curr_image_config));
7576
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnInit,
7677
component_validators_,
7778
curr_image_config.image_label, testbed_));
@@ -89,8 +90,8 @@ absl::Status NsfUpgradeTest::NsfUpgradeOrReboot(
8990

9091
// Program all the flows.
9192
LOG(INFO) << "Programming flows before starting the traffic";
92-
RETURN_IF_ERROR(
93-
flow_programmer_->ProgramFlows(curr_image_config.p4_info, testbed_));
93+
RETURN_IF_ERROR(flow_programmer_->ProgramFlows(curr_image_config.p4_info,
94+
testbed_, *ssh_client_));
9495
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnFlowProgram,
9596
component_validators_,
9697
curr_image_config.image_label, testbed_));
@@ -116,15 +117,15 @@ absl::Status NsfUpgradeTest::NsfUpgradeOrReboot(
116117
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnImageCopy,
117118
component_validators_,
118119
next_image_config.image_label, testbed_));
120+
// TODO: Validate uptime and boot-type once they are supported.
119121

120122
// Perform NSF Reboot.
121123
RETURN_IF_ERROR(NsfReboot(testbed_));
122124
RETURN_IF_ERROR(WaitForNsfReboot(testbed_, *ssh_client_));
123125

124126
// Perform validations after reboot is completed.
125-
RETURN_IF_ERROR(ValidateTestbedState(next_image_config.image_label, testbed_,
126-
*ssh_client_,
127-
next_image_config.gnmi_config));
127+
RETURN_IF_ERROR(
128+
ValidateTestbedState(testbed_, *ssh_client_, &next_image_config));
128129
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnNsfReboot,
129130
component_validators_,
130131
next_image_config.image_label, testbed_));
@@ -141,9 +142,8 @@ absl::Status NsfUpgradeTest::NsfUpgradeOrReboot(
141142

142143
// Push the new config and validate.
143144
RETURN_IF_ERROR(PushConfig(next_image_config, testbed_, *ssh_client_));
144-
RETURN_IF_ERROR(ValidateTestbedState(next_image_config.image_label, testbed_,
145-
*ssh_client_,
146-
next_image_config.gnmi_config));
145+
RETURN_IF_ERROR(
146+
ValidateTestbedState(testbed_, *ssh_client_, &next_image_config));
147147
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnConfigPush,
148148
component_validators_,
149149
next_image_config.image_label, testbed_));
@@ -156,15 +156,23 @@ absl::Status NsfUpgradeTest::NsfUpgradeOrReboot(
156156
LOG(INFO) << "Stopping the traffic";
157157
RETURN_IF_ERROR(traffic_helper_->StopTraffic(testbed_));
158158

159+
// TODO: For now, we validate traffic only after stopping
160+
// traffic. Ideally we would want to validate traffic while injection is in
161+
// progress to narrow down when the traffic loss occurred (i.e. before reboot,
162+
// during reboot or after reconciliation). Although this is possible in OTG
163+
// traffic generator, DVaaS traffic generator for now does not support traffic
164+
// validation before stopping the traffic. This is a good-to-have feature and
165+
// we will update the skeleton to validate traffic while injection is ongoing
166+
// once this feature is available in DVaaS.
159167
LOG(INFO) << "Validating the traffic";
160168
RETURN_IF_ERROR(traffic_helper_->ValidateTraffic(testbed_, kErrorPercentage));
161169
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnStopTraffic,
162170
component_validators_,
163171
next_image_config.image_label, testbed_));
164172

165-
// Selectively clear flows (eg. not clearing nexthop entries for host
166-
// testbeds).
167-
LOG(INFO) << "Clearing the flows";
173+
// TODO: Look into resetting the testbed state, including the
174+
// flows on the SUT, in the same state as that before the test.
175+
LOG(INFO) << "Clearing the flows from SUT";
168176
RETURN_IF_ERROR(flow_programmer_->ClearFlows(testbed_));
169177

170178
RETURN_IF_ERROR(ValidateComponents(&ComponentValidator::OnFlowCleanup,

0 commit comments

Comments
 (0)