From: Razvan Becheriu Date: Fri, 16 Oct 2020 14:19:18 +0000 (+0300) Subject: [#1434] fixed unittests X-Git-Tag: Kea-1.9.1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c41f2f2cfb91653c9eb273a31f2b882dbc1b4d62;p=thirdparty%2Fkea.git [#1434] fixed unittests --- diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 2cd36c87cc..e8053d364f 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -416,7 +416,9 @@ public: // Purposely using high cltt and valid lifetime to test that // expiration time is cast properly. lease->valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime + lease->old_valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime lease->cltt_ = DEC_2030_TIME; // December 11th 2030 + lease->old_cltt_ = DEC_2030_TIME; // December 11th 2030 if (declined) { lease->state_ = Lease::STATE_DECLINED; } @@ -456,7 +458,9 @@ public: // Purposely using high cltt and valid lifetime to test that // expiration time is cast properly. lease->valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime + lease->old_valid_lft_ = HIGH_VALID_LIFETIME; // Very high valid lifetime lease->cltt_ = DEC_2030_TIME; // December 11th 2030 + lease->old_cltt_ = DEC_2030_TIME; // December 11th 2030 if (declined) { lease->state_ = Lease::STATE_DECLINED; } @@ -3646,7 +3650,9 @@ TEST_F(LeaseCmdsTest, Lease4UpdateNoLease) { " \"hostname\": \"newhostname.example.org\"" " }\n" "}"; - string exp_rsp = "failed to update the lease with address 192.0.2.1 - no such lease"; + string exp_rsp = "failed to update the lease with address 192.0.2.1 " + "either because the lease has been deleted or it has changed in the " + "database, in both cases a retry might succeed"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); } @@ -3918,7 +3924,9 @@ TEST_F(LeaseCmdsTest, Lease4UpdateDoNotForceCreate) { " \"force-create\": false" " }\n" "}"; - string exp_rsp = "failed to update the lease with address 192.0.2.1 - no such lease"; + string exp_rsp = "failed to update the lease with address 192.0.2.1 " + "either because the lease has been deleted or it has changed in the " + "database, in both cases a retry might succeed"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); checkLease4Stats(44, 0, 0); @@ -4367,7 +4375,9 @@ TEST_F(LeaseCmdsTest, Lease6UpdateNoLease) { " \"hostname\": \"newhostname.example.org\"" " }\n" "}"; - string exp_rsp = "failed to update the lease with address 2001:db8:1::1 - no such lease"; + string exp_rsp = "failed to update the lease with address 2001:db8:1::1 " + "either because the lease has been deleted or it has changed in the " + "database, in both cases a retry might succeed"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); checkLease6Stats(66, 0, 0, 0); @@ -4490,7 +4500,9 @@ TEST_F(LeaseCmdsTest, Lease6UpdateDoNotForceCreate) { " \"force-create\": false" " }\n" "}"; - string exp_rsp = "failed to update the lease with address 2001:db8:1::1 - no such lease"; + string exp_rsp = "failed to update the lease with address 2001:db8:1::1 " + "either because the lease has been deleted or it has changed in the " + "database, in both cases a retry might succeed"; testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp); checkLease6Stats(66, 0, 0, 0); diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index ddbc9b4b41..5227fcebed 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -1416,8 +1416,8 @@ Memfile_LeaseMgr::updateLease4Internal(const Lease4Ptr& lease) { Lease4StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_); if (lease_it == index.end()) { valid = false; - } else if ((!persist) && (((*lease_it)->old_cltt_ != lease->old_cltt_) || - ((*lease_it)->old_valid_lft_ != lease->old_valid_lft_))) { + } else if ((!persist) && (((*lease_it)->cltt_ != lease->old_cltt_) || + ((*lease_it)->valid_lft_ != lease->old_valid_lft_))) { valid = false; } @@ -1462,8 +1462,8 @@ Memfile_LeaseMgr::updateLease6Internal(const Lease6Ptr& lease) { Lease6StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_); if (lease_it == index.end()) { valid = false; - } else if ((!persist) && (((*lease_it)->old_cltt_ != lease->old_cltt_) || - ((*lease_it)->old_valid_lft_ != lease->old_valid_lft_))) { + } else if ((!persist) && (((*lease_it)->cltt_ != lease->old_cltt_) || + ((*lease_it)->valid_lft_ != lease->old_valid_lft_))) { valid = false; } @@ -1513,10 +1513,10 @@ Memfile_LeaseMgr::deleteLeaseInternal(const Lease4Ptr& lease) { lease_copy.valid_lft_ = 0; lease_file4_->append(lease_copy); } else { - // for test purpose only to check that an actual database + // For test purpose only: check that an actual database // implementation action is atomic - if ((*l)->old_cltt_ != lease->old_cltt_ || - (*l)->old_valid_lft_ != lease->old_valid_lft_) { + if ((*l)->cltt_ != lease->old_cltt_ || + (*l)->valid_lft_ != lease->old_valid_lft_) { return false; } } @@ -1555,10 +1555,10 @@ Memfile_LeaseMgr::deleteLeaseInternal(const Lease6Ptr& lease) { lease_copy.preferred_lft_ = 0; lease_file6_->append(lease_copy); } else { - // for test purpose only to check that an actual database + // For test purpose only: check that an actual database // implementation action is atomic - if ((*l)->old_cltt_ != lease->old_cltt_ || - (*l)->old_valid_lft_ != lease->old_valid_lft_) { + if ((*l)->cltt_ != lease->old_cltt_ || + (*l)->valid_lft_ != lease->old_valid_lft_) { return false; } }