|
@@ -329,9 +329,7 @@ GenericHostDataSourceTest::compareReservations6(IPv6ResrvRange resrv1,
|
|
|
void
|
|
|
GenericHostDataSourceTest::compareClientClasses(const ClientClasses& classes1,
|
|
|
const ClientClasses& classes2) {
|
|
|
- // Currently simple comparison works as ClientClasses derives from
|
|
|
- // std::set<ClientClass>.
|
|
|
- EXPECT_EQ(classes1, classes2);
|
|
|
+ EXPECT_TRUE(std::equal(classes1.begin(), classes1.end(), classes2.begin()));
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -1155,10 +1153,7 @@ void GenericHostDataSourceTest::testOptionsReservations46(const bool formatted)
|
|
|
|
|
|
void
|
|
|
GenericHostDataSourceTest::testMultipleClientClasses4() {
|
|
|
- /// Add host reservation with a multiple v4 client-classes, retrieve it and
|
|
|
- /// make sure that all client classes are retrieved properly.
|
|
|
ASSERT_TRUE(hdsptr_);
|
|
|
- uint8_t len = 128;
|
|
|
|
|
|
// Create the Host object.
|
|
|
HostPtr host = initializeHost4("192.0.2.5", Host::IDENT_HWADDR);
|
|
@@ -1176,18 +1171,50 @@ GenericHostDataSourceTest::testMultipleClientClasses4() {
|
|
|
// Subnet id will be used in quries to the database.
|
|
|
SubnetID subnet_id = host->getIPv4SubnetID();
|
|
|
|
|
|
- // Fetch the host from the source.
|
|
|
- ConstHostPtr from_hds = hdsptr_->get4(subnet_id, IOAddress("192.0.2.5"));
|
|
|
+ // Fetch the host via:
|
|
|
+ // getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
|
|
|
+ ConstHostCollection hosts_by_id = hdsptr_->getAll(host->getHWAddress());
|
|
|
+ ASSERT_EQ(1, hosts_by_id.size());
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, *hosts_by_id.begin()));
|
|
|
+
|
|
|
+ // Fetch the host via:
|
|
|
+ // getAll(const Host::IdentifierType, const uint8_t* identifier_begin,
|
|
|
+ // const size_t identifier_len) const;
|
|
|
+ hosts_by_id = hdsptr_->getAll(host->getIdentifierType(), &host->getIdentifier()[0],
|
|
|
+ host->getIdentifier().size());
|
|
|
+ ASSERT_EQ(1, hosts_by_id.size());
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, *hosts_by_id.begin()));
|
|
|
+
|
|
|
+ // Fetch the host via
|
|
|
+ // getAll4(const asiolink::IOAddress& address) const;
|
|
|
+ hosts_by_id = hdsptr_->getAll4(IOAddress("192.0.2.5"));
|
|
|
+ ASSERT_EQ(1, hosts_by_id.size());
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, *hosts_by_id.begin()));
|
|
|
+
|
|
|
+ // Fetch the host via
|
|
|
+ // get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
|
|
|
+ // const DuidPtr& duid = DuidPtr()) const;
|
|
|
+ ConstHostPtr from_hds = hdsptr_->get4(subnet_id, host->getHWAddress());
|
|
|
ASSERT_TRUE(from_hds);
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
|
|
|
- // Verify they match.
|
|
|
+ // Fetch the host via
|
|
|
+ // get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
|
|
|
+ // const uint8_t* identifier_begin, const size_t identifier_len) const;
|
|
|
+ from_hds = hdsptr_->get4(subnet_id, host->getIdentifierType(), &host->getIdentifier()[0],
|
|
|
+ host->getIdentifier().size());
|
|
|
+ ASSERT_TRUE(from_hds);
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
+
|
|
|
+ // Fetch the host via:
|
|
|
+ // get4(const SubnetID& subnet_id, const asiolink::IOAddress& address) const;
|
|
|
+ from_hds = hdsptr_->get4(subnet_id, IOAddress("192.0.2.5"));
|
|
|
+ ASSERT_TRUE(from_hds);
|
|
|
ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
}
|
|
|
|
|
|
void
|
|
|
GenericHostDataSourceTest::testMultipleClientClasses6() {
|
|
|
- /// Add host reservation with a multiple v6 client-classes, retrieve it and
|
|
|
- /// make sure that all client classes are retrieved properly.
|
|
|
ASSERT_TRUE(hdsptr_);
|
|
|
|
|
|
// Create the Host object.
|
|
@@ -1206,13 +1233,39 @@ GenericHostDataSourceTest::testMultipleClientClasses6() {
|
|
|
// Subnet id will be used in quries to the database.
|
|
|
SubnetID subnet_id = host->getIPv6SubnetID();
|
|
|
|
|
|
- // Fetch the host from the source.
|
|
|
- ConstHostPtr from_hds = hdsptr_->get6(subnet_id, Host::IDENT_HWADDR,
|
|
|
+ // Fetch the host via:
|
|
|
+ // getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) const;
|
|
|
+ ConstHostCollection hosts_by_id = hdsptr_->getAll(host->getHWAddress());
|
|
|
+ ASSERT_EQ(1, hosts_by_id.size());
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, *hosts_by_id.begin()));
|
|
|
+
|
|
|
+ //getAll(const Host::IdentifierType& identifier_type,
|
|
|
+ // const uint8_t* identifier_begin,
|
|
|
+ // const size_t identifier_len) const;
|
|
|
+ hosts_by_id = hdsptr_->getAll(host->getIdentifierType(), &host->getIdentifier()[0],
|
|
|
+ host->getIdentifier().size());
|
|
|
+ ASSERT_EQ(1, hosts_by_id.size());
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, *hosts_by_id.begin()));
|
|
|
+
|
|
|
+ //get6(const SubnetID& subnet_id, const DuidPtr& duid,
|
|
|
+ // const HWAddrPtr& hwaddr = HWAddrPtr()) const;
|
|
|
+ ConstHostPtr from_hds = hdsptr_->get6(subnet_id, DuidPtr(), host->getHWAddress());
|
|
|
+ ASSERT_TRUE(from_hds);
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
+
|
|
|
+ // Fetch the host via:
|
|
|
+ // get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
|
|
|
+ // const uint8_t* identifier_begin, const size_t identifier_len) const;
|
|
|
+ from_hds = hdsptr_->get6(subnet_id, Host::IDENT_HWADDR,
|
|
|
&host->getIdentifier()[0],
|
|
|
host->getIdentifier().size());
|
|
|
ASSERT_TRUE(from_hds);
|
|
|
+ ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
|
|
|
- // Verify they match.
|
|
|
+ // Fetch the host via:
|
|
|
+ // get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) const;
|
|
|
+ from_hds = hdsptr_->get6(IOAddress("2001:db8::1"), 128);
|
|
|
+ ASSERT_TRUE(from_hds);
|
|
|
ASSERT_NO_FATAL_FAILURE(compareHosts(host, from_hds));
|
|
|
}
|
|
|
|