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.
void testDeleteForIPv4();
void testDeleteForIPv6();
void testDelete2ForIPv6();
+ void testDeleteBothForIPv6();
void testDel4();
void testDel6();
void testDeleteAll4();
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;
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.
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) {
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) {
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) {
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.
/// 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.
///