Skip to content

Commit

Permalink
Fix p4orch unit test after rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
mint570 committed Aug 4, 2022
1 parent e27bd14 commit e41cdb7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions orchagent/p4orch/acl_table_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ AclTableManager::AclTableManager(P4OidMapper *p4oidMapper, ResponsePublisherInte
AclTableManager::~AclTableManager()
{
sai_object_id_t udf_match_oid;
if (!m_p4OidMapper->getOID(SAI_OBJECT_TYPE_UDF_MATCH, P4_UDF_MATCH_DEFAULT, &udf_match_oid))
if (!m_p4OidMapper->getOID(SAI_OBJECT_TYPE_UDF_MATCH, P4_UDF_MATCH_DEFAULT, &udf_match_oid))
{
return;
}
Expand Down Expand Up @@ -181,8 +181,7 @@ ReturnCodeOr<std::vector<sai_attribute_t>> AclTableManager::getUdfSaiAttrs(const
{
// Create the default UDF match
LOG_AND_RETURN_IF_ERROR(createDefaultUdfMatch()
<< "Failed to create ACL UDF default match "
<< QuotedVar(P4_UDF_MATCH_DEFAULT));
<< "Failed to create ACL UDF default match " << QuotedVar(P4_UDF_MATCH_DEFAULT));
m_p4OidMapper->getOID(SAI_OBJECT_TYPE_UDF_MATCH, P4_UDF_MATCH_DEFAULT, &udf_match_oid);
}
std::vector<sai_attribute_t> udf_attrs;
Expand Down
8 changes: 8 additions & 0 deletions orchagent/p4orch/tests/acl_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ TEST_F(AclManagerTest, DrainTableTuplesToProcessSetDelRequestSucceeds)
.WillOnce(DoAll(SetArgPointee<0>(kAclTableIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_acl_, create_acl_table_group_member(_, Eq(gSwitchId), Eq(3), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kAclGroupMemberIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_match(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfMatchOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_group(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfGroupOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf(_, _, _, _))
Expand Down Expand Up @@ -1120,6 +1122,8 @@ TEST_F(AclManagerTest, DrainTableTuplesToProcessUpdateRequestExpectFails)
.WillOnce(DoAll(SetArgPointee<0>(kAclTableIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_acl_, create_acl_table_group_member(_, Eq(gSwitchId), Eq(3), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kAclGroupMemberIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_match(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfMatchOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_group(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfGroupOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf(_, _, _, _))
Expand Down Expand Up @@ -4569,6 +4573,8 @@ TEST_F(AclManagerTest, AclTableVerifyStateTest)
.WillOnce(DoAll(SetArgPointee<0>(kAclTableIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_acl_, create_acl_table_group_member(_, Eq(gSwitchId), Eq(3), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kAclGroupMemberIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_match(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfMatchOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_group(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfGroupOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf(_, _, _, _))
Expand Down Expand Up @@ -5063,6 +5069,8 @@ TEST_F(AclManagerTest, AclTableVerifyStateAsicDbTest)
.WillOnce(DoAll(SetArgPointee<0>(kAclTableIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_acl_, create_acl_table_group_member(_, Eq(gSwitchId), Eq(3), NotNull()))
.WillOnce(DoAll(SetArgPointee<0>(kAclGroupMemberIngressOid), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_match(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfMatchOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf_group(_, _, _, _))
.WillOnce(DoAll(SetArgPointee<0>(kUdfGroupOid1), Return(SAI_STATUS_SUCCESS)));
EXPECT_CALL(mock_sai_udf_, create_udf(_, _, _, _))
Expand Down
8 changes: 0 additions & 8 deletions orchagent/p4orch/tests/next_hop_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "mock_sai_next_hop.h"
#include "mock_sai_serialize.h"
#include "mock_sai_switch.h"
#include "mock_sai_udf.h"
#include "p4oidmapper.h"
#include "p4orch.h"
#include "return_code.h"
Expand All @@ -41,7 +40,6 @@ extern VRFOrch *gVrfOrch;
extern swss::DBConnector *gAppDb;
extern sai_hostif_api_t *sai_hostif_api;
extern sai_switch_api_t *sai_switch_api;
extern sai_udf_api_t *sai_udf_api;
extern sai_next_hop_api_t *sai_next_hop_api;

namespace
Expand Down Expand Up @@ -223,15 +221,11 @@ class NextHopManagerTest : public ::testing::Test
protected:
NextHopManagerTest() : next_hop_manager_(&p4_oid_mapper_, &publisher_)
{
mock_sai_udf = &mock_sai_udf_;
mock_sai_hostif = &mock_sai_hostif_;
mock_sai_switch = &mock_sai_switch_;
sai_udf_api->create_udf_match = create_udf_match;
sai_udf_api->remove_udf_match = remove_udf_match;
sai_switch_api->get_switch_attribute = mock_get_switch_attribute;
sai_hostif_api->create_hostif_trap = mock_create_hostif_trap;
sai_hostif_api->create_hostif_table_entry = mock_create_hostif_table_entry;
EXPECT_CALL(mock_sai_udf_, create_udf_match(_, _, _, _)).WillOnce(Return(SAI_STATUS_SUCCESS));
EXPECT_CALL(mock_sai_hostif_, create_hostif_table_entry(_, _, _, _)).WillRepeatedly(Return(SAI_STATUS_SUCCESS));
EXPECT_CALL(mock_sai_hostif_, create_hostif_trap(_, _, _, _)).WillOnce(Return(SAI_STATUS_SUCCESS));
EXPECT_CALL(mock_sai_switch_, get_switch_attribute(_, _, _)).WillRepeatedly(Return(SAI_STATUS_SUCCESS));
Expand All @@ -242,7 +236,6 @@ class NextHopManagerTest : public ::testing::Test

~NextHopManagerTest()
{
EXPECT_CALL(mock_sai_udf_, remove_udf_match(_)).WillRepeatedly(Return(SAI_STATUS_SUCCESS));
delete gP4Orch;
delete copp_orch_;
}
Expand Down Expand Up @@ -334,7 +327,6 @@ class NextHopManagerTest : public ::testing::Test
NextHopManager next_hop_manager_;
StrictMock<MockSaiHostif> mock_sai_hostif_;
StrictMock<MockSaiSwitch> mock_sai_switch_;
StrictMock<MockSaiUdf> mock_sai_udf_;
CoppOrch *copp_orch_;
};

Expand Down
6 changes: 3 additions & 3 deletions tests/p4rt/test_l3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog):

# Verify that P4RT key to OID count is same as the original count.
status, fvs = key_to_oid_helper.get_db_info()
assert status == True
assert status == False
assert len(fvs) == len(original_key_oid_info)

# Query application database for nexthop entries.
Expand Down Expand Up @@ -2863,7 +2863,7 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes

# Verify that P4RT key to OID count does not change in Redis DB.
status, fvs = key_to_oid_helper.get_db_info()
assert status == True
assert status == False
assert len(fvs) == len(original_key_oid_info)

# Query application database for tunnel entries.
Expand Down Expand Up @@ -2905,7 +2905,7 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes

# Verify that P4RT key to OID count does not change in Redis DB.
status, fvs = key_to_oid_helper.get_db_info()
assert status == True
assert status == False
assert len(fvs) == len(original_key_oid_info)

# Query application database for nexthop entries.
Expand Down
4 changes: 2 additions & 2 deletions tests/p4rt/test_l3_admit.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_DefaultL3AdmitAddDeletePass(self, dvs, testlog):

# Verify that P4RT key to OID count decremented to orig in Redis DB.
status, fvs = key_to_oid_helper.get_db_info()
assert status == True
assert status == False
assert len(fvs) == len(original_key_oid_info)

# Query application database for route entries.
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_InvalidL3AdmitKeyFailsToCreate(self, dvs, testlog):

# Verify that P4RT key to OID count not changed in Redis DB
status, fvs = key_to_oid_helper.get_db_info()
assert status == True
assert status == False
assert len(fvs) == len(original_key_oid_info)

# Query ASIC database for my mac entries. Count remains the same
Expand Down

0 comments on commit e41cdb7

Please sign in to comment.