BIND 10 trac2209, updated. 1eda789420a1914f61ee720043a15516157f23b4 [2209] Tests for the getCachedZoneWriter
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Oct 22 15:37:32 UTC 2012
The branch, trac2209 has been updated
via 1eda789420a1914f61ee720043a15516157f23b4 (commit)
from 61d475331f841b3d5f1b2461ae99fe45f5d554fe (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 1eda789420a1914f61ee720043a15516157f23b4
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Oct 22 17:28:45 2012 +0200
[2209] Tests for the getCachedZoneWriter
They are the reload() tests reused for this purpose. They fail, since
the method is temporary and contains almost no code.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/client_list.cc | 6 +++++
src/lib/datasrc/client_list.h | 6 +++--
src/lib/datasrc/tests/client_list_unittest.cc | 31 ++++++++++++++++++++++---
3 files changed, 38 insertions(+), 5 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index 865a1ce..cf96a47 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -376,6 +376,12 @@ ConfigurableClientList::reload(const Name& name) {
return (ZONE_RELOADED);
}
+ConfigurableClientList::ZoneWriterPair
+ConfigurableClientList::getCachedZoneWriter(const Name& ) {
+ // TODO: Just for now.
+ return (ZoneWriterPair(CACHE_DISABLED, ZoneWriterPtr()));
+}
+
// NOTE: This function is not tested, it would be complicated. However, the
// purpose of the function is to provide a very thin wrapper to be able to
// replace the call to DataSourceClientContainer constructor in tests.
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index 97d79ba..d6344b7 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -290,12 +290,14 @@ public:
/// the original data source no longer contains the cached zone.
ReloadResult reload(const dns::Name& zone);
+ /// \brief Convenience type shortcut
+ typedef boost::shared_ptr<memory::ZoneWriter> ZoneWriterPtr;
+
/// \brief Return value of getCachedZoneWriter()
///
/// A pair containing status and the zone writer, for the
/// getCachedZoneWriter() method.
- typedef std::pair<ReloadResult, boost::shared_ptr<memory::ZoneWriter> >
- ZoneWriterPair;
+ typedef std::pair<ReloadResult, ZoneWriterPtr> ZoneWriterPair;
/// \brief Return a zone writer that can be used to reload a zone.
///
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index ee1ca58..6b21db5 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -20,6 +20,7 @@
#include <datasrc/data_source.h>
#include <datasrc/memory/memory_client.h>
#include <datasrc/memory/zone_finder.h>
+#include <datasrc/memory/zone_writer.h>
#include <dns/rrclass.h>
#include <dns/rrttl.h>
@@ -862,10 +863,34 @@ ReloadTest<ReloadUpdateType>::doReload(const Name& origin) {
return (list_->reload(origin));
};
-// TODO: Version with ZoneWriter
+// Version with the ZoneWriter
+class WriterUpdateType {};
+template<>
+ConfigurableClientList::ReloadResult
+ReloadTest<WriterUpdateType>::doReload(const Name& origin) {
+ ConfigurableClientList::ZoneWriterPair
+ result(list_->getCachedZoneWriter(origin));
+ if (result.first == ConfigurableClientList::ZONE_RELOADED) {
+ // Can't use ASSERT_NE here, it would wan't to return(), which
+ // it can't in non-void function.
+ if (result.second) {
+ result.second->load();
+ result.second->install();
+ result.second->cleanup();
+ } else {
+ ADD_FAILURE() << "getCachedZoneWriter returned ZONE_RELOADED, "
+ "but the writer is NULL";
+ }
+ } else {
+ EXPECT_EQ(static_cast<memory::ZoneWriter*>(NULL),
+ result.second.get());
+ }
+ return (result.first);
+}
-typedef ::testing::Types<ReloadUpdateType> UpdateTypes;
-TYPED_TEST_CASE(ReloadTest, ReloadUpdateType);
+// Typedefs for the GTEST guts to make it work
+typedef ::testing::Types<ReloadUpdateType, WriterUpdateType> UpdateTypes;
+TYPED_TEST_CASE(ReloadTest, UpdateTypes);
// Test we can reload a zone
TYPED_TEST(ReloadTest, reloadSuccess) {
More information about the bind10-changes
mailing list