BIND 10 master, updated. 469b4078b27d456cbbce856edfd8b57b437c317b Merge #1997
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jun 11 08:23:40 UTC 2012
The branch, master has been updated
via 469b4078b27d456cbbce856edfd8b57b437c317b (commit)
via 7817f9484fa5acae4d82c39ac88d010be62d1225 (commit)
via 5b0f09471e155d0a8985b2d320c1a5f47667e2d7 (commit)
via ca3f9d967c0806859979ac5508939eb785d90e1d (commit)
via 2d96fb33890ca6e6abe991d694d9408f5264fc57 (commit)
from 400bb38f52c2c272c18edd77305310f6c55c4c37 (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 469b4078b27d456cbbce856edfd8b57b437c317b
Merge: 400bb38 7817f94
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jun 11 10:05:07 2012 +0200
Merge #1997
Support for static data source under the new data source framework.
commit 7817f9484fa5acae4d82c39ac88d010be62d1225
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jun 11 10:01:41 2012 +0200
[1997] Add forgotten EXTRA_DIST
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 21 ++++++++++
src/lib/datasrc/Makefile.am | 18 +++++++-
src/lib/datasrc/static.zone.pre | 12 ++++++
src/lib/datasrc/static_datasrc_link.cc | 62 ++++++++++++++++++++++++++++
src/lib/datasrc/tests/Makefile.am | 1 +
src/lib/datasrc/tests/factory_unittest.cc | 56 +++++++++++++++++++++++++
src/lib/datasrc/tests/testdata/static.zone | 2 +
7 files changed, 170 insertions(+), 2 deletions(-)
create mode 100644 src/lib/datasrc/static.zone.pre
create mode 100644 src/lib/datasrc/static_datasrc_link.cc
create mode 100644 src/lib/datasrc/tests/testdata/static.zone
-----------------------------------------------------------------------
diff --git a/AUTHORS b/AUTHORS
index e69de29..67cb090 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -0,0 +1,21 @@
+Chen Zhengzhang
+Dmitriy Volodin
+Evan Hunt
+Haidong Wang
+Haikuo Zhang
+Han Feng
+Jelte Jansen
+Jeremy C. Reed
+Xie Jiagui
+Jin Jian
+JINMEI Tatuya
+Kazunori Fujiwara
+Michael Graff
+Michal Vaner
+Mukund Sivaraman
+Naoki Kambe
+Shane Kerr
+Shen Tingting
+Stephen Morris
+Yoshitaka Aharen
+Zhang Likun
diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am
index 2cdb8ea..37efef0 100644
--- a/src/lib/datasrc/Makefile.am
+++ b/src/lib/datasrc/Makefile.am
@@ -12,8 +12,13 @@ pkglibdir = $(libexecdir)/@PACKAGE@/backends
datasrc_config.h: datasrc_config.h.pre
$(SED) -e "s|@@PKGLIBDIR@@|$(pkglibdir)|" datasrc_config.h.pre >$@
+static.zone: static.zone.pre
+ $(SED) -e "s|@@VERSION_STRING@@|$(PACKAGE_STRING)|" $(srcdir)/static.zone.pre >$@
+ $(SED) -e 's/\(.*\)/AUTHORS.BIND. 0 CH TXT "\1"/' $(top_srcdir)/AUTHORS >>$@
+
CLEANFILES = *.gcno *.gcda datasrc_messages.h datasrc_messages.cc
CLEANFILES += datasrc_config.h
+CLEANFILES += static.zone
lib_LTLIBRARIES = libdatasrc.la
libdatasrc_la_SOURCES = data_source.h data_source.cc
@@ -33,7 +38,7 @@ libdatasrc_la_SOURCES += factory.h factory.cc
nodist_libdatasrc_la_SOURCES = datasrc_messages.h datasrc_messages.cc
libdatasrc_la_LDFLAGS = -no-undefined -version-info 1:0:1
-pkglib_LTLIBRARIES = sqlite3_ds.la memory_ds.la
+pkglib_LTLIBRARIES = sqlite3_ds.la memory_ds.la static_ds.la
sqlite3_ds_la_SOURCES = sqlite3_accessor.h sqlite3_accessor.cc
sqlite3_ds_la_SOURCES += sqlite3_accessor_link.cc
@@ -49,6 +54,12 @@ memory_ds_la_LDFLAGS = -module -avoid-version
memory_ds_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
memory_ds_la_LIBADD += libdatasrc.la
+static_ds_la_SOURCES = memory_datasrc.h memory_datasrc.cc
+static_ds_la_SOURCES += static_datasrc_link.cc
+static_ds_la_LDFLAGS = -module -avoid-version
+static_ds_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
+static_ds_la_LIBADD += libdatasrc.la
+
libdatasrc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
libdatasrc_la_LIBADD += $(top_builddir)/src/lib/dns/libdns++.la
libdatasrc_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
@@ -59,4 +70,7 @@ BUILT_SOURCES = datasrc_config.h datasrc_messages.h datasrc_messages.cc
datasrc_messages.h datasrc_messages.cc: Makefile datasrc_messages.mes
$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/datasrc/datasrc_messages.mes
-EXTRA_DIST = datasrc_messages.mes
+EXTRA_DIST = datasrc_messages.mes static.zone.pre
+
+zonedir = $(pkgdatadir)
+zone_DATA = static.zone
diff --git a/src/lib/datasrc/static.zone.pre b/src/lib/datasrc/static.zone.pre
new file mode 100644
index 0000000..16a7379
--- /dev/null
+++ b/src/lib/datasrc/static.zone.pre
@@ -0,0 +1,12 @@
+;; This is the content of the BIND./CH zone. It contains the version and
+;; authors (called VERSION.BIND. and AUTHORS.BIND.). You can add more or
+;; modify the zone. Then you can reload the zone by issuing the command
+;;
+;; loadzone CH BIND
+;;
+;; in the bindctl.
+
+BIND. 0 CH SOA bind. authors.bind. 0 28800 7200 604800 86400
+
+VERSION.BIND. 0 CH TXT "@@VERSION_STRING@@"
+;; HOSTNAME.BIND 0 CH TXT "localhost"
diff --git a/src/lib/datasrc/static_datasrc_link.cc b/src/lib/datasrc/static_datasrc_link.cc
new file mode 100644
index 0000000..789580d
--- /dev/null
+++ b/src/lib/datasrc/static_datasrc_link.cc
@@ -0,0 +1,62 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include "client.h"
+#include "memory_datasrc.h"
+
+#include <cc/data.h>
+#include <dns/rrclass.h>
+
+#include <memory>
+#include <exception>
+
+using namespace isc::data;
+using namespace isc::dns;
+using namespace boost;
+using namespace std;
+
+namespace isc {
+namespace datasrc {
+
+DataSourceClient*
+createInstance(ConstElementPtr config, string& error) {
+ try {
+ // Create the data source
+ auto_ptr<InMemoryClient> client(new InMemoryClient());
+ // Hardcode the origin and class
+ shared_ptr<InMemoryZoneFinder>
+ finder(new InMemoryZoneFinder(RRClass::CH(), Name("BIND")));
+ // Fill it with data
+ const string path(config->stringValue());
+ finder->load(path);
+ // And put the zone inside
+ client->addZone(finder);
+ return (client.release());
+ }
+ catch (const std::exception& e) {
+ error = e.what();
+ }
+ catch (...) {
+ error = "Unknown exception";
+ }
+ return (NULL);
+}
+
+void
+destroyInstance(DataSourceClient* instance) {
+ delete instance;
+}
+
+}
+}
diff --git a/src/lib/datasrc/tests/Makefile.am b/src/lib/datasrc/tests/Makefile.am
index 6c4a937..adc8e0e 100644
--- a/src/lib/datasrc/tests/Makefile.am
+++ b/src/lib/datasrc/tests/Makefile.am
@@ -113,3 +113,4 @@ EXTRA_DIST += testdata/test.sqlite3
EXTRA_DIST += testdata/new_minor_schema.sqlite3
EXTRA_DIST += testdata/newschema.sqlite3
EXTRA_DIST += testdata/oldschema.sqlite3
+EXTRA_DIST += testdata/static.zone
diff --git a/src/lib/datasrc/tests/factory_unittest.cc b/src/lib/datasrc/tests/factory_unittest.cc
index 58afd7b..2031d50 100644
--- a/src/lib/datasrc/tests/factory_unittest.cc
+++ b/src/lib/datasrc/tests/factory_unittest.cc
@@ -28,6 +28,8 @@ using namespace isc::datasrc;
using namespace isc::data;
std::string SQLITE_DBFILE_EXAMPLE_ORG = TEST_DATA_DIR "/example.org.sqlite3";
+const std::string STATIC_DS_FILE = TEST_DATA_DIR "/static.zone";
+const std::string ROOT_ZONE_FILE = TEST_DATA_DIR "/root.zone";
namespace {
@@ -235,5 +237,59 @@ TEST(FactoryTest, badType) {
DataSourceError);
}
+// Check the static data source can be loaded.
+TEST(FactoryTest, staticDS) {
+ // The only configuration is the file to load.
+ const ConstElementPtr config(new StringElement(STATIC_DS_FILE));
+ // Get the data source
+ DataSourceClientContainer dsc("static", config);
+ // And try getting something out to see if it really works.
+ DataSourceClient::FindResult
+ result(dsc.getInstance().findZone(isc::dns::Name("BIND")));
+ ASSERT_EQ(result::SUCCESS, result.code);
+ EXPECT_EQ(isc::dns::Name("BIND"), result.zone_finder->getOrigin());
+ EXPECT_EQ(isc::dns::RRClass::CH(), result.zone_finder->getClass());
+ const isc::dns::ConstRRsetPtr
+ version(result.zone_finder->find(isc::dns::Name("VERSION.BIND"),
+ isc::dns::RRType::TXT())->rrset);
+ ASSERT_NE(isc::dns::ConstRRsetPtr(), version);
+ EXPECT_EQ(isc::dns::Name("VERSION.BIND"), version->getName());
+ EXPECT_EQ(isc::dns::RRClass::CH(), version->getClass());
+ EXPECT_EQ(isc::dns::RRType::TXT(), version->getType());
+}
+
+// Check that file not containing BIND./CH is rejected
+//
+// FIXME: This test is disabled because the InMemoryZoneFinder::load does
+// not check if the data loaded correspond with the origin. The static
+// factory is not the place to fix that.
+TEST(FactoryTest, DISABLED_staticDSBadFile) {
+ // The only configuration is the file to load.
+ const ConstElementPtr config(new StringElement(STATIC_DS_FILE));
+ // See it does not want the file
+ EXPECT_THROW(DataSourceClientContainer("static", config), DataSourceError);
+}
+
+// Check that some bad configs are rejected
+TEST(FactoryTest, staticDSBadConfig) {
+ const char* configs[] = {
+ // The file does not exist
+ "\"/does/not/exist\"",
+ // Bad types
+ "null",
+ "42",
+ "{}",
+ "[]",
+ "true",
+ NULL
+ };
+ for (const char** config(configs); *config; ++config) {
+ SCOPED_TRACE(*config);
+ EXPECT_THROW(DataSourceClientContainer("static",
+ Element::fromJSON(*config)),
+ DataSourceError);
+ }
+}
+
} // end anonymous namespace
diff --git a/src/lib/datasrc/tests/testdata/static.zone b/src/lib/datasrc/tests/testdata/static.zone
new file mode 100644
index 0000000..5e9e8a6
--- /dev/null
+++ b/src/lib/datasrc/tests/testdata/static.zone
@@ -0,0 +1,2 @@
+BIND. 3600 CH SOA BIND. BIND. 1 3600 300 36000 3600
+VERSION.BIND. 3600 CH TXT "10"
More information about the bind10-changes
mailing list