BIND 10 trac3059, updated. 0fc5b23ed78c9b9ed16437a5b53e45881d413e77 [3059] Additional review related changes.
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Aug 7 12:36:24 UTC 2013
The branch, trac3059 has been updated
via 0fc5b23ed78c9b9ed16437a5b53e45881d413e77 (commit)
from 4f2cfbfa1b3edf01bab9c4d8b38a651ab857f52d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0fc5b23ed78c9b9ed16437a5b53e45881d413e77
Author: Thomas Markwalder <tmark at isc.org>
Date: Wed Aug 7 08:34:48 2013 -0400
[3059] Additional review related changes.
D2UpdateMgr members were rescoped to be more appropriate
and unit tests adjusted accordingly. Other minor changes.
-----------------------------------------------------------------------
Summary of changes:
src/bin/d2/d2_config.cc | 9 +++---
src/bin/d2/d2_config.h | 4 +--
src/bin/d2/d2_update_mgr.h | 5 +++-
src/bin/d2/tests/d2_update_mgr_unittests.cc | 43 +++++++++++++++++++++++----
4 files changed, 48 insertions(+), 13 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/d2/d2_config.cc b/src/bin/d2/d2_config.cc
index 1e299ef..db20cc8 100644
--- a/src/bin/d2/d2_config.cc
+++ b/src/bin/d2/d2_config.cc
@@ -91,9 +91,6 @@ DdnsDomainListMgr::setDomains(DdnsDomainMapPtr domains) {
bool
DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
- // Clear the return parameter.
- domain.reset();
-
// First check the case of one domain to rule them all.
if ((size() == 1) && (wildcard_domain_)) {
domain = wildcard_domain_;
@@ -106,6 +103,7 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
size_t req_len = fqdn.size();
size_t match_len = 0;
DdnsDomainMapPair map_pair;
+ DdnsDomainPtr best_match;
BOOST_FOREACH (map_pair, *domains_) {
std::string domain_name = map_pair.first;
size_t dom_len = domain_name.size();
@@ -134,13 +132,13 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
// any we have matched so far.
if (dom_len > match_len) {
match_len = dom_len;
- domain = map_pair.second;
+ best_match = map_pair.second;
}
}
}
}
- if (!domain) {
+ if (!best_match) {
// There's no match. If they specified a wild card domain use it
// otherwise there's no domain for this entry.
if (wildcard_domain_) {
@@ -152,6 +150,7 @@ DdnsDomainListMgr::matchDomain(const std::string& fqdn, DdnsDomainPtr& domain) {
return (false);
}
+ domain = best_match;
return (true);
}
diff --git a/src/bin/d2/d2_config.h b/src/bin/d2/d2_config.h
index e50345b..ba0beaa 100644
--- a/src/bin/d2/d2_config.h
+++ b/src/bin/d2/d2_config.h
@@ -414,8 +414,8 @@ public:
/// it will be returned immediately for any FQDN.
///
/// @param fqdn is the name for which to look.
- /// @param domain receives the matching domain. Note that it will be reset
- /// upon entry and only set if a match is subsequently found.
+ /// @param domain receives the matching domain. If no match is found its
+ /// contents will be unchanged.
///
/// @return returns true if a match is found, false otherwise.
/// @todo This is a very basic match method, which expects valid FQDNs
diff --git a/src/bin/d2/d2_update_mgr.h b/src/bin/d2/d2_update_mgr.h
index b4308a4..555b7be 100644
--- a/src/bin/d2/d2_update_mgr.h
+++ b/src/bin/d2/d2_update_mgr.h
@@ -152,7 +152,7 @@ public:
const size_t max_transactions = MAX_TRANSACTIONS_DEFAULT);
/// @brief Destructor
- ~D2UpdateMgr();
+ virtual ~D2UpdateMgr();
/// @brief Check current transactions; start transactions for new requests.
///
@@ -170,6 +170,7 @@ public:
/// add the transaction to the list of transactions.
void sweep();
+protected:
/// @brief Performs post-completion cleanup on completed transactions.
///
/// Iterates through the list of transactions and removes any that have
@@ -208,6 +209,7 @@ public:
/// exists. Note this would be programmatic error.
void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr& ncr);
+public:
/// @brief Returns the maximum number of concurrent transactions.
size_t getMaxTransactions() const {
return (max_transactions_);
@@ -286,6 +288,7 @@ private:
/// @brief Defines a pointer to a D2UpdateMgr instance.
typedef boost::shared_ptr<D2UpdateMgr> D2UpdateMgrPtr;
+
} // namespace isc::d2
} // namespace isc
#endif
diff --git a/src/bin/d2/tests/d2_update_mgr_unittests.cc b/src/bin/d2/tests/d2_update_mgr_unittests.cc
index a7e6185..0abed5d 100644
--- a/src/bin/d2/tests/d2_update_mgr_unittests.cc
+++ b/src/bin/d2/tests/d2_update_mgr_unittests.cc
@@ -31,23 +31,56 @@ using namespace isc::d2;
namespace {
+/// @brief Wrapper class for D2UpdateMgr to provide acces non-public methods.
+///
+/// This class faciliates testing by making non-public methods accessible so
+/// they can be invoked directly in test routines.
+class D2UpdateMgrWrapper : public D2UpdateMgr {
+public:
+ /// @brief Constructor
+ ///
+ /// Parameters match those needed by D2UpdateMgr.
+ D2UpdateMgrWrapper(D2QueueMgrPtr& queue_mgr, D2CfgMgrPtr& cfg_mgr,
+ isc::asiolink::IOService& io_service,
+ const size_t max_transactions = MAX_TRANSACTIONS_DEFAULT)
+ : D2UpdateMgr(queue_mgr, cfg_mgr, io_service, max_transactions) {
+ }
+
+ /// @brief Destructor
+ virtual ~D2UpdateMgrWrapper() {
+ }
+
+ // Expose the protected methods to be tested.
+ using D2UpdateMgr::checkFinishedTransactions;
+ using D2UpdateMgr::pickNextJob;
+ using D2UpdateMgr::makeTransaction;
+};
+
+/// @brief Defines a pointer to a D2UpdateMgr instance.
+typedef boost::shared_ptr<D2UpdateMgrWrapper> D2UpdateMgrWrapperPtr;
+
/// @brief Test fixture for testing D2UpdateMgr.
-/// D2UpdateMgr depends on both D2QueueMgr and D2CfgMgr. This fixture
-/// provides an instance of each, plus a canned, valid DHCP_DDNS configuration
-/// sufficient to test D2UpdateMgr's basic functions.
+///
+/// Note this class uses D2UpdateMgrWrapper class to exercise non-public
+/// aspects of D2UpdateMgr. D2UpdateMgr depends on both D2QueueMgr and
+/// D2CfgMgr. This fixture provides an instance of each, plus a canned,
+/// valid DHCP_DDNS configuration sufficient to test D2UpdateMgr's basic
+/// functions.
class D2UpdateMgrTest : public ConfigParseTest {
public:
isc::asiolink::IOService io_service_;
D2QueueMgrPtr queue_mgr_;
D2CfgMgrPtr cfg_mgr_;
- D2UpdateMgrPtr update_mgr_;
+ //D2UpdateMgrPtr update_mgr_;
+ D2UpdateMgrWrapperPtr update_mgr_;
std::vector<NameChangeRequestPtr> canned_ncrs_;
size_t canned_count_;
D2UpdateMgrTest() {
queue_mgr_.reset(new D2QueueMgr(io_service_));
cfg_mgr_.reset(new D2CfgMgr());
- update_mgr_.reset(new D2UpdateMgr(queue_mgr_, cfg_mgr_, io_service_));
+ update_mgr_.reset(new D2UpdateMgrWrapper(queue_mgr_, cfg_mgr_,
+ io_service_));
makeCannedNcrs();
makeCannedConfig();
}
More information about the bind10-changes
mailing list