Skip to content

Commit 1d6f6fa

Browse files
Ron Hemeta-codesync[bot]
authored andcommitted
Test that two ACL entries may share a priority
Summary: Covers the `(priority, name)` handle key: two entries at one priority program as distinct SAI objects, each reachable by its own name, and removing one leaves the other. Before the re-key the second `addAclEntry` threw. Reviewed By: shri-khare Differential Revision: D116378074 fbshipit-source-id: f8a17988620c7f8c1ffd256f79ab1b9c61cefa65
1 parent 3f197f5 commit 1d6f6fa

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

fboss/agent/hw/sai/switch/tests/AclTableManagerTest.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,54 @@ TEST_F(AclTableManagerTest, addDupAclEntry) {
232232
FbossError);
233233
}
234234

235+
TEST_F(AclTableManagerTest, addTwoAclEntriesSamePriority) {
236+
// 1. Two entries at one priority, told apart only by name.
237+
auto aclEntry =
238+
std::make_shared<AclEntry>(kPriority(), std::string("AclEntry1"));
239+
aclEntry->setDscp(kDscp());
240+
aclEntry->setActionType(kActionType());
241+
242+
auto aclEntry2 =
243+
std::make_shared<AclEntry>(kPriority(), std::string("AclEntry2"));
244+
aclEntry2->setDscp(kDscp2());
245+
aclEntry2->setActionType(kActionType());
246+
247+
// 2. Both program.
248+
AclEntrySaiId aclEntryId = saiManagerTable->aclTableManager().addAclEntry(
249+
aclEntry,
250+
cfg::switch_config_constants::DEFAULT_INGRESS_ACL_TABLE(),
251+
nullptr /*state*/);
252+
AclEntrySaiId aclEntryId2 = saiManagerTable->aclTableManager().addAclEntry(
253+
aclEntry2,
254+
cfg::switch_config_constants::DEFAULT_INGRESS_ACL_TABLE(),
255+
nullptr /*state*/);
256+
257+
// 3. They are distinct SAI objects, each reachable by its own name.
258+
EXPECT_NE(aclEntryId, aclEntryId2);
259+
auto* aclTableHandle = saiManagerTable->aclTableManager().getAclTableHandle(
260+
cfg::switch_config_constants::DEFAULT_INGRESS_ACL_TABLE());
261+
auto* handle1 = saiManagerTable->aclTableManager().getAclEntryHandle(
262+
aclTableHandle, kPriority(), std::string("AclEntry1"));
263+
auto* handle2 = saiManagerTable->aclTableManager().getAclEntryHandle(
264+
aclTableHandle, kPriority(), std::string("AclEntry2"));
265+
ASSERT_NE(handle1, nullptr);
266+
ASSERT_NE(handle2, nullptr);
267+
EXPECT_EQ(handle1->aclEntry->adapterKey(), aclEntryId);
268+
EXPECT_EQ(handle2->aclEntry->adapterKey(), aclEntryId2);
269+
270+
// 4. Removing one leaves the other programmed.
271+
saiManagerTable->aclTableManager().removeAclEntry(
272+
aclEntry, cfg::switch_config_constants::DEFAULT_INGRESS_ACL_TABLE());
273+
EXPECT_EQ(
274+
saiManagerTable->aclTableManager().getAclEntryHandle(
275+
aclTableHandle, kPriority(), std::string("AclEntry1")),
276+
nullptr);
277+
EXPECT_NE(
278+
saiManagerTable->aclTableManager().getAclEntryHandle(
279+
aclTableHandle, kPriority(), std::string("AclEntry2")),
280+
nullptr);
281+
}
282+
235283
TEST_F(AclTableManagerTest, getAclEntry) {
236284
auto aclEntry =
237285
std::make_shared<AclEntry>(kPriority(), std::string("AclEntry1"));

0 commit comments

Comments
 (0)