]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4493] Extended perfdhcp test for collected packets.
authorMarcin Siodelski <marcin@isc.org>
Mon, 2 May 2016 13:26:46 +0000 (15:26 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 2 May 2016 13:26:46 +0000 (15:26 +0200)
The extended test verifies that the stats manager is
still usable after some packets have been collected.

src/bin/perfdhcp/tests/stats_mgr_unittest.cc

index d72554313711751a9a3533999470302ca62dc7d4..a65b14da5f0ed975bb56339691828ec007b90235 100644 (file)
@@ -211,7 +211,7 @@ public:
             }
             ASSERT_NO_THROW(
                 stats_mgr->passSentPacket(StatsMgr4::XCHG_DO, sent_packet)
-            );
+            )  << "failure for transaction id " << transid[i];
         }
 
         // Create a server response for one of the packets sent.
@@ -231,6 +231,34 @@ public:
             EXPECT_EQ(TEST_COLLECTED_PKT_NUM / 2,
                       stats_mgr->getCollectedNum(StatsMgr4::XCHG_DO));
         }
+
+        // Make sure that we can still use the StatsMgr. It is possible
+        // that the pointer to 'next sent' packet was invalidated
+        // during packet removal.
+        for (unsigned int i = 0; i < TEST_COLLECTED_PKT_NUM; ++i) {
+            // Increase transaction ids by 1 so as they don't duplicate
+            // with transaction ids of already sent packets.
+            Pkt4ModifiablePtr sent_packet(createPacket4(DHCPDISCOVER,
+                                                    transid[i] + 1));
+            Pkt4ModifiablePtr rcvd_packet(createPacket4(DHCPOFFER,
+                                                        transid[i] + 1));
+            ASSERT_NO_THROW(
+                stats_mgr->passSentPacket(StatsMgr4::XCHG_DO, sent_packet)
+            ) << "failure for transaction id " << transid[i];
+
+            ASSERT_NO_THROW(
+                stats_mgr->passRcvdPacket(StatsMgr4::XCHG_DO, rcvd_packet);
+            ) << "failure for transaction id " << transid[i];
+        }
+
+        // We should have processed TEST_COLLECTED_PKT_NUM but it is possible
+        // that one of them we couldn't match (orphan packet), because
+        // the matched packet had to be collected because of the transaction
+        // timeout. Therefore, we have to count both received packets and
+        // orhpans.
+        EXPECT_EQ(TEST_COLLECTED_PKT_NUM + 1,
+                  stats_mgr->getRcvdPacketsNum(StatsMgr4::XCHG_DO) +
+                  stats_mgr->getOrphans(StatsMgr4::XCHG_DO));
     }
 };