Skip to content

Commit c9f46ce

Browse files
kishanpsSRAVANI KANASANI
authored andcommitted
Add changes to arriba_test
1 parent 26b641c commit c9f46ce

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

sdn_tests/pins_ondatra/tests/thinkit/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ cc_test(
107107
],
108108
deps = [
109109
"@com_github_sonic_net_sonic_pins//dvaas:test_vector_cc_proto",
110-
"@com_github_sonic_net_sonic_pins//gutil:status",
110+
# "@com_github_sonic_net_sonic_pins//gutil:status",
111+
"@com_github_sonic_net_sonic_pins//gutil:testing",
111112
"//infrastructure/thinkit:ondatra_params",
112113
"@com_github_sonic_net_sonic_pins//tests/forwarding:arriba_test",
113114
"@com_github_sonic_net_sonic_pins//thinkit:mirror_testbed_fixture",

sdn_tests/pins_ondatra/tests/thinkit/arriba_test.cc

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,53 @@
1010
#include "dvaas/test_vector.pb.h"
1111
#include "glog/logging.h"
1212
#include "gtest/gtest.h"
13-
#include "gutil/status.h"
14-
#include "gutil/status.h"
13+
// #include "gutil/status.h"
14+
#include "gutil/testing.h"
1515
#include "infrastructure/thinkit/ondatra_params.h"
1616
#include "thinkit/mirror_testbed_fixture.h"
1717

1818
ABSL_FLAG(std::vector<std::string>, arriba_test_vector_files, {},
1919
"Paths to files containing ArribaTestVector textprotos.");
20+
ABSL_FLAG(double, expected_minimum_success_rate, 1.0,
21+
"Expected minimum success rate for the packet vectors.");
22+
ABSL_FLAG(
23+
bool, wait_for_all_enabled_interfaces_to_be_up, true,
24+
"If true, waits for all enabled ports to be up on SUT and control switch.");
25+
ABSL_FLAG(
26+
absl::Duration, max_expected_packet_in_flight_duration, absl::Seconds(3),
27+
R"(Maximum time expected it takes to receive output packets either from SUT
28+
or control switch in response to an injected input packet. Beyond that,
29+
the input packet might be considered dropped.)");
2030

2131
namespace pins_test {
2232
namespace {
2333

34+
// Unsolicited packets that, for the time being, are acceptable in a PINS
35+
// testbeds.
36+
inline bool AlpineIsExpectedUnsolicitedPacket(const packetlib::Packet& packet) {
37+
if (packet.headers().size() == 3 &&
38+
packet.headers(2).icmp_header().type() == "0x85") {
39+
return true;
40+
}
41+
// TODO Switch generates IPV6 hop_by_hop packets.
42+
if (packet.headers().size() == 2 &&
43+
packet.headers(1).ipv6_header().next_header() == "0x00") {
44+
return true;
45+
}
46+
// Switch generates LACP packets if LAGs are present.
47+
if (packet.headers().size() == 1 &&
48+
packet.headers(0).ethernet_header().ethertype() == "0x8809") {
49+
return true;
50+
}
51+
// Alpine's deployment environment sends ARP packets.
52+
if (!packet.headers().empty() &&
53+
packet.headers(0).ethernet_header().ethertype() == "0x0806") {
54+
LOG(INFO) << "ALPINE: ARP packet";
55+
return true;
56+
}
57+
return false;
58+
}
59+
2460
// Returns one test instance per test vector textproto file provided through the
2561
// `--arriba_test_vector_files` flag.
2662
absl::StatusOr<std::vector<ArribaTestParams>> GetTestInstances() {
@@ -36,10 +72,26 @@ absl::StatusOr<std::vector<ArribaTestParams>> GetTestInstances() {
3672
std::vector<ArribaTestParams> test_instances;
3773
for (const std::string& test_vector_file :
3874
absl::GetFlag(FLAGS_arriba_test_vector_files)) {
75+
dvaas::ArribaTestVector arriba_test_vector;
76+
arriba_test_vector =
77+
gutil::ParseProtoFileOrDie<dvaas::ArribaTestVector>(test_vector_file);
3978

4079
test_instances.push_back(ArribaTestParams{
4180
.mirror_testbed = std::shared_ptr<thinkit::MirrorTestbedInterface>(
4281
mirror_testbed_params.mirror_testbed),
82+
.arriba_test_vector = arriba_test_vector,
83+
.validation_params =
84+
{
85+
.expected_minimum_success_rate =
86+
absl::GetFlag(FLAGS_expected_minimum_success_rate),
87+
.max_expected_packet_in_flight_duration =
88+
absl::GetFlag(FLAGS_max_expected_packet_in_flight_duration),
89+
.is_expected_unsolicited_packet =
90+
AlpineIsExpectedUnsolicitedPacket,
91+
},
92+
.wait_for_all_enabled_interfaces_to_be_up =
93+
absl::GetFlag(FLAGS_wait_for_all_enabled_interfaces_to_be_up),
94+
.description = test_vector_file,
4395
});
4496
}
4597
return test_instances;
@@ -48,6 +100,7 @@ absl::StatusOr<std::vector<ArribaTestParams>> GetTestInstances() {
48100
std::vector<ArribaTestParams> GetTestInstancesOrDie() {
49101
absl::StatusOr<std::vector<ArribaTestParams>> test_instances =
50102
GetTestInstances();
103+
CHECK_OK(test_instances.status()); // Crash OK.
51104
return *test_instances;
52105
}
53106

0 commit comments

Comments
 (0)