Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into switch_exp_runner
  • Loading branch information
divyagayathri-hcl committed Nov 28, 2024
2 parents c3c25bf + d4495ee commit 811eda3
Show file tree
Hide file tree
Showing 61 changed files with 5,831 additions and 1,178 deletions.
80 changes: 77 additions & 3 deletions dvaas/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ cc_library(
srcs = ["packet_injection.cc"],
hdrs = ["packet_injection.h"],
deps = [
":port_id_map",
":test_vector",
":test_vector_cc_proto",
"//gutil:status",
"//lib/p4rt:p4rt_port",
"//p4_pdpi:ir",
"//p4_pdpi:ir_cc_proto",
"//p4_pdpi:p4_runtime_session",
"//p4_pdpi/packetlib",
"//p4_pdpi/packetlib:packetlib_cc_proto",
"//tests/forwarding:util",
"@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
],
)

cc_library(
name = "test_run_validation",
srcs = ["test_run_validation.cc"],
Expand Down Expand Up @@ -101,6 +103,7 @@ cc_library(
hdrs = ["arriba_test_vector_validation.h"],
deps = [
":packet_injection",
":port_id_map",
":test_run_validation",
":test_vector",
":test_vector_cc_proto",
Expand All @@ -111,6 +114,7 @@ cc_library(
"//p4_pdpi:p4_runtime_session_extras",
"//sai_p4/instantiations/google/test_tools:test_entries",
"//thinkit:mirror_testbed",
"@com_github_google_glog//:glog",
"@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
Expand Down Expand Up @@ -193,16 +197,22 @@ cc_library(
hdrs = ["port_id_map.h"],
deps = [
"//gutil:status",
"//gutil:test_artifact_writer",
"//lib/gnmi:gnmi_helper",
"//lib/p4rt:p4rt_port",
"@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)


cc_test(
name = "port_id_map_test",
srcs = ["port_id_map_test.cc"],
Expand Down Expand Up @@ -321,4 +331,68 @@ cc_test(
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
)

# go/golden-test-with-coverage
cc_test(
name = "test_run_validation_test_runner",
srcs = ["test_run_validation_test_runner.cc"],
linkstatic = True,
deps = [
":test_run_validation",
":test_vector",
":test_vector_cc_proto",
"//gutil:testing",
"//p4_pdpi/packetlib",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)

cmd_diff_test(
name = "test_run_validation_golden_test",
actual_cmd = "$(execpath :test_run_validation_test_runner)",
expected = ":test_run_validation_test.expected.output",
tools = [":test_run_validation_test_runner"],
)

cc_library(
name = "dataplane_validation",
srcs = ["dataplane_validation.cc"],
hdrs = ["dataplane_validation.h"],
deps = [
":output_writer",
":packet_injection",
":port_id_map",
":switch_api",
":test_run_validation",
":test_vector",
":test_vector_cc_proto",
":user_provided_packet_test_vector",
":validation_result",
"//gutil:status",
"//gutil:test_artifact_writer",
"//gutil:version",
"//lib/gnmi:gnmi_helper",
"//lib/gnmi:openconfig_cc_proto",
"//lib/p4rt:p4rt_port",
"//p4_pdpi:ir",
"//p4_pdpi:ir_cc_proto",
"//p4_pdpi:p4_runtime_session",
"//p4_pdpi:p4_runtime_session_extras",
"//p4_pdpi/packetlib:packetlib_cc_proto",
"//p4_symbolic/packet_synthesizer:packet_synthesizer_cc_proto",
"//tests/lib:switch_test_setup_helpers",
"//thinkit:mirror_testbed",
"@com_github_gnmi//proto/gnmi:gnmi_cc_proto",
"@com_github_google_glog//:glog",
"@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
"@com_google_protobuf//:protobuf",
],
)
23 changes: 16 additions & 7 deletions dvaas/arriba_test_vector_validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "dvaas/packet_injection.h"
#include "dvaas/port_id_map.h"
#include "dvaas/test_run_validation.h"
#include "dvaas/test_vector.h"
#include "dvaas/test_vector.pb.h"
#include "glog/logging.h"
#include "gutil/status.h"
#include "gutil/test_artifact_writer.h"
#include "p4/v1/p4runtime.pb.h"
Expand All @@ -37,7 +39,8 @@ absl::Status ValidateAgaistArribaTestVector(
pdpi::P4RuntimeSession& sut, pdpi::P4RuntimeSession& control_switch,
const ArribaTestVector& arriba_test_vector,
const ArribaTestVectorValidationParams& params) {
// Prepare control switch.
// Prepare the control switch.
LOG(INFO) << "Installing entires to punt all packets on the control switch";
ASSIGN_OR_RETURN(p4::v1::GetForwardingPipelineConfigResponse config,
GetForwardingPipelineConfig(&control_switch));
ASSIGN_OR_RETURN(pdpi::IrP4Info ir_p4info,
Expand All @@ -50,7 +53,8 @@ absl::Status ValidateAgaistArribaTestVector(
RETURN_IF_ERROR(pdpi::ClearTableEntries(&control_switch));
RETURN_IF_ERROR(pdpi::InstallPiEntities(control_switch, punt_entities));

// Prepare SUT.
// Prepare the SUT.
LOG(INFO) << "Installing entries from the given test vector on the SUT";
RETURN_IF_ERROR(pdpi::ClearTableEntries(&sut));
RETURN_IF_ERROR(
pdpi::InstallIrTableEntries(sut, arriba_test_vector.ir_table_entries()));
Expand All @@ -66,11 +70,16 @@ absl::Status ValidateAgaistArribaTestVector(
gutil::BazelTestArtifactWriter artifact_writer;

// Send tests to switch and collect results.
ASSIGN_OR_RETURN(
PacketTestRuns test_runs,
SendTestPacketsAndCollectOutputs(sut, control_switch, test_vector_by_id,
packet_statistics,
params.max_packets_to_send_per_second));
ASSIGN_OR_RETURN(PacketTestRuns test_runs,
SendTestPacketsAndCollectOutputs(
sut, control_switch, test_vector_by_id,
{
.max_packets_to_send_per_second =
params.max_packets_to_send_per_second,
.mirror_testbed_port_map =
MirrorTestbedP4rtPortIdMap::CreateIdentityMap(),
},
packet_statistics));

// Compare the switch output with expected output for each test vector.
return ValidateTestRuns(test_runs, params.switch_output_diff_params,
Expand Down
Loading

0 comments on commit 811eda3

Please sign in to comment.