Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Thinkit] visibility declarations; make all targets public. Set role. Adding additional BERT tests. #673

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/forwarding/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ cc_library(
testonly = True,
srcs = ["smoke_test.cc"],
hdrs = ["smoke_test.h"],
visibility = ["//visibility:public"],
deps = [
":p4_blackbox_fixture",
":test_data",
Expand Down
11 changes: 9 additions & 2 deletions tests/forwarding/p4_blackbox_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class P4BlackboxFixture : public thinkit::MirrorTestbedFixture {
}

void TearDown() override {
if (SutP4RuntimeSession() != nullptr) {
if (SutP4RuntimeSession() != nullptr && clear_table_entries_on_teardown_) {
// Clear all table entries to leave the switch in a clean state.
EXPECT_OK(pdpi::ClearTableEntries(SutP4RuntimeSession()));
}
Expand All @@ -82,9 +82,16 @@ class P4BlackboxFixture : public thinkit::MirrorTestbedFixture {

const pdpi::IrP4Info& IrP4Info() const { return ir_p4info_; }

protected:
void DisableClearingTableEntriesOnTearDown() {
clear_table_entries_on_teardown_ = false;
}

private:
bool clear_table_entries_on_teardown_ = true;
std::unique_ptr<pdpi::P4RuntimeSession> sut_p4rt_session_;
pdpi::IrP4Info ir_p4info_ = sai::GetIrP4Info(sai::Instantiation::kMiddleblock);
pdpi::IrP4Info ir_p4info_ =
sai::GetIrP4Info(sai::Instantiation::kMiddleblock);
};

} // namespace gpins
Expand Down
45 changes: 43 additions & 2 deletions tests/forwarding/smoke_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,46 @@
namespace gpins {
namespace {

TEST_P(SmokeTestFixture, ModifyWorks) {
const sai::WriteRequest pd_insert = gutil::ParseProtoOrDie<sai::WriteRequest>(
R"pb(
updates {
type: INSERT
table_entry {
acl_ingress_table_entry {
match { is_ip { value: "0x1" } }
priority: 10
action { copy { qos_queue: "0x1" } }
}
}
}
)pb");
ASSERT_OK_AND_ASSIGN(p4::v1::WriteRequest pi_insert,
pdpi::PdWriteRequestToPi(IrP4Info(), pd_insert));
ASSERT_OK(
pdpi::SetMetadataAndSendPiWriteRequest(SutP4RuntimeSession(), pi_insert));

const sai::WriteRequest pd_modify = gutil::ParseProtoOrDie<sai::WriteRequest>(
R"pb(
updates {
type: MODIFY
table_entry {
acl_ingress_table_entry {
match { is_ip { value: "0x1" } }
priority: 10
action { forward {} }
}
}
}
)pb");
ASSERT_OK_AND_ASSIGN(p4::v1::WriteRequest pi_modify,
pdpi::PdWriteRequestToPi(IrP4Info(), pd_modify));
ASSERT_OK(
pdpi::SetMetadataAndSendPiWriteRequest(SutP4RuntimeSession(), pi_modify));
// This used to fail with a read error, see b/185508142.
ASSERT_OK(pdpi::ClearTableEntries(SutP4RuntimeSession()));
}

TEST_P(SmokeTestFixture, InsertTableEntry) {
const sai::TableEntry pd_entry = gutil::ParseProtoOrDie<sai::TableEntry>(
R"pb(
Expand Down Expand Up @@ -89,8 +129,9 @@ TEST_P(SmokeTestFixture, InsertAndReadTableEntries) {

p4::v1::ReadRequest read_request;
read_request.add_entities()->mutable_table_entry();
ASSERT_OK_AND_ASSIGN(p4::v1::ReadResponse read_response,
pdpi::SetMetadataAndSendPiReadRequest(session, read_request));
ASSERT_OK_AND_ASSIGN(
p4::v1::ReadResponse read_response,
pdpi::SetMetadataAndSendPiReadRequest(session, read_request));

for (const auto& entity : read_response.entities()) {
ASSERT_OK(test_environment.AppendToTestArtifact(
Expand Down
2 changes: 2 additions & 0 deletions tests/gnoi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ cc_library(
"//thinkit:mirror_testbed_fixture",
"@com_github_gnoi//diag:diag_cc_proto",
"@com_github_google_glog//:glog",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/flags:flag",
"@com_github_grpc_grpc//:grpc++",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
Expand Down
Loading
Loading