Commit a9b5fc56 authored by Francis Dupont's avatar Francis Dupont

[392-search-of-reservations-by-hostname] Addressed comments

parent df889e1a
......@@ -1231,7 +1231,7 @@ The subnet-id Parameter
Prior to diving into the individual commands, it is worth discussing the
parameter, ``subnet-id``. Currently this parameter is mandatory for all of the
commands supplied by this library at the exception of
commands supplied by this library with the exception of
reservation-get-by-hostname where it is optional.
In previous versions of Kea, reservations had
to belong to a specific subnet; as of Kea 1.5.0, reservations may
......@@ -1687,7 +1687,7 @@ returns some IPv4 hosts:
]
},
"result": 0,
"text": "72 IPv4 host(s) found."
"text": "5 IPv4 host(s) found."
}
The response returned by ``reservation-get-by-hostname`` can be long
......
......@@ -1503,6 +1503,7 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
// lower_case_hostname: text
lower_case_hostname_ = host->getLowerHostname();
if (lower_case_hostname_.size() > HOSTNAME_MAX_LEN) {
// Should never happen...
isc_throw(BadValue, "CqlHostExchange::prepareExchange(): lower "
"case hostname " << lower_case_hostname_ << " of length "
<< lower_case_hostname_.size()
......
......@@ -339,14 +339,14 @@ TEST_F(CqlHostDataSourceTest, getAllbyHostname) {
// Verifies that IPv4 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(CqlHostDataSourceTest, getAllbyHostname4) {
testGetAllbyHostname4();
TEST_F(CqlHostDataSourceTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4();
}
// Verifies that IPv6 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(CqlHostDataSourceTest, getAllbyHostname6) {
testGetAllbyHostname6();
TEST_F(CqlHostDataSourceTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6();
}
// Verifies that IPv4 host reservations in the same subnet can be retrieved
......
......@@ -145,8 +145,8 @@ protected:
/// inserted.
/// @param data_source2 Host data source to which second reservation is
/// inserted.
void testGetAllbyHostname4(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2);
void testGetAllbyHostnameSubnet4(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2);
/// @brief This test verifies that HostMgr returns all reservations for the
/// specified hostname and DHCPv6 subnet.
......@@ -158,8 +158,8 @@ protected:
/// inserted.
/// @param data_source2 Host data source to which second reservation is
/// inserted.
void testGetAllbyHostname6(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2);
void testGetAllbyHostnameSubnet6(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2);
/// @brief This test verifies that HostMgr returns all reservations for the
/// specified DHCPv4 subnet by pages.
......@@ -456,8 +456,8 @@ HostMgrTest::testGetAllbyHostname(BaseHostDataSource& data_source1,
}
void
HostMgrTest::testGetAllbyHostname4(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2) {
HostMgrTest::testGetAllbyHostnameSubnet4(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2) {
// Initially, no reservations should be present.
ConstHostCollection hosts =
HostMgr::instance().getAllbyHostname4("host", SubnetID(1));
......@@ -505,8 +505,8 @@ HostMgrTest::testGetAllbyHostname4(BaseHostDataSource& data_source1,
}
void
HostMgrTest::testGetAllbyHostname6(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2) {
HostMgrTest::testGetAllbyHostnameSubnet6(BaseHostDataSource& data_source1,
BaseHostDataSource& data_source2) {
// Initially, no reservations should be present.
ConstHostCollection hosts =
HostMgr::instance().getAllbyHostname6("host", SubnetID(1));
......@@ -982,15 +982,15 @@ TEST_F(HostMgrTest, getAllbyHostname) {
// This test verifies that HostMgr returns all reservations for the specified
// hostname and DHCPv4 subnet. The reservations are defined in the server's
// configuration.
TEST_F(HostMgrTest, getAllbyHostname4) {
testGetAllbyHostname4(*getCfgHosts(), *getCfgHosts());
TEST_F(HostMgrTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4(*getCfgHosts(), *getCfgHosts());
}
// This test verifies that HostMgr returns all reservations for the specified
// hostname and DHCPv6 subnet. The reservations are defined in the server's
// configuration.
TEST_F(HostMgrTest, getAllbyHostname6) {
testGetAllbyHostname4(*getCfgHosts(), *getCfgHosts());
testGetAllbyHostnameSubnet4(*getCfgHosts(), *getCfgHosts());
}
// This test verifies that HostMgr returns all reservations for the
......@@ -1246,15 +1246,15 @@ TEST_F(MySQLHostMgrTest, getAllbyHostname) {
// This test verifies that reservations for a particular hostname and
// DHCPv4 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(MySQLHostMgrTest, getAllbyHostname4) {
testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
TEST_F(MySQLHostMgrTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular hostname and
// DHCPv6 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(MySQLHostMgrTest, getAllbyHostname6) {
testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
TEST_F(MySQLHostMgrTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular subnet can
......@@ -1391,15 +1391,15 @@ TEST_F(PostgreSQLHostMgrTest, getAllbyHostname) {
// This test verifies that reservations for a particular hostname and
// DHCPv4 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(PostgreSQLHostMgrTest, getAllbyHostname4) {
testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
TEST_F(PostgreSQLHostMgrTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular hostname and
// DHCPv6 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(PostgreSQLHostMgrTest, getAllbyHostname6) {
testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
TEST_F(PostgreSQLHostMgrTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular subnet can
......@@ -1517,15 +1517,15 @@ TEST_F(CQLHostMgrTest, getAllbyHostname) {
// This test verifies that reservations for a particular hostname and
// DHCPv4 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(CQLHostMgrTest, getAllbyHostname4) {
testGetAllbyHostname4(*getCfgHosts(), HostMgr::instance());
TEST_F(CQLHostMgrTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular hostname and
// DHCPv6 subnet can be retrieved from the configuration file and a
// database simultaneously.
TEST_F(CQLHostMgrTest, getAllbyHostname6) {
testGetAllbyHostname6(*getCfgHosts(), HostMgr::instance());
TEST_F(CQLHostMgrTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6(*getCfgHosts(), HostMgr::instance());
}
// This test verifies that reservations for a particular subnet can
......
......@@ -328,14 +328,14 @@ TEST_F(MySqlHostDataSourceTest, getAllbyHostname) {
// Verifies that IPv4 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(MySqlHostDataSourceTest, getAllbyHostname4) {
testGetAllbyHostname4();
TEST_F(MySqlHostDataSourceTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4();
}
// Verifies that IPv6 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(MySqlHostDataSourceTest, getAllbyHostname6) {
testGetAllbyHostname6();
TEST_F(MySqlHostDataSourceTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6();
}
// Verifies that IPv4 host reservations in the same subnet can be retrieved
......
......@@ -314,14 +314,14 @@ TEST_F(PgSqlHostDataSourceTest, getAllbyHostname) {
// Verifies that IPv4 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(PgSqlHostDataSourceTest, getAllbyHostname4) {
testGetAllbyHostname4();
TEST_F(PgSqlHostDataSourceTest, getAllbyHostnameSubnet4) {
testGetAllbyHostnameSubnet4();
}
// Verifies that IPv6 host reservations with the same hostname and in
// the same subnet can be retrieved
TEST_F(PgSqlHostDataSourceTest, getAllbyHostname6) {
testGetAllbyHostname6();
TEST_F(PgSqlHostDataSourceTest, getAllbyHostnameSubnet6) {
testGetAllbyHostnameSubnet6();
}
// Verifies that IPv4 host reservations in the same subnet can be retrieved
......
......@@ -525,7 +525,7 @@ GenericHostDataSourceTest::testGetAllbyHostname() {
}
void
GenericHostDataSourceTest::testGetAllbyHostname4() {
GenericHostDataSourceTest::testGetAllbyHostnameSubnet4() {
// Make sure we have a pointer to the host data source.
ASSERT_TRUE(hdsptr_);
......@@ -549,7 +549,9 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
HostPtr host4 = HostDataSourceUtils::initializeHost4("192.0.2.4", id);
host4->setHostname("host.example.com");
// Set them in the same subnets.
HostPtr host5 = HostDataSourceUtils::initializeHost4("192.0.2.5", id);
// Set them in the same subnet at the exception of host5.
SubnetID subnet4 = host1->getIPv4SubnetID();
host2->setIPv4SubnetID(subnet4);
host3->setIPv4SubnetID(subnet4);
......@@ -564,6 +566,7 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
ASSERT_NO_THROW(hdsptr_->add(host2));
ASSERT_NO_THROW(hdsptr_->add(host3));
ASSERT_NO_THROW(hdsptr_->add(host4));
ASSERT_NO_THROW(hdsptr_->add(host5));
// Retrieve unknown name.
ConstHostCollection from_hds = hdsptr_->getAllbyHostname4("foo", subnet4);
......@@ -606,7 +609,7 @@ GenericHostDataSourceTest::testGetAllbyHostname4() {
}
void
GenericHostDataSourceTest::testGetAllbyHostname6() {
GenericHostDataSourceTest::testGetAllbyHostnameSubnet6() {
// Make sure we have a pointer to the host data source.
ASSERT_TRUE(hdsptr_);
......@@ -630,7 +633,9 @@ GenericHostDataSourceTest::testGetAllbyHostname6() {
HostPtr host4 = HostDataSourceUtils::initializeHost6("2001:db8::4", id, false);
host4->setHostname("host.example.com");
// Set them in the same subnets.
HostPtr host5 = HostDataSourceUtils::initializeHost6("2001:db8::5", id, false);
// Set them in the same subnet at the exception of host5.
SubnetID subnet4 = host1->getIPv4SubnetID();
host2->setIPv4SubnetID(subnet4);
host3->setIPv4SubnetID(subnet4);
......@@ -645,6 +650,7 @@ GenericHostDataSourceTest::testGetAllbyHostname6() {
ASSERT_NO_THROW(hdsptr_->add(host2));
ASSERT_NO_THROW(hdsptr_->add(host3));
ASSERT_NO_THROW(hdsptr_->add(host4));
ASSERT_NO_THROW(hdsptr_->add(host5));
// Retrieve unknown name.
ConstHostCollection from_hds = hdsptr_->getAllbyHostname6("foo", subnet6);
......
......@@ -212,13 +212,13 @@ public:
/// hostname and in the same subnet can be retrieved properly.
///
/// Uses gtest macros to report failures.
void testGetAllbyHostname4();
void testGetAllbyHostnameSubnet4();
/// @brief Test that Verifies that IPv6 host reservations with the same
/// hostname and in the same subnet can be retrieved properly.
///
/// Uses gtest macros to report failures.
void testGetAllbyHostname6();
void testGetAllbyHostnameSubnet6();
/// @brief Test that Verifies that pages of host reservations in the
/// same subnet can be retrieved properly.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment