|
@@ -330,81 +330,14 @@ TEST_F(MySqlLeaseMgrTest, testAddGetDelete6) {
|
|
testAddGetDelete6(false);
|
|
testAddGetDelete6(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/// @brief Basic Lease4 Checks
|
|
/// @brief Basic Lease4 Checks
|
|
///
|
|
///
|
|
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
|
|
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
|
|
/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id.
|
|
/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id.
|
|
/// (client-id is optional and may not be present)
|
|
/// (client-id is optional and may not be present)
|
|
TEST_F(MySqlLeaseMgrTest, lease4NullClientId) {
|
|
TEST_F(MySqlLeaseMgrTest, lease4NullClientId) {
|
|
- // Get the leases to be used for the test.
|
|
|
|
- vector<Lease4Ptr> leases = createLeases4();
|
|
|
|
-
|
|
|
|
- // Let's clear client-id pointers
|
|
|
|
- leases[1]->client_id_ = ClientIdPtr();
|
|
|
|
- leases[2]->client_id_ = ClientIdPtr();
|
|
|
|
- leases[3]->client_id_ = ClientIdPtr();
|
|
|
|
-
|
|
|
|
- // Start the tests. Add three leases to the database, read them back and
|
|
|
|
- // check they are what we think they are.
|
|
|
|
- EXPECT_TRUE(lmptr_->addLease(leases[1]));
|
|
|
|
- EXPECT_TRUE(lmptr_->addLease(leases[2]));
|
|
|
|
- EXPECT_TRUE(lmptr_->addLease(leases[3]));
|
|
|
|
- lmptr_->commit();
|
|
|
|
-
|
|
|
|
- // Reopen the database to ensure that they actually got stored.
|
|
|
|
- reopen();
|
|
|
|
-
|
|
|
|
- Lease4Ptr l_returned = lmptr_->getLease4(ioaddress4_[1]);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[1], l_returned);
|
|
|
|
-
|
|
|
|
- l_returned = lmptr_->getLease4(ioaddress4_[2]);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[2], l_returned);
|
|
|
|
-
|
|
|
|
- l_returned = lmptr_->getLease4(ioaddress4_[3]);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[3], l_returned);
|
|
|
|
-
|
|
|
|
- // Check that we can't add a second lease with the same address
|
|
|
|
- EXPECT_FALSE(lmptr_->addLease(leases[1]));
|
|
|
|
-
|
|
|
|
- // Check that we can get the lease by HWAddr
|
|
|
|
- HWAddr tmp(leases[2]->hwaddr_, HTYPE_ETHER);
|
|
|
|
- Lease4Collection returned = lmptr_->getLease4(tmp);
|
|
|
|
- ASSERT_EQ(1, returned.size());
|
|
|
|
- detailCompareLease(leases[2], *returned.begin());
|
|
|
|
-
|
|
|
|
- l_returned = lmptr_->getLease4(tmp, leases[2]->subnet_id_);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[2], l_returned);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // Check that we can update the lease
|
|
|
|
- // Modify some fields in lease 1 (not the address) and update it.
|
|
|
|
- ++leases[1]->subnet_id_;
|
|
|
|
- leases[1]->valid_lft_ *= 2;
|
|
|
|
- lmptr_->updateLease4(leases[1]);
|
|
|
|
-
|
|
|
|
- // ... and check that the lease is indeed updated
|
|
|
|
- l_returned = lmptr_->getLease4(ioaddress4_[1]);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[1], l_returned);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // Delete a lease, check that it's gone, and that we can't delete it
|
|
|
|
- // a second time.
|
|
|
|
- EXPECT_TRUE(lmptr_->deleteLease(ioaddress4_[1]));
|
|
|
|
- l_returned = lmptr_->getLease4(ioaddress4_[1]);
|
|
|
|
- EXPECT_FALSE(l_returned);
|
|
|
|
- EXPECT_FALSE(lmptr_->deleteLease(ioaddress4_[1]));
|
|
|
|
-
|
|
|
|
- // Check that the second address is still there.
|
|
|
|
- l_returned = lmptr_->getLease4(ioaddress4_[2]);
|
|
|
|
- ASSERT_TRUE(l_returned);
|
|
|
|
- detailCompareLease(leases[2], l_returned);
|
|
|
|
-
|
|
|
|
|
|
+ testLease4NullClientId();
|
|
}
|
|
}
|
|
|
|
|
|
/// @brief Verify that too long hostname for Lease4 is not accepted.
|
|
/// @brief Verify that too long hostname for Lease4 is not accepted.
|