BIND 10 trac2851, updated. 2cb89753827b015cd183fff26b52e7c28154727f [2851] added a new test case for reloading a zone added to the datasrc later
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed May 8 22:38:26 UTC 2013
The branch, trac2851 has been updated
via 2cb89753827b015cd183fff26b52e7c28154727f (commit)
via 211025a21adc6230894092b606c8f86cef3dc913 (commit)
via 7e2d747ba455749e7ccee8eec36fe5f7e51ed749 (commit)
from 6dd94680bed03c6423d1674bc4193c64a7fed4a1 (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 2cb89753827b015cd183fff26b52e7c28154727f
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed May 8 15:37:47 2013 -0700
[2851] added a new test case for reloading a zone added to the datasrc later
commit 211025a21adc6230894092b606c8f86cef3dc913
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed May 8 15:25:51 2013 -0700
[2851] updated comment wording for reloadZoneGone test.
it now doesn't throw an exception but reject the attempt with an error code.
commit 7e2d747ba455749e7ccee8eec36fe5f7e51ed749
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue May 7 13:42:40 2013 -0700
[2851] untabify
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/client_list.h | 4 ++--
src/lib/datasrc/tests/client_list_unittest.cc | 30 +++++++++++++++++++++++--
src/lib/datasrc/tests/mock_client.h | 7 ++++++
3 files changed, 37 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index 0e436ce..207b9c1 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -391,7 +391,7 @@ public:
/// \throw DataSourceError or anything else that the data source
/// containing the zone might throw is propagated.
ZoneWriterPair getCachedZoneWriter(const dns::Name& zone,
- const std::string& datasrc_name = "");
+ const std::string& datasrc_name = "");
/// \brief Implementation of the ClientList::find.
virtual FindResult find(const dns::Name& zone,
@@ -421,7 +421,7 @@ public:
std::string name_;
// cache_conf_ can be accessed only from this read-only getter,
- // to protect its integrity as much as possible.
+ // to protect its integrity as much as possible.
const internal::CacheConfig* getCacheConfig() const {
return (cache_conf_.get());
}
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index ba97736..99b4253 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -965,8 +965,8 @@ TEST_F(ListTest, reloadNoSuchZone) {
RRType::A())->code);
}
-// Check we gracefuly throw an exception when a zone disappeared in
-// the underlying data source when we want to reload it
+// Check we gracefully reject reloading (i.e. no exception) when a zone
+// disappeared in the underlying data source when we want to reload it
TEST_F(ListTest, reloadZoneGone) {
list_->configure(config_elem_zones_, true);
const Name name("example.org");
@@ -988,6 +988,32 @@ TEST_F(ListTest, reloadZoneGone) {
list_->find(name).finder_->find(name, RRType::SOA())->code);
}
+TEST_F(ListTest, reloadNewZone) {
+ // Test the case where a zone to be cached originally doesn't exist
+ // in the underlying data source and is added later. reload() will
+ // succeed once it's available in the data source.
+ const ConstElementPtr elem(Element::fromJSON("["
+ "{"
+ " \"type\": \"test_type\","
+ " \"cache-enable\": true,"
+ " \"cache-zones\": [\"example.org\", \"example.com\"],"
+ " \"params\": [\"example.org\"]"
+ "}]"));
+ list_->configure(elem, true);
+ checkDS(0, "test_type", "[\"example.org\"]", true); // no example.com
+
+ // We can't reload it either
+ EXPECT_EQ(ConfigurableClientList::ZONE_NOT_FOUND,
+ doReload(Name("example.com")));
+
+ // If we add the zone, we can now reload it
+ static_cast<MockDataSourceClient*>(
+ list_->getDataSources()[0].data_src_client_)->
+ insertZone(Name("example.com"));
+ EXPECT_EQ(ConfigurableClientList::ZONE_SUCCESS,
+ doReload(Name("example.com")));
+}
+
// The underlying data source throws. Check we don't modify the state.
TEST_F(ListTest, reloadZoneThrow) {
list_->configure(config_elem_zones_, true);
diff --git a/src/lib/datasrc/tests/mock_client.h b/src/lib/datasrc/tests/mock_client.h
index c51e9a1..7a01440 100644
--- a/src/lib/datasrc/tests/mock_client.h
+++ b/src/lib/datasrc/tests/mock_client.h
@@ -58,6 +58,13 @@ public:
void eraseZone(const dns::Name& zone_name) {
zones.erase(zone_name);
}
+
+ /// \brief Dynamically add a zone to the data source.
+ ///
+ /// \return true if the zone is newly added; false if it already exists.
+ bool insertZone(const dns::Name& zone_name) {
+ return (zones.insert(zone_name).second);
+ }
const std::string type_;
const data::ConstElementPtr configuration_;
More information about the bind10-changes
mailing list