2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#3375] Addressed comments

This commit is contained in:
Francis Dupont
2024-06-10 10:38:08 +02:00
parent 91378b3ae1
commit 3e93864b4f
6 changed files with 155 additions and 3 deletions

View File

@@ -278,7 +278,7 @@ This debug message is issued when no host was found using the specified
subnet id and host identifier.
% HOSTS_CFG_UPDATE_ADD add the host for reservations: %1
This debug message is issued when new host (with reservations) is
This debug message is issued when a new host (with reservations) is
added to the server's configuration during an update. The argument
describes the host and its reservations in detail.

View File

@@ -72,6 +72,7 @@ public:
void testDeleteForIPv4();
void testDeleteForIPv6();
void testDelete2ForIPv6();
void testDeleteBothForIPv6();
void testDel4();
void testDel6();
void testDeleteAll4();
@@ -719,7 +720,7 @@ TEST_F(CfgHostsTest, deleteForIPv6MultiThreading) {
void
CfgHostsTest::testDelete2ForIPv6() {
CfgHosts cfg;
// Add host with two addresses.
// Add a host with two addresses.
IOAddress address1("2001:db8:1::1");
IOAddress address2("2001:db8:2::2");
size_t host_count = 10;
@@ -732,7 +733,7 @@ CfgHostsTest::testDelete2ForIPv6() {
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, address2));
cfg.add(host);
// Delete one host using first address.
// Delete the host using its first address.
EXPECT_TRUE(cfg.del(subnet_id, address1));
// Check if all addresses were removed.
@@ -749,6 +750,41 @@ TEST_F(CfgHostsTest, delete2ForIPv6MultiThreading) {
testDelete2ForIPv6();
}
// This test checks that IPv6 address and prefix reservations for the specified
// subnet ID and IPv6 address can be deleted.
void
CfgHostsTest::testDeleteBothForIPv6() {
CfgHosts cfg;
// Add a host with two addresses.
IOAddress address1("2001:db8:1::1");
IOAddress address2("2001:db8:2::");
size_t host_count = 10;
SubnetID subnet_id(42);
HostPtr host = HostPtr(new Host(duids_[0]->toText(), "duid",
SUBNET_ID_UNUSED, subnet_id,
IOAddress::IPV4_ZERO_ADDRESS()));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, address1));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_PD, address2, 64));
cfg.add(host);
// Delete the host using its address.
EXPECT_TRUE(cfg.del(subnet_id, address1));
// Check if all reservations were removed.
EXPECT_FALSE(cfg.get6(subnet_id, address2));
EXPECT_FALSE(cfg.del(subnet_id, address2));
}
TEST_F(CfgHostsTest, deleteBothForIPv6) {
testDeleteBothForIPv6();
}
TEST_F(CfgHostsTest, deleteBothForIPv6MultiThreading) {
MultiThreadingTest mt(true);
testDeleteBothForIPv6();
}
// This test checks that false is returned for deleting the IPv4 reservation
// that doesn't exist.
TEST_F(CfgHostsTest, deleteForMissingIPv4) {

View File

@@ -1443,6 +1443,32 @@ TEST_F(MySqlHostDataSourceTest, deleteById6OptionsMultiThreading) {
testDeleteById6Options();
}
// This test verifies that all reservations can be deleted from database
// by providing subnet ID and one address.
TEST_F(MySqlHostDataSourceTest, del2) {
testDelete2ForIPv6();
}
// This test verifies that all reservations can be deleted from database
// by providing subnet ID and one address.
TEST_F(MySqlHostDataSourceTest, del2MultiThreading) {
MultiThreadingTest mt(true);
testDelete2ForIPv6();
}
// This test verifies that address and PD reservations can be deleted from database
// by providing subnet ID and the address.
TEST_F(MySqlHostDataSourceTest, delBoth) {
testDelete2ForIPv6();
}
// This test verifies that address and PD reservations can be deleted from database
// by providing subnet ID and the address.
TEST_F(MySqlHostDataSourceTest, delBothMultiThreading) {
MultiThreadingTest mt(true);
testDelete2ForIPv6();
}
/// @brief Tests that multiple reservations without IPv4 addresses can be
/// specified within a subnet.
TEST_F(MySqlHostDataSourceTest, testMultipleHostsNoAddress4) {

View File

@@ -1411,6 +1411,32 @@ TEST_F(PgSqlHostDataSourceTest, deleteById6OptionsMultiThreading) {
testDeleteById6Options();
}
// This test verifies that all reservations can be deleted from database
// by providing subnet ID and one address.
TEST_F(PgSqlHostDataSourceTest, del2) {
testDelete2ForIPv6();
}
// This test verifies that all reservations can be deleted from database
// by providing subnet ID and one address.
TEST_F(PgSqlHostDataSourceTest, del2MultiThreading) {
MultiThreadingTest mt(true);
testDelete2ForIPv6();
}
// This test verifies that address and PD reservations can be deleted from database
// by providing subnet ID and the address.
TEST_F(PgSqlHostDataSourceTest, delBoth) {
testDelete2ForIPv6();
}
// This test verifies that address and PD reservations can be deleted from database
// by providing subnet ID and the address.
TEST_F(PgSqlHostDataSourceTest, delBothMultiThreading) {
MultiThreadingTest mt(true);
testDelete2ForIPv6();
}
/// @brief Tests that multiple reservations without IPv4 addresses can be
/// specified within a subnet.
TEST_F(PgSqlHostDataSourceTest, testMultipleHostsNoAddress4) {

View File

@@ -2619,6 +2619,62 @@ GenericHostDataSourceTest::testDeleteById6Options() {
EXPECT_FALSE(result);
}
void
GenericHostDataSourceTest::testDelete2ForIPv6() {
// Make sure we have a pointer to the host data source.
ASSERT_TRUE(hdsptr_);
// Let's create a v6 host...
IOAddress address1("2001:db8:1::1");
IOAddress address2("2001:db8:2::2");
SubnetID subnet_id(42);
auto ident = HostDataSourceUtils::generateIdentifier(Host::IDENT_DUID);
HostPtr host = HostPtr(new Host(&ident[0], ident.size(), Host::IDENT_DUID,
SUBNET_ID_UNUSED, subnet_id,
IOAddress::IPV4_ZERO_ADDRESS()));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, address1));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, address2));
// ... and add it to the data source.
ASSERT_NO_THROW(hdsptr_->add(host));
EXPECT_EQ(2, countDBReservations6());
// Delete the host using its first address.
EXPECT_TRUE(hdsptr_->del(subnet_id, address1));
// Check if all addresses were removed.
EXPECT_EQ(0, countDBReservations6());
EXPECT_FALSE(hdsptr_->get6(subnet_id, address2));
EXPECT_FALSE(hdsptr_->del(subnet_id, address2));
}
void
GenericHostDataSourceTest::testDeleteBothForIPv6() {
// Make sure we have a pointer to the host data source.
ASSERT_TRUE(hdsptr_);
// Let's create a v6 host...
IOAddress address1("2001:db8:1::1");
IOAddress address2("2001:db8:2::");
SubnetID subnet_id(42);
auto ident = HostDataSourceUtils::generateIdentifier(Host::IDENT_DUID);
HostPtr host = HostPtr(new Host(&ident[0], ident.size(), Host::IDENT_DUID,
SUBNET_ID_UNUSED, subnet_id,
IOAddress::IPV4_ZERO_ADDRESS()));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_NA, address1));
host->addReservation(IPv6Resrv(IPv6Resrv::TYPE_PD, address2, 64));
// ... and add it to the data source.
ASSERT_NO_THROW(hdsptr_->add(host));
EXPECT_EQ(2, countDBReservations6());
// Delete the host using its address.
EXPECT_TRUE(hdsptr_->del(subnet_id, address1));
// Check if all reservations were removed.
EXPECT_EQ(0, countDBReservations6());
EXPECT_FALSE(hdsptr_->get6(subnet_id, address2));
EXPECT_FALSE(hdsptr_->del(subnet_id, address2));
}
void
GenericHostDataSourceTest::testMultipleHostsNoAddress4() {
// Make sure we have a pointer to the host data source.

View File

@@ -508,6 +508,14 @@ public:
/// Uses gtest macros to report failures.
void testDeleteById6Options();
/// @brief Tests that two IPv6 reservations for the specified subnet ID
/// and IPv6 address can be deleted.
void testDelete2ForIPv6();
/// @brief Tests that IPv6 address and prefix reservations for the specified
/// subnet ID and IPv6 address can be deleted.
void testDeleteBothForIPv6();
/// @brief Tests that multiple reservations without IPv4 addresses can be
/// specified within a subnet.
///