Commit fe99fae7 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

3087 Addressed review comments

Good deal of commentary clean up, rolled back IOService reference
changes to DNSClient, and most significantly added unit tests
for NameChangeTransaction::sendUpdate.  These tests involve an
actual message exchange.
parent e6df9bca
......@@ -190,7 +190,7 @@ indicate a network connectivity or system resource issue.
% DHCP_DDNS_QUEUE_MGR_RESUME_ERROR application could not restart the queue manager, reason: %1
This is an error message indicating that DHCP_DDNS's Queue Manager could not
be restarted after stopping due to an a full receive queue. This means that
be restarted after stopping due to a full receive queue. This means that
the application cannot receive requests. This is most likely due to DHCP_DDNS
configuration parameters referring to resources such as an IP address or port,
that is no longer unavailable. DHCP_DDNS will attempt to restart the queue
......@@ -260,60 +260,66 @@ of this update did not succeed. This is a programmatic error and should be
reported.
% DHCP_DDNS_FORWARD_ADD_REJECTED DNS Server, %1, rejected a DNS update request to add the address mapping for FQDN, %2, with an RCODE: %3
This is an error message issued when an udpate was rejected by the DNS server itwas sent to for the reason given by the RCODE. The rcode values are defined in
RFC 2136.
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_FORWARD_ADD_IO_ERROR while attempting a request to add a forward address mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an IO error
This is an error message issued when a communication error occurs while DHCP_DDNS is carrying out a forward address update. The application will retry against
the same server or others as appropriate.
% DHCP_DDNS_FORWARD_ADD_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping add for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a forward address update. The application will
retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT while attempting a request to add a forward address mapping to DNS server, %1, for FQDN, %2, DHCP_DDNS received a corrupt response
% DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while adding forward address mapping for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to add a forward address mapping, is mangled or mal-formed.
update request to add a forward address mapping, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_ADD_UNKNOWN_FAILURE while attempting a request to add a forward address mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an unexepected error.
This is an error message issued when a unexpected error condition error occurs
while DHCP_DDNS is carrying out a forward address update. The request will be
be aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while adding a forward address mapping for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was adding a forward address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_FORWARD_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the address mapping for FQDN, %2, with an RCODE: %3
This is an error message issued when an udpate was rejected by the DNS server itwas sent to for the reason given by the RCODE. The rcode values are defined in
RFC 2136.
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_FORWARD_REPLACE_IO_ERROR while attempting a request to replace a forward address mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an IO error
This is an error message issued when a communication error occurs while DHCP_DDNS is carrying out a forward address update. The application will retry against
the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping replace for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a forward address update. The application will
retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT while attempting a request to replace a forward address mapping to DNS server, %1, for FQDN, %2, DHCP_DDNS received a corrupt response
% DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing forward address mapping for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to replace a forward address mapping, is mangled or mal-formed.
update request to replace a forward address mapping, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_FORWARD_REPLACE_UNKNOWN_FAILURE while attempting a request to replace a forward address mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an unexepected error.
This is an error message issued when a unexpected error condition error occurs
while DHCP_DDNS is carrying out a forward address update. The request will be
be aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while replacing forward address mapping for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was replacing a forward address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_REVERSE_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the reverse mapping for FQDN, %2, with an RCODE: %3
This is an error message issued when an udpate was rejected by the DNS server itwas sent to for the reason given by the RCODE. The rcode values are defined in
RFC 2136.
This is an error message issued when an update was rejected by the DNS server
it was sent to for the reason given by the RCODE. The rcode values are defined
in RFC 2136.
% DHCP_DDNS_REVERSE_REPLACE_IO_ERROR while attempting a request to replace a reverse mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an IO error
This is an error message issued when a communication error occurs while DHCP_DDNS is carrying out a reverse address update. The application will retry against
the same server or others as appropriate.
% DHCP_DDNS_REVERSE_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping replacement for FQDN %1 to DNS server %2
This is an error message issued when a communication error occurs while
DHCP_DDNS is carrying out a reverse address update. The application will
retry against the same server or others as appropriate.
% DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT while attempting a request to replace a reverse mapping to DNS server, %1, for FQDN, %2, DHCP_DDNS received a corrupt response
% DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing reverse address mapping for FQDN, %2
This is an error message issued when the response received by DHCP_DDNS, to a
update request to replace a reverse address, is mangled or mal-formed.
update request to replace a reverse address, is mangled or malformed.
The application will retry against the same server or others as appropriate.
% DHCP_DDNS_REVERSE_REPLACE_UNKNOWN_FAILURE while attempting a request to replace a reverse mapping to DNS server %1 for FQDN %2, DHCP_DDNS encountered an unexepected error.
This is an error message issued when a unexpected error condition error occurs
while DHCP_DDNS is carrying out a reverse address update. The request will be
be aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while replacing reverse address mapping for FQDN %2 to DNS server %3
This is an error message issued when DNSClient returns an unrecognized status
while DHCP_DDNS was replacing a reverse address mapping. The request will be
aborted. This is most likely a programmatic issue and should be reported.
% DHCP_DDNS_TRANS_SEND_EROR application encountered an unexpected error while attempting to send an DNS update: %1
% DHCP_DDNS_TRANS_SEND_ERROR application encountered an unexpected error while attempting to send a DNS update: %1
This is error message issued when the application is able to construct an update
message but the attempt to send it suffered a unexpected error. This is most
likely a programmatic error, rather than a communications issue. Some or all
......
......@@ -65,7 +65,7 @@ public:
virtual void operator()(asiodns::IOFetch::Result result);
// Starts asynchronous DNS Update.
void doUpdate(IOServicePtr& io_service,
void doUpdate(asiolink::IOService& io_service,
const asiolink::IOAddress& ns_addr,
const uint16_t ns_port,
D2UpdateMessage& update,
......@@ -162,7 +162,7 @@ DNSClientImpl::getStatus(const asiodns::IOFetch::Result result) {
}
void
DNSClientImpl::doUpdate(IOServicePtr& io_service,
DNSClientImpl::doUpdate(asiolink::IOService& io_service,
const IOAddress& ns_addr,
const uint16_t ns_port,
D2UpdateMessage& update,
......@@ -189,11 +189,12 @@ DNSClientImpl::doUpdate(IOServicePtr& io_service,
// Timeout value is explicitly cast to the int type to avoid warnings about
// overflows when doing implicit cast. It should have been checked by the
// caller that the unsigned timeout value will fit into int.
IOFetch io_fetch(IOFetch::UDP, *io_service, msg_buf, ns_addr, ns_port,
IOFetch io_fetch(IOFetch::UDP, io_service, msg_buf, ns_addr, ns_port,
in_buf_, this, static_cast<int>(wait));
// Post the task to the task queue in the IO service. Caller will actually
// run these tasks by executing IOService::run.
io_service->post(io_fetch);
io_service.post(io_fetch);
}
......@@ -213,7 +214,7 @@ DNSClient::getMaxTimeout() {
}
void
DNSClient::doUpdate(IOServicePtr&,
DNSClient::doUpdate(asiolink::IOService&,
const IOAddress&,
const uint16_t,
D2UpdateMessage&,
......@@ -224,16 +225,11 @@ DNSClient::doUpdate(IOServicePtr&,
}
void
DNSClient::doUpdate(IOServicePtr& io_service,
DNSClient::doUpdate(asiolink::IOService& io_service,
const IOAddress& ns_addr,
const uint16_t ns_port,
D2UpdateMessage& update,
const unsigned int wait) {
if (!io_service) {
isc_throw(isc::BadValue,
"DNSClient::doUpdate: IOService cannot be null");
}
// The underlying implementation which we use to send DNS Updates uses
// signed integers for timeout. If we want to avoid overflows we need to
// respect this limitation here.
......
......@@ -16,8 +16,8 @@
#define DNS_CLIENT_H
#include <d2/d2_update_message.h>
#include <d2/d2_asio.h>
#include <asiolink/io_service.h>
#include <util/buffer.h>
#include <asiodns/io_fetch.h>
......@@ -151,7 +151,7 @@ public:
///
/// @todo Implement TSIG Support. Currently any attempt to call this
/// function will result in exception.
void doUpdate(IOServicePtr& io_service,
void doUpdate(asiolink::IOService& io_service,
const asiolink::IOAddress& ns_addr,
const uint16_t ns_port,
D2UpdateMessage& update,
......@@ -176,7 +176,7 @@ public:
/// @param wait A timeout (in seconds) for the response. If a response is
/// not received within the timeout, exchange is interrupted. This value
/// must not exceed maximal value for 'int' data type.
void doUpdate(IOServicePtr& io_service,
void doUpdate(asiolink::IOService& io_service,
const asiolink::IOAddress& ns_addr,
const uint16_t ns_port,
D2UpdateMessage& update,
......
......@@ -217,8 +217,8 @@ NameAddTransaction::addingFwdAddrsHandler() {
// @note For now we treat OTHER as an IO error like TIMEOUT. It
// is not entirely clear if this is accurate.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_ADD_IO_ERROR)
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
retryTransition(SELECTING_FWD_SERVER_ST);
break;
......@@ -227,8 +227,8 @@ NameAddTransaction::addingFwdAddrsHandler() {
// A response was received but was corrupt. Retry it like an IO
// error.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT)
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
retryTransition(SELECTING_FWD_SERVER_ST);
break;
......@@ -236,7 +236,8 @@ NameAddTransaction::addingFwdAddrsHandler() {
default:
// Any other value and we will fail this transaction, something
// bigger is wrong.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_ADD_UNKNOWN_FAILURE)
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS)
.arg(getDnsUpdateStatus())
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
......@@ -317,8 +318,8 @@ NameAddTransaction::replacingFwdAddrsHandler() {
// @note For now we treat OTHER as an IO error like TIMEOUT. It
// is not entirely clear if this is accurate.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_REPLACE_IO_ERROR)
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
// If we are out of retries on this server, we go back and start
// all over on a new server.
......@@ -329,8 +330,8 @@ NameAddTransaction::replacingFwdAddrsHandler() {
// A response was received but was corrupt. Retry it like an IO
// error.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT)
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
// If we are out of retries on this server, we go back and start
// all over on a new server.
......@@ -340,7 +341,9 @@ NameAddTransaction::replacingFwdAddrsHandler() {
default:
// Any other value and we will fail this transaction, something
// bigger is wrong.
LOG_ERROR(dctl_logger, DHCP_DDNS_FORWARD_REPLACE_UNKNOWN_FAILURE)
LOG_ERROR(dctl_logger,
DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS)
.arg(getDnsUpdateStatus())
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
......@@ -438,8 +441,8 @@ NameAddTransaction::replacingRevPtrsHandler() {
// @note For now we treat OTHER as an IO error like TIMEOUT. It
// is not entirely clear if this is accurate.
LOG_ERROR(dctl_logger, DHCP_DDNS_REVERSE_REPLACE_IO_ERROR)
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
// If we are out of retries on this server, we go back and start
// all over on a new server.
......@@ -450,8 +453,8 @@ NameAddTransaction::replacingRevPtrsHandler() {
// A response was received but was corrupt. Retry it like an IO
// error.
LOG_ERROR(dctl_logger, DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT)
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
.arg(getCurrentServer()->getIpAddress())
.arg(getNcr()->getFqdn());
// If we are out of retries on this server, we go back and start
// all over on a new server.
......@@ -461,7 +464,9 @@ NameAddTransaction::replacingRevPtrsHandler() {
default:
// Any other value and we will fail this transaction, something
// bigger is wrong.
LOG_ERROR(dctl_logger, DHCP_DDNS_REVERSE_REPLACE_UNKNOWN_FAILURE)
LOG_ERROR(dctl_logger,
DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS)
.arg(getDnsUpdateStatus())
.arg(getNcr()->getFqdn())
.arg(getCurrentServer()->getIpAddress());
......
......@@ -129,12 +129,16 @@ protected:
/// @throw StateModelError if an event value is undefined.
virtual void verifyStates();
/// @brief State handler for R
/// @brief State handler for READY_ST.
///
/// Entered from:
/// - INIT_ST with next event of START_EVT
///
/// Servers as the starting state handler.
/// The READY_ST is the state the model transitions into when the inherited
/// method, startTransaction() is invoked. This handler, therefore, as the
/// is the entry point into the state model execuition.h Its primary task
/// is to determine whether to start with a forward DNS change or a
/// reverse DNS change.
///
/// Transitions to:
/// - SELECTING_FWD_SERVER_ST with next event of SERVER_SELECT_ST if request
......@@ -144,7 +148,7 @@ protected:
/// includes only a reverse change.
///
/// @throw NameAddTransactionError if upon entry next event is not
/// START_EVT.EADY_ST.
/// START_EVT.READY_ST.
void readyHandler();
/// @brief State handler for SELECTING_FWD_SERVER_ST.
......@@ -209,7 +213,14 @@ protected:
/// schedules an asynchronous send via sendUpdate(), and returns. Note
/// that sendUpdate will post NOP_EVT as next event.
///
/// If the handler is invoked with a next event of IO_COMPELTED_EVT, then
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
......@@ -239,7 +250,7 @@ protected:
/// SERVER_SELECTED_EVT or IO_COMPLETE_EVT.
void addingFwdAddrsHandler();
/// @brief State handler for .
/// @brief State handler for REPLACING_FWD_ADDRS_ST.
///
/// Entered from:
/// - ADDING_FWD_ADDRS_ST with next event of FQDN_IN_USE_EVT
......@@ -252,7 +263,14 @@ protected:
/// via sendUpdate(), and returns. Note that sendUpdate will post NOP_EVT
/// as the next event.
///
/// If the handler is invoked with a next event of IO_COMPELTED_EVT, then
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
......@@ -296,7 +314,14 @@ protected:
/// add request, schedules an asynchronous send via sendUpdate(), and
/// returns. Note that sendUpdate will post NOP_EVT as next event.
///
/// If the handler is invoked with a next event of IO_COMPELTED_EVT, then
/// Posting the NOP_EVT will cause runModel() to suspend execution of
/// the state model thus affecting a "wait" for the update IO to complete.
/// Update completion occurs via the DNSClient callback operator() method
/// inherited from NameChangeTransaction. When invoked this callback will
/// post a next event of IO_COMPLETED_EVT and then invoke runModel which
/// resumes execution of the state model.
///
/// When the handler is invoked with a next event of IO_COMPELTED_EVT,
/// the DNS update status is checked and acted upon accordingly:
///
/// Transitions to:
......
......@@ -102,7 +102,7 @@ NameChangeTransaction::sendUpdate(bool /* use_tsig_ */) {
// @todo time out should ultimately be configurable, down to
// server level?
dns_client_->doUpdate(io_service_, current_server_->getIpAddress(),
dns_client_->doUpdate(*io_service_, current_server_->getIpAddress(),
current_server_->getPort(), *dns_update_request_,
DNS_UPDATE_DEFAULT_TIMEOUT);
......@@ -116,11 +116,9 @@ NameChangeTransaction::sendUpdate(bool /* use_tsig_ */) {
// mechansisms and manifested as an unsuccessful IO statu in the
// DNSClient callback. Any problem here most likely means the request
// is corrupt in some way and cannot be completed, therefore we will
// log it, mark it as failed, and set next event to NOP_EVT.
LOG_ERROR(dctl_logger, DHCP_DDNS_TRANS_SEND_EROR).arg(ex.what());
setNcrStatus(dhcp_ddns::ST_FAILED);
// @todo is this right?
postNextEvent(NOP_EVT);
// log it and transition it to failure.
LOG_ERROR(dctl_logger, DHCP_DDNS_TRANS_SEND_ERROR).arg(ex.what());
transition(PROCESS_TRANS_FAILED_ST, UPDATE_FAILED_EVT);
}
}
......@@ -183,7 +181,7 @@ NameChangeTransaction::onModelFailure(const std::string& explanation) {
}
void
NameChangeTransaction::retryTransition(int server_sel_state) {
NameChangeTransaction::retryTransition(const int server_sel_state) {
if (update_attempts_ < MAX_UPDATE_TRIES_PER_SERVER) {
// Re-enter the current state with same server selected.
transition(getCurrState(), SERVER_SELECTED_EVT);
......@@ -230,7 +228,7 @@ NameChangeTransaction::setReverseChangeCompleted(const bool value) {
}
void
NameChangeTransaction::setUpdateAttempts(size_t value) {
NameChangeTransaction::setUpdateAttempts(const size_t value) {
update_attempts_ = value;
}
......
......@@ -197,7 +197,15 @@ public:
virtual void operator()(DNSClient::Status status);
protected:
/// @todo
/// @brief Send the update request to the current server.
///
/// This method increments the update attempt count and then passes the
/// current update request to the DNSClient instance to be sent to the
/// currently selected server. Since the send is asynchronous, the method
/// posts NOP_EVT as the next event and then returns.
///
/// If an exception occurs it will be logged and and the transaction will
/// be failed.
virtual void sendUpdate(bool use_tsig_ = false);
/// @brief Adds events defined by NameChangeTransaction to the event set.
......@@ -257,8 +265,19 @@ protected:
/// @param explanation is text detailing the error
virtual void onModelFailure(const std::string& explanation);
/// @todo
void retryTransition(int server_sel_state);
/// @brief Determines the state and next event based on update attempts.
///
/// This method will post a next event of SERVER_SELECTED_EVT to the
/// current state if the number of udpate attempts has not reached the
/// maximum allowed.
///
/// If the maximum number of attempts has been reached, it will transition
/// to the given state with a next event of SERVER_IO_ERROR_EVT.
///
/// @param server_sel_state State to transition to if maximum attempts
/// have been tried.
///
void retryTransition(const int server_sel_state);
/// @brief Sets the update request packet to the given packet.
///
......@@ -278,7 +297,7 @@ protected:
/// @param response is the new response packet to assign.
void setDnsUpdateResponse(D2UpdateMessagePtr& response);
/// @brief Destroys the current update respons packet.
/// @brief Destroys the current update response packet.
void clearDnsUpdateResponse();
/// @brief Sets the forward change completion flag to the given value.
......@@ -333,7 +352,13 @@ protected:
/// @brief Sets the update attempt count to the given value.
///
/// @param value is the new value to assign.
void setUpdateAttempts(size_t value);
void setUpdateAttempts(const size_t value);
/// @todo
const IOServicePtr& getIOService() {
return (io_service_);
}
public:
/// @brief Fetches the NameChangeRequest for this transaction.
......@@ -465,7 +490,7 @@ private:
/// list, which may be beyond the end of the list.
size_t next_server_pos_;
// @todo
/// @brief Number of transmit attempts for the current request.
size_t update_attempts_;
};
......
......@@ -78,8 +78,12 @@ const long TEST_TIMEOUT = 5 * 1000;
/// @brief Tests that construction with max queue size of zero is not allowed.
TEST(D2QueueMgrBasicTest, construction1) {
IOServicePtr io_service(new isc::asiolink::IOService());
IOServicePtr io_service;
// Verify that constructing with null IOServicePtr is not allowed.
EXPECT_THROW((D2QueueMgr(io_service)), D2QueueMgrError);
io_service.reset(new isc::asiolink::IOService());
// Verify that constructing with max queue size of zero is not allowed.
EXPECT_THROW(D2QueueMgr(io_service, 0), D2QueueMgrError);
}
......
......@@ -181,6 +181,12 @@ TEST(D2UpdateMgr, construction) {
ASSERT_NO_THROW(cfg_mgr.reset(new D2CfgMgr()));
// Verify that constructor fails with invalid io_service.
io_service.reset();
EXPECT_THROW(D2UpdateMgr(queue_mgr, cfg_mgr, io_service),
D2UpdateMgrError);
io_service.reset(new isc::asiolink::IOService());
// Verify that max transactions cannot be zero.
EXPECT_THROW(D2UpdateMgr(queue_mgr, cfg_mgr, io_service, 0),
D2UpdateMgrError);
......
......@@ -61,7 +61,7 @@ const long TEST_TIMEOUT = 5 * 1000;
// timeout is hit. This will result in test failure.
class DNSClientTest : public virtual ::testing::Test, DNSClient::Callback {
public:
IOServicePtr service_;
IOService service_;
D2UpdateMessagePtr response_;
DNSClient::Status status_;
uint8_t receive_buffer_[MAX_SIZE];
......@@ -79,11 +79,11 @@ public:
// in case when response from the server is not received. Tests output would
// become messy if such errors were logged.
DNSClientTest()
: service_(new isc::asiolink::IOService()),
: service_(),
status_(DNSClient::SUCCESS),
corrupt_response_(false),
expect_response_(true),
test_timer_(*service_) {
test_timer_(service_) {
asiodns::logger.setSeverity(isc::log::INFO);
response_.reset(new D2UpdateMessage(D2UpdateMessage::INBOUND));
dns_client_.reset(new DNSClient(response_, this));
......@@ -108,7 +108,7 @@ public:
// @param status A status code returned by DNSClient.
virtual void operator()(DNSClient::Status status) {
status_ = status;
service_->stop();
service_.stop();
if (expect_response_) {
if (!corrupt_response_) {
......@@ -139,7 +139,7 @@ public:
//
// This callback stops all running (hanging) tasks on IO service.
void testTimeoutHandler() {
service_->stop();
service_.stop();
FAIL() << "Test timeout hit.";
}
......@@ -261,7 +261,7 @@ public:
// Set the response wait time to 0 so as our test is not hanging. This
// should cause instant timeout.
const int timeout = 0;
const int timeout = 500;
// The doUpdate() function starts asynchronous message exchange with DNS
// server. When message exchange is done or timeout occurs, the
// completion callback will be triggered. The doUpdate function returns
......@@ -271,7 +271,7 @@ public:
// This starts the execution of tasks posted to IOService. run() blocks
// until stop() is called in the completion callback function.
service_->run();
service_.run();
}
......@@ -295,7 +295,7 @@ public:
// responses. The reuse address option is set so as both sockets can
// use the same address. This new socket is bound to the test address
// and port, where requests will be sent.
udp::socket udp_socket(service_->get_io_service(), asio::ip::udp::v4());
udp::socket udp_socket(service_.get_io_service(), asio::ip::udp::v4());
udp_socket.set_option(socket_base::reuse_address(true));
udp_socket.bind(udp::endpoint(address::from_string(TEST_ADDRESS),
TEST_PORT));
......@@ -334,7 +334,7 @@ public:
// Kick of the message exchange by actually running the scheduled
// "send" and "receive" operations.
service_->run();
service_.run();
udp_socket.close();
......
This diff is collapsed.
This diff is collapsed.
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