Parcourir la source

[5252] Addressed review comment

    Unit test now verifies Lease::state_.
Thomas Markwalder il y a 8 ans
Parent
commit
cecf74b413
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc

+ 7 - 1
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc

@@ -1326,7 +1326,7 @@ TEST_F(AllocEngine6Test, addressRenewal) {
     leases = allocateTest(engine, pool_, IOAddress("::"), false, true);
     leases = allocateTest(engine, pool_, IOAddress("::"), false, true);
     ASSERT_EQ(1, leases.size());
     ASSERT_EQ(1, leases.size());
 
 
-    // Assigned count should be one. 
+    // Assigned count should be one.
     EXPECT_TRUE(testStatistics("assigned-nas", 1, subnet_->getID()));
     EXPECT_TRUE(testStatistics("assigned-nas", 1, subnet_->getID()));
 
 
     // This is what the client will send in his renew message.
     // This is what the client will send in his renew message.
@@ -1946,6 +1946,9 @@ TEST_F(AllocEngine6Test, reuseReclaimedExpiredViaRequest) {
     lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
     lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
 
+    // Verify that the lease state is indeed expired-reclaimed
+    EXPECT_EQ(lease->state_, Lease::STATE_EXPIRED_RECLAIMED);
+
     // Same client comes along and issues a request
     // Same client comes along and issues a request
     AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", false,
     AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", false,
                                     Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234)));
                                     Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234)));
@@ -1964,6 +1967,9 @@ TEST_F(AllocEngine6Test, reuseReclaimedExpiredViaRequest) {
     // Now check that the lease in LeaseMgr has the same parameters
     // Now check that the lease in LeaseMgr has the same parameters
     detailCompareLease(lease, from_mgr);
     detailCompareLease(lease, from_mgr);
 
 
+    // Verify that the lease state has been set back to the default.
+    EXPECT_EQ(lease->state_, Lease::STATE_DEFAULT);
+
     // Verify assigned-nas got bumped.  Reclaimed stats should still
     // Verify assigned-nas got bumped.  Reclaimed stats should still
     // be zero as we artifically marked it reclaimed.
     // be zero as we artifically marked it reclaimed.
     EXPECT_TRUE(testStatistics("assigned-nas", 1, subnet_->getID()));
     EXPECT_TRUE(testStatistics("assigned-nas", 1, subnet_->getID()));