Commit 830b726a authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[3328] Addressed review comments

Fixed typos and replaced used of DHCPv<n> with b10-dhcp<n> in
D2 relevant sections of the admin guide.
Added sender_ip and max_queue_size value to dhcp4 and dhcp6 unit
tests.
Added used of DFT constants in D2ClientCfg default constructor.
parent 94f8425e
This diff is collapsed.
......@@ -88,9 +88,11 @@ Dhcp4SrvD2Test::reset() {
void
Dhcp4SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
const std::string& ip_address,
const uint32_t port,
const uint32_t sender_port) {
const std::string& server_ip,
const size_t port,
const std::string& sender_ip,
const size_t sender_port,
const size_t max_queue_size) {
std::ostringstream config;
config <<
"{ \"interfaces\": [ \"*\" ],"
......@@ -101,9 +103,11 @@ Dhcp4SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
" \"subnet\": \"192.0.2.0/24\" } ],"
" \"dhcp-ddns\" : {"
" \"enable-updates\" : " << (enable_d2 ? "true" : "false") << ", "
" \"server-ip\" : \"" << ip_address << "\", "
" \"server-ip\" : \"" << server_ip << "\", "
" \"server-port\" : " << port << ", "
" \"sender-ip\" : \"" << sender_ip << "\", "
" \"sender-port\" : " << sender_port << ", "
" \"max-queue-size\" : " << max_queue_size << ", "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"always-include-fqdn\" : true, "
......@@ -167,10 +171,10 @@ TEST_F(Dhcp4SrvD2Test, enableDisable) {
ASSERT_FALSE(mgr.amSending());
}
// Tests Dhcp4 server's ability to correctly handle a flawed dhcp-ddns configuration.
// It does so by first enabling updates by submitting a valid configuration and then
// ensuring they remain on after submitting a flawed configuration.
// and then invoking its startD2() method.
// Tests Dhcp4 server's ability to correctly handle a flawed dhcp-ddns
// configuration. It does so by first enabling updates by submitting a valid
// configuration and then ensuring they remain on after submitting a flawed
// configuration and then invoking its startD2() method.
TEST_F(Dhcp4SrvD2Test, badConfig) {
// Grab the manager and verify that be default ddns is off
// and a sender was not started.
......@@ -297,7 +301,8 @@ TEST_F(Dhcp4SrvD2Test, forceUDPSendFailure) {
// Using server address of 0.0.0.0/0 should induce failure on send.
// Pass in a non-zero sender port to avoid validation error when
// server-ip/port are same as sender-ip/port
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "0.0.0.0", 0, 53001));
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "0.0.0.0", 0,
"0.0.0.0", 53001));
ASSERT_TRUE(mgr.ddnsEnabled());
ASSERT_NO_THROW(srv_.startD2());
ASSERT_TRUE(mgr.amSending());
......
......@@ -77,13 +77,17 @@ public:
///
/// @param enable_updates value to assign to the enable-updates parameter
/// @param exp_result indicates if configuration should pass or fail
/// @param ip_address IP address for the D2 server
/// @param server_ip IP address for the D2 server
/// @param port port for the D2 server
/// @param sender_ip NCR sender's IP address
/// @param sender_port NCR sender port
/// @param max_queue_size maximum number of NCRs allowed in sender's queue
void configureD2(bool enable_updates, bool exp_result = SHOULD_PASS,
const std::string& ip_address = "127.0.0.1",
const uint32_t port = 53001,
const uint32_t sender_port = 0);
const std::string& server_ip = "127.0.0.1",
const size_t port = 53001,
const std::string& sender_ip = "0.0.0.0",
const size_t sender_port = 0,
const size_t max_queue_size = 1024);
/// @brief Configures the server with the given configuration
///
......
......@@ -90,9 +90,11 @@ Dhcp6SrvD2Test::reset() {
void
Dhcp6SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
const std::string& ip_address,
const uint32_t port,
const uint32_t sender_port) {
const std::string& server_ip,
const size_t port,
const std::string& sender_ip,
const size_t sender_port,
const size_t max_queue_size) {
std::ostringstream config;
config <<
"{ \"interfaces\": [ \"*\" ],"
......@@ -105,9 +107,11 @@ Dhcp6SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
" \"subnet\": \"2001:db8:1::/64\" } ],"
" \"dhcp-ddns\" : {"
" \"enable-updates\" : " << (enable_d2 ? "true" : "false") << ", "
" \"server-ip\" : \"" << ip_address << "\", "
" \"server-ip\" : \"" << server_ip << "\", "
" \"server-port\" : " << port << ", "
" \"sender-ip\" : \"" << sender_ip << "\", "
" \"sender-port\" : " << sender_port << ", "
" \"max-queue-size\" : " << max_queue_size << ", "
" \"ncr-protocol\" : \"UDP\", "
" \"ncr-format\" : \"JSON\", "
" \"always-include-fqdn\" : true, "
......@@ -171,10 +175,10 @@ TEST_F(Dhcp6SrvD2Test, enableDisable) {
ASSERT_FALSE(mgr.amSending());
}
// Tests Dhcp6 server's ability to correctly handle a flawed dhcp-ddns configuration.
// It does so by first enabling updates by submitting a valid configuration and then
// ensuring they remain on after submitting a flawed configuration.
// and then invoking its startD2() method.
// Tests Dhcp6 server's ability to correctly handle a flawed dhcp-ddns
// configuration. It does so by first enabling updates by submitting a valid
// configuration and then ensuring they remain on after submitting a flawed
// configuration and then invoking its startD2() method.
TEST_F(Dhcp6SrvD2Test, badConfig) {
// Grab the manager and verify that be default ddns is off
// and a sender was not started.
......@@ -246,7 +250,7 @@ TEST_F(Dhcp6SrvD2Test, differentConfig) {
ASSERT_TRUE(mgr.amSending());
// Now enable it on a different port.
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "127.0.0.1", 54001));
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "::1", 54001));
// Configuration was altered, so ddns should still enabled but not sending.
ASSERT_TRUE(mgr.ddnsEnabled());
......@@ -301,7 +305,8 @@ TEST_F(Dhcp6SrvD2Test, forceUDPSendFailure) {
// Using server address of 0.0.0.0/0 should induce failure on send.
// Pass in a non-zero sender port to avoid validation error when
// server-ip/port are same as sender-ip/port
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "0.0.0.0", 0, 53001));
ASSERT_NO_FATAL_FAILURE(configureD2(true, SHOULD_PASS, "::", 0,
"::", 53001));
ASSERT_TRUE(mgr.ddnsEnabled());
ASSERT_NO_THROW(srv_.startD2());
ASSERT_TRUE(mgr.amSending());
......
......@@ -76,14 +76,17 @@ public:
/// parameters given and passes it into the server's configuration handler.
///
/// @param enable_updates value to assign to the enable-updates parameter
/// @param exp_result indicates if configuration should pass or fail
/// @param ip_address IP address for the D2 server
/// @param server_ip IP address for the D2 server
/// @param port port for the D2 server
/// @param sender_ip NCR sender's IP address
/// @param sender_port NCR sender port
/// @param max_queue_size maximum number of NCRs allowed in sender's queue
void configureD2(bool enable_updates, bool exp_result = SHOULD_PASS,
const std::string& ip_address = "127.0.0.1",
const uint32_t port = 53001,
const uint32_t sender_port = 0);
const std::string& server_ip = "::1",
const size_t port = 53001,
const std::string& sender_ip = "::",
const size_t sender_port = 0,
const size_t max_queue_size = 1024);
/// @brief Configures the server with the given configuration
///
......
......@@ -55,19 +55,19 @@ D2ClientConfig::D2ClientConfig(const bool enable_updates,
const std::string& generated_prefix,
const std::string& qualifying_suffix)
: enable_updates_(enable_updates),
server_ip_(server_ip),
server_port_(server_port),
sender_ip_(sender_ip),
sender_port_(sender_port),
max_queue_size_(max_queue_size),
ncr_protocol_(ncr_protocol),
ncr_format_(ncr_format),
always_include_fqdn_(always_include_fqdn),
override_no_update_(override_no_update),
override_client_update_(override_client_update),
replace_client_name_(replace_client_name),
generated_prefix_(generated_prefix),
qualifying_suffix_(qualifying_suffix) {
server_ip_(server_ip),
server_port_(server_port),
sender_ip_(sender_ip),
sender_port_(sender_port),
max_queue_size_(max_queue_size),
ncr_protocol_(ncr_protocol),
ncr_format_(ncr_format),
always_include_fqdn_(always_include_fqdn),
override_no_update_(override_no_update),
override_client_update_(override_client_update),
replace_client_name_(replace_client_name),
generated_prefix_(generated_prefix),
qualifying_suffix_(qualifying_suffix) {
validateContents();
}
......@@ -75,17 +75,17 @@ D2ClientConfig::D2ClientConfig()
: enable_updates_(false),
server_ip_(isc::asiolink::IOAddress(DFT_SERVER_IP)),
server_port_(DFT_SERVER_PORT),
sender_ip_(isc::asiolink::IOAddress("0.0.0.0")),
sender_port_(0),
max_queue_size_(0),
ncr_protocol_(dhcp_ddns::NCR_UDP),
ncr_format_(dhcp_ddns::FMT_JSON),
always_include_fqdn_(false),
override_no_update_(false),
override_client_update_(false),
replace_client_name_(false),
generated_prefix_("myhost"),
qualifying_suffix_("example.com") {
sender_ip_(isc::asiolink::IOAddress(DFT_V4_SENDER_IP)),
sender_port_(DFT_SENDER_PORT),
max_queue_size_(DFT_MAX_QUEUE_SIZE),
ncr_protocol_(dhcp_ddns::stringToNcrProtocol(DFT_NCR_PROTOCOL)),
ncr_format_(dhcp_ddns::stringToNcrFormat(DFT_NCR_FORMAT)),
always_include_fqdn_(DFT_ALWAYS_INCLUDE_FQDN),
override_no_update_(DFT_OVERRIDE_NO_UPDATE),
override_client_update_(DFT_OVERRIDE_CLIENT_UPDATE),
replace_client_name_(DFT_REPLACE_CLIENT_NAME),
generated_prefix_(DFT_GENERATED_PREFIX),
qualifying_suffix_(DFT_QUALIFYING_SUFFIX) {
validateContents();
}
......
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