Commit a9b5fc56 authored by Francis Dupont's avatar Francis Dupont
Browse files

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

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