]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4184] Updated last UTs
authorFrancis Dupont <fdupont@isc.org>
Thu, 11 Dec 2025 14:57:29 +0000 (15:57 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 11 Dec 2025 22:34:26 +0000 (23:34 +0100)
src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc

index c2705f37f993ff3709bf8630244092125f344813..e97c1f98ffd9dce455055275135183e601c12a0b 100644 (file)
@@ -339,7 +339,8 @@ TEST_F(HAImplTest, buffer4Receive) {
     // Domain name should not be skipped because the vendor option was truncated.
     EXPECT_TRUE(query4->getOption(DHO_DOMAIN_NAME));
 
-    // Drop statistics should not change.
+    // Drop statistics should have been increased.
+    EXPECT_EQ(1, getStatistic("pkt4-parse-failed"));
     EXPECT_EQ(1, getStatistic("pkt4-receive-drop"));
 }
 
@@ -399,6 +400,7 @@ TEST_F(HAImplTest, subnet4Select) {
     EXPECT_TRUE(query4->inClass("HA_server3"));
 
     // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-use"));
     EXPECT_EQ(0, getStatistic("pkt4-receive-drop"));
 }
 
@@ -461,6 +463,7 @@ TEST_F(HAImplTest, subnet4SelectSharedNetwork) {
     EXPECT_TRUE(query4->inClass("HA_server3"));
 
     // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-us"));
     EXPECT_EQ(0, getStatistic("pkt4-receive-drop"));
 }
 
@@ -504,6 +507,7 @@ TEST_F(HAImplTest, subnet4SelectSingleRelationship) {
     EXPECT_TRUE(query4->getClasses().empty());
 
     // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-us"));
     EXPECT_EQ(0, getStatistic("pkt4-receive-drop"));
 }
 
@@ -551,6 +555,7 @@ TEST_F(HAImplTest, subnet4SelectDropNoServerName) {
     EXPECT_TRUE(query4->getClasses().empty());
 
     // Drop statistics should have been increased.
+    EXPECT_EQ(1, getStatistic("pkt4-not-for-us"));
     EXPECT_EQ(1, getStatistic("pkt4-receive-drop"));
 }
 
@@ -602,6 +607,8 @@ TEST_F(HAImplTest, subnet4SelectDropInvalidServerNameType) {
     EXPECT_TRUE(query4->getClasses().empty());
 
     // Drop statistics should have been increased.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt4-processing-failed"));
     EXPECT_EQ(1, getStatistic("pkt4-receive-drop"));
 }
 
@@ -796,6 +803,10 @@ TEST_F(HAImplTest, buffer6Receive) {
     EXPECT_EQ(DHCPV6_SOLICIT, static_cast<int>(query6->getType()));
     // Domain name should be skipped because the vendor option was truncated.
     EXPECT_FALSE(query6->getOption(D6O_NIS_DOMAIN_NAME));
+
+    // Drop statistics should have been increased.
+    EXPECT_EQ(1, getStatistic("pkt6-parse-failed"));
+    EXPECT_EQ(1, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests subnet6_select callout implementation when the server name
@@ -852,6 +863,10 @@ TEST_F(HAImplTest, subnet6Select) {
     // to which the query belongs.
     ASSERT_EQ(1, query6->getClasses().size());
     EXPECT_TRUE(query6->inClass("HA_server3"));
+
+    // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-use"));
+    EXPECT_EQ(0, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests subnet6_select callout implementation when the server name
@@ -913,6 +928,7 @@ TEST_F(HAImplTest, subnet6SelectSharedNetwork) {
     EXPECT_TRUE(query6->inClass("HA_server3"));
 
     // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-us"));
     EXPECT_EQ(0, getStatistic("pkt6-receive-drop"));
 }
 
@@ -956,6 +972,7 @@ TEST_F(HAImplTest, subnet6SelectSingleRelationship) {
     EXPECT_TRUE(query6->getClasses().empty());
 
     // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-us"));
     EXPECT_EQ(0, getStatistic("pkt6-receive-drop"));
 }
 
@@ -1003,6 +1020,7 @@ TEST_F(HAImplTest, subnet6SelectDropNoServerName) {
     EXPECT_TRUE(query6->getClasses().empty());
 
     // Drop statistics should have been increased.
+    EXPECT_EQ(1, getStatistic("pkt6-not-for-us"));
     EXPECT_EQ(1, getStatistic("pkt6-receive-drop"));
 }
 
@@ -1054,6 +1072,8 @@ TEST_F(HAImplTest, subnet6SelectDropInvalidServerNameType) {
     EXPECT_TRUE(query6->getClasses().empty());
 
     // Drop statistics should have been increased.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt6-processing-failed"));
     EXPECT_EQ(1, getStatistic("pkt6-receive-drop"));
 }
 
@@ -1243,6 +1263,10 @@ TEST_F(HAImplTest, leases4Committed) {
     // be set to "park".
     EXPECT_EQ(CalloutHandle::NEXT_STEP_PARK, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query4));
+
+    // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-us"));
+    EXPECT_EQ(0, getStatistic("pkt4-receive-drop"));
 }
 
 // Tests leases4_committed callout implementation for multiple relationships.
@@ -1299,6 +1323,10 @@ TEST_F(HAImplTest, leases4CommittedMultipleRelationships) {
     // there was no error during the callout.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_PARK, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query4));
+
+    // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt4-not-for-us"));
+    EXPECT_EQ(0, getStatistic("pkt4-receive-drop"));
 }
 
 // Tests leases4_committed callout implementation for multiple relationships when
@@ -1352,6 +1380,10 @@ TEST_F(HAImplTest, leases4CommittedMultipleRelationshipsNoServerName) {
     // The relationship was not found so the packet should be dropped.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_DROP, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query4));
+
+    // Drop statistics should have beeb increased.
+    EXPECT_EQ(1, getStatistic("pkt4-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt4-receive-drop"));
 }
 
 // Tests leases4_committed callout implementation for multiple relationships when
@@ -1408,6 +1440,10 @@ TEST_F(HAImplTest, leases4CommittedMultipleRelationshipsInvalidServerName) {
     // The relationship was not found so the packet should be dropped.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_DROP, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query4));
+
+    // Drop statistics should have beeb increased.
+    EXPECT_EQ(1, getStatistic("pkt4-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt4-receive-drop"));
 }
 
 // Tests leases6_committed callout implementation.
@@ -1494,6 +1530,10 @@ TEST_F(HAImplTest, leases6Committed) {
     // be set to "park".
     EXPECT_EQ(CalloutHandle::NEXT_STEP_PARK, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query6));
+
+    // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-us"));
+    EXPECT_EQ(0, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests leases6_committed callout implementation for multiple relationships.
@@ -1549,6 +1589,10 @@ TEST_F(HAImplTest, leases6CommittedMultipleRelationships) {
     // there was no error during the callout.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_PARK, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query6));
+
+    // Drop statistics should not increase.
+    EXPECT_EQ(0, getStatistic("pkt6-not-for-us"));
+    EXPECT_EQ(0, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests leases6_committed callout implementation for multiple relationships when
@@ -1601,6 +1645,10 @@ TEST_F(HAImplTest, leases6CommittedMultipleRelationshipsNoServerName) {
     // The relationship was not found so the packet should be dropped.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_DROP, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query6));
+
+    // Drop statistics should have beeb increased.
+    EXPECT_EQ(1, getStatistic("pkt6-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests leases6_committed callout implementation for multiple relationships when
@@ -1656,6 +1704,10 @@ TEST_F(HAImplTest, leases6CommittedMultipleRelationshipsInvalidServerName) {
     // The relationship was not found so the packet should be dropped.
     EXPECT_EQ(CalloutHandle::NEXT_STEP_DROP, callout_handle->getStatus());
     EXPECT_TRUE(callout_handle->getParkingLotHandlePtr()->drop(query6));
+
+    // Drop statistics should have beeb increased.
+    EXPECT_EQ(1, getStatistic("pkt6-not-for-us"));
+    EXPECT_EQ(1, getStatistic("pkt6-receive-drop"));
 }
 
 // Tests lease4_expire callout implementation when the server is a hub