BIND 10 trac1976, updated. 27b68b4cbeb6ed397baf40221b9dda915230dcf6 [1976] Rip the old data source stuff out
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jun 22 13:17:17 UTC 2012
The branch, trac1976 has been updated
via 27b68b4cbeb6ed397baf40221b9dda915230dcf6 (commit)
via be542e8e2c04b89bc6788112e4006e91bcff2418 (commit)
via 5ed0c62ab3febe9f5310006fe3dedf52928fa79f (commit)
from f5db3a25bbac60c241acc36ba9869f72b4db18a9 (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 27b68b4cbeb6ed397baf40221b9dda915230dcf6
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jun 22 15:11:48 2012 +0200
[1976] Rip the old data source stuff out
As it was no longer used to answer queries, the old data sources (both
the new API and old sqlite3 stuff) was ripped out. Their configuration
goes with them. The loadzone command, unfortunately, too, because it
handled the old stuff and we don't really have a way to load to
in-memory now (needs #2044/#2046) so it would do nothing anyway.
The configuration options are left in the spec file, because other
modules refer to them. Once the other modules are solved, it can be
removed.
commit be542e8e2c04b89bc6788112e4006e91bcff2418
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jun 22 14:53:04 2012 +0200
[1976] Cleanup: test class to test file
The SingletonList is no longer needed for transition in the main Auth
code. It is now used in Query tests only, so it was moved to the
query_unittest.cc and the list.h removed.
commit 5ed0c62ab3febe9f5310006fe3dedf52928fa79f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Jun 22 14:43:48 2012 +0200
[1976] Switch processing to the ClientLists
The authoritative server now uses the ClientLists to provide the correct
data source clients for Query. The previous configuration is now
ignored.
Many tests were disabled. Part of them is because we don't have the
default configuration for built in yet (but it will be simple and solved
in this branch soon, it's just to keep this commit smallish). The more
problematic ones are because our in-memory is not really working well --
we want to use it as a cache and that is missing. Loading the zone files
to in-memory is also missing (ticket #2046).
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/Makefile.am | 2 +-
src/bin/auth/auth_config.cc | 99 +-------
src/bin/auth/auth_srv.cc | 101 ++------
src/bin/auth/command.cc | 3 +
src/bin/auth/datasrc_configurator.h | 27 +++
src/bin/auth/list.h | 33 ---
src/bin/auth/tests/auth_srv_unittest.cc | 70 ++++--
src/bin/auth/tests/command_unittest.cc | 20 +-
src/bin/auth/tests/config_unittest.cc | 381 +------------------------------
src/bin/auth/tests/query_unittest.cc | 28 ++-
10 files changed, 147 insertions(+), 617 deletions(-)
delete mode 100644 src/bin/auth/list.h
-----------------------------------------------------------------------
diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am
index c399521..1f0fbbf 100644
--- a/src/bin/auth/Makefile.am
+++ b/src/bin/auth/Makefile.am
@@ -49,7 +49,7 @@ b10_auth_SOURCES += command.cc command.h
b10_auth_SOURCES += common.h common.cc
b10_auth_SOURCES += statistics.cc statistics.h
b10_auth_SOURCES += datasrc_configurator.h
-b10_auth_SOURCES += main.cc list.h
+b10_auth_SOURCES += main.cc
# This is a temporary workaround for #1206, where the InMemoryClient has been
# moved to an ldopened library. We could add that library to LDADD, but that
# is nonportable. This should've been moot after #1207, but there is still
diff --git a/src/bin/auth/auth_config.cc b/src/bin/auth/auth_config.cc
index c85a4ee..d7266e5 100644
--- a/src/bin/auth/auth_config.cc
+++ b/src/bin/auth/auth_config.cc
@@ -43,20 +43,6 @@ using namespace isc::datasrc;
using namespace isc::server_common::portconfig;
namespace {
-/// A derived \c AuthConfigParser class for the "datasources" configuration
-/// identifier.
-class DatasourcesConfig : public AuthConfigParser {
-public:
- DatasourcesConfig(AuthSrv& server) : server_(server)
- {}
- virtual void build(ConstElementPtr config_value);
- virtual void commit();
-private:
- AuthSrv& server_;
- vector<boost::shared_ptr<AuthConfigParser> > datasources_;
- set<string> configured_sources_;
- vector<pair<RRClass, DataSourceClientContainerPtr> > clients_;
-};
/// A derived \c AuthConfigParser for the version value
/// (which is not used at this moment)
@@ -67,79 +53,6 @@ public:
virtual void commit() {};
};
-void
-DatasourcesConfig::build(ConstElementPtr config_value) {
- BOOST_FOREACH(ConstElementPtr datasrc_elem, config_value->listValue()) {
- // The caller is supposed to perform syntax-level checks, but we'll
- // do minimum level of validation ourselves so that we won't crash due
- // to a buggy application.
- ConstElementPtr datasrc_type = datasrc_elem->get("type");
- if (!datasrc_type) {
- isc_throw(AuthConfigError, "Missing data source type");
- }
-
- if (configured_sources_.find(datasrc_type->stringValue()) !=
- configured_sources_.end()) {
- isc_throw(AuthConfigError, "Data source type '" <<
- datasrc_type->stringValue() << "' already configured");
- }
-
- // Apart from that it's not really easy to get at the default
- // class value for the class here, it should probably really
- // be a property of the instantiated data source. For now
- // use hardcoded default IN.
- const RRClass rrclass =
- datasrc_elem->contains("class") ?
- RRClass(datasrc_elem->get("class")->stringValue()) : RRClass::IN();
-
- // Right now, we only support the in-memory data source for the
- // RR class of IN. We reject other cases explicitly by hardcoded
- // checks. This will soon be generalized, at which point these
- // checks will also have to be cleaned up.
- if (rrclass != RRClass::IN()) {
- isc_throw(isc::InvalidParameter, "Unsupported data source class: "
- << rrclass);
- }
- if (datasrc_type->stringValue() != "memory") {
- isc_throw(AuthConfigError, "Unsupported data source type: "
- << datasrc_type->stringValue());
- }
-
- // Create a new client for the specified data source and store it
- // in the local vector. For now, we always build a new client
- // from the scratch, and replace any existing ones with the new ones.
- // We might eventually want to optimize building zones (in case of
- // reloading) by selectively loading fresh zones for data source
- // where zone loading is expensive (such as in-memory).
- clients_.push_back(
- pair<RRClass, DataSourceClientContainerPtr>(
- rrclass,
- DataSourceClientContainerPtr(new DataSourceClientContainer(
- datasrc_type->stringValue(),
- datasrc_elem))));
-
- configured_sources_.insert(datasrc_type->stringValue());
- }
-}
-
-void
-DatasourcesConfig::commit() {
- // As noted in build(), the current implementation only supports the
- // in-memory data source for class IN, and build() should have ensured
- // it. So, depending on the vector is empty or not, we either clear
- // or install an in-memory data source for the server.
- //
- // When we generalize it, we'll somehow install all data source clients
- // built in the vector, clearing deleted ones from the server.
- if (clients_.empty()) {
- server_.setInMemoryClient(RRClass::IN(),
- DataSourceClientContainerPtr());
- } else {
- server_.setInMemoryClient(clients_.front().first,
- clients_.front().second);
- }
-}
-
/// A derived \c AuthConfigParser class for the "statistics-internal"
/// configuration identifier.
class StatisticsIntervalConfig : public AuthConfigParser {
@@ -242,9 +155,7 @@ createAuthConfigParser(AuthSrv& server, const std::string& config_id) {
// simplicity. In future we'll probably generalize it using map-like
// data structure, and may even provide external register interface so
// that it can be dynamically customized.
- if (config_id == "datasources") {
- return (new DatasourcesConfig(server));
- } else if (config_id == "statistics-interval") {
+ if (config_id == "statistics-interval") {
return (new StatisticsIntervalConfig(server));
} else if (config_id == "listen_on") {
return (new ListenAddressConfig(server));
@@ -261,6 +172,14 @@ createAuthConfigParser(AuthSrv& server, const std::string& config_id) {
// later be used to mark backwards incompatible changes in the
// config data
return (new VersionConfig());
+ } else if (config_id == "datasources") {
+ // TODO: Ignored for now, since the value is probably used by
+ // other modules. Once they have been removed from there, remove
+ // it from here and the spec file.
+
+ // We need to return something. The VersionConfig is empty now,
+ // so we may abuse that one, as it is a short-term solution only.
+ return (new VersionConfig());
} else {
isc_throw(AuthConfigError, "Unknown configuration identifier: " <<
config_id);
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index 66b6503..e4016c5 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -46,6 +46,7 @@
#include <datasrc/memory_datasrc.h>
#include <datasrc/static_datasrc.h>
#include <datasrc/sqlite3_datasrc.h>
+#include <datasrc/client_list.h>
#include <xfr/xfrout_client.h>
@@ -55,7 +56,6 @@
#include <auth/query.h>
#include <auth/statistics.h>
#include <auth/auth_log.h>
-#include <auth/list.h>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
@@ -270,6 +270,18 @@ public:
/// The client list
map<RRClass, boost::shared_ptr<ConfigurableClientList> > client_lists_;
+ boost::shared_ptr<ConfigurableClientList> getClientList(const RRClass&
+ rrclass)
+ {
+ const map<RRClass, boost::shared_ptr<ConfigurableClientList> >::
+ const_iterator it(client_lists_.find(rrclass));
+ if (it == client_lists_.end()) {
+ return (boost::shared_ptr<ConfigurableClientList>());
+ } else {
+ return (it->second);
+ }
+ }
+
/// Bind the ModuleSpec object in config_session_ with
/// isc:config::ModuleSpec::validateStatistics.
void registerStatisticsValidator();
@@ -290,14 +302,6 @@ public:
isc::dns::Message& message,
bool done);
private:
- std::string db_file_;
-
- MetaDataSrc data_sources_;
- /// We keep a pointer to the currently running sqlite datasource
- /// so that we can specifically remove that one should the database
- /// file change
- ConstDataSrcPtr cur_datasrc_;
-
bool xfrout_connected_;
AbstractXfroutClient& xfrout_client_;
@@ -326,13 +330,6 @@ AuthSrvImpl::AuthSrvImpl(const bool use_cache,
xfrout_client_(xfrout_client),
ddns_forwarder_("update", ddns_forwarder)
{
- // cur_datasrc_ is automatically initialized by the default constructor,
- // effectively being an empty (sqlite) data source. once ccsession is up
- // the datasource will be set by the configuration setting
-
- // add static data source
- data_sources_.addDataSrc(ConstDataSrcPtr(new StaticDataSrc));
-
// enable or disable the cache
cache_.setEnabled(use_cache);
}
@@ -719,15 +716,14 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, Message& message,
// If a memory data source is configured call the separate
// Query::process()
const ConstQuestionPtr question = *message.beginQuestion();
- if (memory_client_container_ &&
- memory_client_class_ == question->getClass()) {
+ const boost::shared_ptr<datasrc::ClientList>
+ list(getClientList(question->getClass()));
+ if (list) {
const RRType& qtype = question->getType();
const Name& qname = question->getName();
- SingletonList list(memory_client_container_->getInstance());
- query_.process(list, qname, qtype, message, dnssec_ok);
+ query_.process(*list, qname, qtype, message, dnssec_ok);
} else {
- datasrc::Query query(message, cache_, dnssec_ok);
- data_sources_.doQuery(query);
+ makeErrorMessage(renderer_, message, buffer, Rcode::REFUSED());
}
} catch (const Exception& ex) {
LOG_ERROR(auth_logger, AUTH_PROCESS_FAIL).arg(ex.what());
@@ -914,56 +910,6 @@ AuthSrvImpl::validateStatistics(isc::data::ConstElementPtr data) const {
data, true));
}
-ConstElementPtr
-AuthSrvImpl::setDbFile(ConstElementPtr config) {
- ConstElementPtr answer = isc::config::createAnswer();
-
- if (config && config->contains("database_file")) {
- db_file_ = config->get("database_file")->stringValue();
- } else if (config_session_ != NULL) {
- bool is_default;
- string item("database_file");
- ConstElementPtr value = config_session_->getValue(is_default, item);
- ElementPtr final = Element::createMap();
-
- // If the value is the default, and we are running from
- // a specific directory ('from build'), we need to use
- // a different value than the default (which may not exist)
- // (btw, this should not be done here in the end, i think
- // the from-source script should have a check for this,
- // but for that we need offline access to config, so for
- // now this is a decent solution)
- if (is_default && getenv("B10_FROM_BUILD")) {
- value = Element::create(string(getenv("B10_FROM_BUILD")) +
- "/bind10_zones.sqlite3");
- }
- final->set(item, value);
- config = final;
-
- db_file_ = value->stringValue();
- } else {
- return (answer);
- }
- LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_DATA_SOURCE).arg(db_file_);
-
- // create SQL data source
- // Note: the following step is tricky to be exception-safe and to ensure
- // exception guarantee: We first need to perform all operations that can
- // fail, while acquiring resources in the RAII manner. We then perform
- // delete and swap operations which should not fail.
- DataSrcPtr datasrc_ptr(DataSrcPtr(new Sqlite3DataSrc));
- datasrc_ptr->init(config);
- data_sources_.addDataSrc(datasrc_ptr);
-
- // The following code should be exception free.
- if (cur_datasrc_ != NULL) {
- data_sources_.removeDataSrc(cur_datasrc_);
- }
- cur_datasrc_ = datasrc_ptr;
-
- return (answer);
-}
-
void
AuthSrvImpl::resumeServer(DNSServer* server, Message& message, bool done) {
if (done) {
@@ -980,7 +926,7 @@ AuthSrv::updateConfig(ConstElementPtr new_config) {
if (new_config) {
configureAuthServer(*this, new_config);
}
- return (impl_->setDbFile(new_config));
+ return (isc::config::createAnswer());
} catch (const isc::Exception& error) {
LOG_ERROR(auth_logger, AUTH_CONFIG_UPDATE_FAIL).arg(error.what());
return (isc::config::createAnswer(1, error.what()));
@@ -1038,16 +984,9 @@ AuthSrv::setClientList(const RRClass& rrclass,
impl_->client_lists_.erase(rrclass);
}
}
-
boost::shared_ptr<ConfigurableClientList>
AuthSrv::getClientList(const RRClass& rrclass) {
- const map<RRClass, boost::shared_ptr<ConfigurableClientList> >::
- const_iterator it(impl_->client_lists_.find(rrclass));
- if (it == impl_->client_lists_.end()) {
- return (boost::shared_ptr<ConfigurableClientList>());
- } else {
- return (it->second);
- }
+ return (impl_->getClientList(rrclass));
}
vector<RRClass>
diff --git a/src/bin/auth/command.cc b/src/bin/auth/command.cc
index 750ea28..e1ddc39 100644
--- a/src/bin/auth/command.cc
+++ b/src/bin/auth/command.cc
@@ -307,8 +307,11 @@ createAuthCommand(const string& command_id) {
return (new ShutdownCommand());
} else if (command_id == "sendstats") {
return (new SendStatsCommand());
+#if 0
+ // FIXME: The loadzone command will use #2046
} else if (command_id == "loadzone") {
return (new LoadZoneCommand());
+#endif
} else if (false && command_id == "_throw_exception") {
// This is for testing purpose only and should not appear in the
// actual configuration syntax.
diff --git a/src/bin/auth/datasrc_configurator.h b/src/bin/auth/datasrc_configurator.h
index 014ce69..7eaf50a 100644
--- a/src/bin/auth/datasrc_configurator.h
+++ b/src/bin/auth/datasrc_configurator.h
@@ -176,6 +176,33 @@ public:
throw;
}
}
+ /// \brief Version of reconfigure for easier testing.
+ ///
+ /// This method can be used to reconfigure a server without first
+ /// initializing the configurator. This does not need a session.
+ /// Otherwise, it acts the same as reconfigure.
+ ///
+ /// This is not meant for production code. Do not use there.
+ ///
+ /// \param server The server to configure.
+ /// \param config The config to use.
+ /// \throw isc::InvalidOperation if the configurator is initialized.
+ /// \throw anything that reconfigure does.
+ static void testReconfigure(Server* server,
+ const isc::data::ConstElementPtr& config)
+ {
+ if (server_ != NULL) {
+ isc_throw(isc::InvalidOperation, "Currently initialized.");
+ }
+ try {
+ server_ = server;
+ reconfigure(config);
+ server_ = NULL;
+ } catch (...) {
+ server_ = NULL;
+ throw;
+ }
+ }
};
template<class Server, class List>
diff --git a/src/bin/auth/list.h b/src/bin/auth/list.h
deleted file mode 100644
index 180f8bb..0000000
--- a/src/bin/auth/list.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <datasrc/client_list.h>
-#include <datasrc/client.h>
-
-#include <dns/name.h>
-
-// Note: This file breaks almost every rule about how it should look like and
-// other formalities. However, it is only a transitional file and will be deleted
-// before the end of this branch.
-
-using namespace isc::datasrc;
-using namespace isc::dns;
-
-class SingletonList : public ClientList {
-public:
- SingletonList(DataSourceClient& client) :
- client_(client)
- {}
- virtual FindResult find(const Name& zone, bool exact, bool) const {
- DataSourceClient::FindResult result(client_.findZone(zone));
- switch (result.code) {
- case result::SUCCESS:
- return (FindResult(&client_, result.zone_finder, true));
- case result::PARTIALMATCH:
- if (!exact) {
- return (FindResult(&client_, result.zone_finder, false));
- }
- default:
- return (FindResult());
- }
- }
-private:
- DataSourceClient& client_;
-};
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index bb2028b..3010662 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -34,6 +34,7 @@
#include <auth/auth_srv.h>
#include <auth/common.h>
#include <auth/statistics.h>
+#include <auth/datasrc_configurator.h>
#include <util/unittests/mock_socketsession.h>
#include <dns/tests/unittest_util.h>
@@ -224,7 +225,7 @@ createBuiltinVersionResponse(const qid_t qid, vector<uint8_t>& data) {
// The most primitive check: checking the result of the processMessage()
// method
-TEST_F(AuthSrvTest, builtInQuery) {
+TEST_F(AuthSrvTest, DISABLED_builtInQuery) { // Needs builtin
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
default_qid, Name("version.bind"),
RRClass::CH(), RRType::TXT());
@@ -239,6 +240,20 @@ TEST_F(AuthSrvTest, builtInQuery) {
checkAllRcodeCountersZeroExcept(Rcode::NOERROR(), 1);
}
+// We did not configure any client lists. Therefore it should be REFUSED
+TEST_F(AuthSrvTest, noClientList) {
+ UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
+ default_qid, Name("version.bind"),
+ RRClass::CH(), RRType::TXT());
+ createRequestPacket(request_message, IPPROTO_UDP);
+ server.processMessage(*io_message, *parse_message, *response_obuffer,
+ &dnsserv);
+
+ EXPECT_TRUE(dnsserv.hasAnswer());
+ headerCheck(*parse_message, default_qid, Rcode::REFUSED(),
+ opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
+}
+
// Same test emulating the UDPServer class behavior (defined in libasiolink).
// This is not a good test in that it assumes internal implementation details
// of UDPServer, but we've encountered a regression due to the introduction
@@ -248,7 +263,7 @@ TEST_F(AuthSrvTest, builtInQuery) {
// authoritative only server in terms of performance, and it's quite likely
// we need to drop it for the authoritative server implementation.
// At that point we can drop this test, too.
-TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
+TEST_F(AuthSrvTest, DISABLED_builtInQueryViaDNSServer) { //Needs builtin
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
default_qid, Name("version.bind"),
RRClass::CH(), RRType::TXT());
@@ -268,7 +283,7 @@ TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
}
// Same type of test as builtInQueryViaDNSServer but for an error response.
-TEST_F(AuthSrvTest, iqueryViaDNSServer) {
+TEST_F(AuthSrvTest, DISABLED_iqueryViaDNSServer) { // Needs builtin
createDataFromFile("iquery_fromWire.wire");
(*server.getDNSLookupProvider())(*io_message, parse_message,
response_message,
@@ -350,7 +365,7 @@ TEST_F(AuthSrvTest, AXFRSuccess) {
// Try giving the server a TSIG signed request and see it can anwer signed as
// well
-TEST_F(AuthSrvTest, TSIGSigned) {
+TEST_F(AuthSrvTest, DISABLED_TSIGSigned) { // Needs builtin
// Prepare key, the client message, etc
const TSIGKey key("key:c2VjcmV0Cg==:hmac-sha1");
TSIGContext context(key);
@@ -825,9 +840,23 @@ updateConfig(AuthSrv* server, const char* const config_data,
"Bad result from updateConfig: " << result->str();
}
+void
+updateDatabase(AuthSrv* server, const char* params) {
+ const ConstElementPtr config(Element::fromJSON("{"
+ "\"IN\": [{"
+ " \"type\": \"sqlite3\","
+ " \"params\": " + string(params) +
+ "}]}"));
+ DataSourceConfigurator::testReconfigure(server, config);
+}
+
// Install a Sqlite3 data source with testing data.
+#ifdef USE_STATIC_LINK
+TEST_F(AuthSrvTest, DISABLED_updateConfig) {
+#else
TEST_F(AuthSrvTest, updateConfig) {
- updateConfig(&server, CONFIG_TESTDB, true);
+#endif
+ updateDatabase(&server, CONFIG_TESTDB);
// query for existent data in the installed data source. The resulting
// response should have the AA flag on, and have an RR in each answer
@@ -840,8 +869,12 @@ TEST_F(AuthSrvTest, updateConfig) {
QR_FLAG | AA_FLAG, 1, 1, 1, 0);
}
+#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, datasourceFail) {
- updateConfig(&server, CONFIG_TESTDB, true);
+#else
+TEST_F(AuthSrvTest, DISABLED_datasourceFail) {
+#endif
+ updateDatabase(&server, CONFIG_TESTDB);
// This query will hit a corrupted entry of the data source (the zoneload
// tool and the data source itself naively accept it). This will result
@@ -855,12 +888,17 @@ TEST_F(AuthSrvTest, datasourceFail) {
opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
}
+#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, updateConfigFail) {
+#else
+TEST_F(AuthSrvTest, DISABLED_updateConfigFail) {
+#endif
// First, load a valid data source.
- updateConfig(&server, CONFIG_TESTDB, true);
+ updateDatabase(&server, CONFIG_TESTDB);
// Next, try to update it with a non-existent one. This should fail.
- updateConfig(&server, BADCONFIG_TESTDB, false);
+ EXPECT_THROW(updateDatabase(&server, BADCONFIG_TESTDB),
+ isc::datasrc::DataSourceError);
// The original data source should still exist.
createDataFromFile("examplequery_fromWire.wire");
@@ -875,7 +913,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_updateWithInMemoryClient
#else
- updateWithInMemoryClient
+ DISABLED_updateWithInMemoryClient // Needs #2046
#endif
)
{
@@ -903,7 +941,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientNoDNSSEC
#else
- queryWithInMemoryClientNoDNSSEC
+ DISABLED_queryWithInMemoryClientNoDNSSEC // Needs #2046
#endif
)
{
@@ -928,7 +966,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientDNSSEC
#else
- queryWithInMemoryClientDNSSEC
+ DISABLED_queryWithInMemoryClientDNSSEC // Needs #2046
#endif
)
{
@@ -952,7 +990,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_chQueryWithInMemoryClient
#else
- chQueryWithInMemoryClient
+ DISABLED_chQueryWithInMemoryClient // FIXME: Needs the built-in
#endif
)
{
@@ -1376,7 +1414,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientProxy
#else
- queryWithInMemoryClientProxy
+ DISABLED_queryWithInMemoryClientProxy // Needs #2046
#endif
)
{
@@ -1426,7 +1464,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithThrowingProxyServfails
#else
- queryWithThrowingProxyServfails
+ DISABLED_queryWithThrowingProxyServfails // Needs #2046
#endif
)
{
@@ -1457,7 +1495,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientProxyGetClass
#else
- queryWithInMemoryClientProxyGetClass
+ DISABLED_queryWithInMemoryClientProxyGetClass // Needs #2046
#endif
)
{
@@ -1477,7 +1515,7 @@ TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithThrowingInToWire
#else
- queryWithThrowingInToWire
+ DISABLED_queryWithThrowingInToWire // Needs #2046
#endif
)
{
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index ec00d11..1114a32 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -241,7 +241,7 @@ TEST_F(AuthCommandTest,
#ifdef USE_STATIC_LINK
DISABLED_loadZone
#else
- loadZone
+ DISABLED_loadZone // Needs #2046
#endif
)
{
@@ -265,7 +265,7 @@ TEST_F(AuthCommandTest,
#ifdef USE_STATIC_LINK
DISABLED_loadZoneSQLite3
#else
- loadZoneSQLite3
+ DISABLED_loadZoneSQLite3 // Needs #2044
#endif
)
{
@@ -408,7 +408,7 @@ TEST_F(AuthCommandTest,
#ifdef USE_STATIC_LINK
DISABLED_loadBrokenZone
#else
- loadBrokenZone
+ DISABLED_loadBrokenZone // Needs #2046
#endif
)
{
@@ -428,7 +428,7 @@ TEST_F(AuthCommandTest,
#ifdef USE_STATIC_LINK
DISABLED_loadUnreadableZone
#else
- loadUnreadableZone
+ DISABLED_loadUnreadableZone // Needs #2046
#endif
)
{
@@ -454,21 +454,11 @@ TEST_F(AuthCommandTest, loadZoneWithoutDataSrc) {
checkAnswer(1);
}
-TEST_F(AuthCommandTest, loadSqlite3DataSrc) {
- // For sqlite3 data source we don't have to do anything (the data source
- // (re)loads itself automatically)
- result_ = execAuthServerCommand(server_, "loadzone",
- Element::fromJSON(
- "{\"origin\": \"test1.example\","
- " \"datasrc\": \"sqlite3\"}"));
- checkAnswer(0);
-}
-
TEST_F(AuthCommandTest,
#ifdef USE_STATIC_LINK
DISABLED_loadZoneInvalidParams
#else
- loadZoneInvalidParams
+ DISABLED_loadZoneInvalidParams // Needs #2046
#endif
)
{
diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc
index e2d193a..fd6b9a3 100644
--- a/src/bin/auth/tests/config_unittest.cc
+++ b/src/bin/auth/tests/config_unittest.cc
@@ -72,32 +72,6 @@ private:
isc::testutils::TestSocketRequestor sock_requestor_;
};
-TEST_F(AuthConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_datasourceConfig
-#else
- datasourceConfig
-#endif
- )
-{
- // By default, we don't have any in-memory data source.
- EXPECT_FALSE(server.hasInMemoryClient());
- configureAuthServer(server, Element::fromJSON(
- "{\"datasources\": [{\"type\": \"memory\"}]}"));
- // after successful configuration, we should have one (with empty zoneset).
- EXPECT_TRUE(server.hasInMemoryClient());
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
-}
-
-TEST_F(AuthConfigTest, databaseConfig) {
- // right now, "database_file" is handled separately, so the parser
- // doesn't recognize it, but it shouldn't throw an exception due to that.
- EXPECT_NO_THROW(configureAuthServer(
- server,
- Element::fromJSON(
- "{\"database_file\": \"should_be_ignored\"}")));
-}
-
TEST_F(AuthConfigTest, versionConfig) {
// make sure it does not throw on 'version'
EXPECT_NO_THROW(configureAuthServer(
@@ -112,28 +86,12 @@ TEST_F(AuthConfigTest, exceptionGuarantee) {
EXPECT_THROW(configureAuthServer(
server,
Element::fromJSON(
- "{\"datasources\": [{\"type\": \"memory\"}], "
- " \"no_such_config_var\": 1}")),
+ "{ \"no_such_config_var\": 1}")),
AuthConfigError);
// The server state shouldn't change
EXPECT_FALSE(server.hasInMemoryClient());
}
-TEST_F(AuthConfigTest, exceptionConversion) {
- // This configuration contains a bogus RR class, which will trigger an
- // exception from libdns++. configureAuthServer() should convert this
- // to AuthConfigError and rethrow the converted one.
- EXPECT_THROW(configureAuthServer(
- server,
- Element::fromJSON(
- "{\"datasources\": "
- " [{\"type\": \"memory\","
- " \"class\": \"BADCLASS\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"example.zone\"}]}]}")),
- AuthConfigError);
-}
-
TEST_F(AuthConfigTest, badConfig) {
// These should normally not happen, but should be handled to avoid
// an unexpected crash due to a bug of the caller.
@@ -172,343 +130,6 @@ TEST_F(AuthConfigTest, listenAddressConfig) {
EXPECT_EQ(DNSService::SERVER_SYNC_OK, dnss_.getUDPFdParams().at(1).options);
}
-class MemoryDatasrcConfigTest : public AuthConfigTest {
-protected:
- MemoryDatasrcConfigTest() :
- parser(createAuthConfigParser(server, "datasources"))
- {}
- ~MemoryDatasrcConfigTest() {
- delete parser;
- }
- AuthConfigParser* parser;
-};
-
-TEST_F(MemoryDatasrcConfigTest, addZeroDataSrc) {
- parser->build(Element::fromJSON("[]"));
- parser->commit();
- EXPECT_FALSE(server.hasInMemoryClient());
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addEmpty
-#else
- addEmpty
-#endif
- )
-{
- // By default, we don't have any in-memory data source.
- EXPECT_FALSE(server.hasInMemoryClient());
- parser->build(Element::fromJSON("[{\"type\": \"memory\"}]"));
- parser->commit();
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addZeroZone
-#else
- addZeroZone
-#endif
- )
-{
- parser->build(Element::fromJSON("[{\"type\": \"memory\","
- " \"zones\": []}]"));
- parser->commit();
- EXPECT_EQ(0, server.getInMemoryClient(rrclass)->getZoneCount());
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addOneZone
-#else
- addOneZone
-#endif
- )
-{
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
- // Check it actually loaded something
- EXPECT_EQ(ZoneFinder::SUCCESS, server.getInMemoryClient(rrclass)->findZone(
- Name("ns.example.com.")).zone_finder->find(Name("ns.example.com."),
- RRType::A())->code);
-}
-
-// This test uses dynamic load of a data source module, and won't work when
-// statically linked.
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addOneWithFiletypeSQLite3
-#else
- addOneWithFiletypeSQLite3
-#endif
- )
-{
- const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
- stringstream ss("example.org. 3600 IN SOA . . 0 0 0 0 0\n");
- createSQLite3DB(rrclass, Name("example.org"), test_db.c_str(), ss);
-
- // In-memory with an SQLite3 data source as the backend.
- parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.org\","
- " \"file\": \""
- + test_db + "\","
- " \"filetype\": \"sqlite3\"}]}]"));
- parser->commit();
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
-
- // Failure case: the specified zone doesn't exist in the DB file.
- delete parser;
- parser = createAuthConfigParser(server, "datasources");
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \""
- + test_db + "\","
- " \"filetype\": \"sqlite3\"}]}]")),
- DataSourceError);
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addOneWithFiletypeText
-#else
- addOneWithFiletypeText
-#endif
- )
-{
- // Explicitly specifying "text" is okay.
- parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \""
- TEST_DATA_DIR "/example.zone\","
- " \"filetype\": \"text\"}]}]"));
- parser->commit();
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_addMultiZones
-#else
- addMultiZones
-#endif
- )
-{
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"},"
- " {\"origin\": \"example.org\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.org.zone\"},"
- " {\"origin\": \"example.net\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.net.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(3, server.getInMemoryClient(rrclass)->getZoneCount());
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_replace
-#else
- replace
-#endif
- )
-{
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
- server.getInMemoryClient(rrclass)->findZone(
- Name("example.com")).code);
-
- // create a new parser, and install a new set of configuration. It
- // should replace the old one.
- delete parser;
- parser = createAuthConfigParser(server, "datasources");
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.org\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.org.zone\"},"
- " {\"origin\": \"example.net\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.net.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(2, server.getInMemoryClient(rrclass)->getZoneCount());
- EXPECT_EQ(isc::datasrc::result::NOTFOUND,
- server.getInMemoryClient(rrclass)->findZone(
- Name("example.com")).code);
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_exception
-#else
- exception
-#endif
- )
-{
- // Load a zone
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
- server.getInMemoryClient(rrclass)->findZone(
- Name("example.com")).code);
-
- // create a new parser, and try to load something. It will throw,
- // the given master file should not exist
- delete parser;
- parser = createAuthConfigParser(server, "datasources");
- EXPECT_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.org\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.org.zone\"},"
- " {\"origin\": \"example.net\","
- " \"file\": \"" TEST_DATA_DIR
- "/nonexistent.zone\"}]}]")),
- isc::datasrc::DataSourceError);
- // As that one throwed exception, it is not expected from us to
- // commit it
-
- // The original should be untouched
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
- EXPECT_EQ(isc::datasrc::result::SUCCESS,
- server.getInMemoryClient(rrclass)->findZone(
- Name("example.com")).code);
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_remove
-#else
- remove
-#endif
- )
-{
- EXPECT_NO_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"}]}]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_EQ(1, server.getInMemoryClient(rrclass)->getZoneCount());
-
- delete parser;
- parser = createAuthConfigParser(server, "datasources");
- EXPECT_NO_THROW(parser->build(Element::fromJSON("[]")));
- EXPECT_NO_THROW(parser->commit());
- EXPECT_FALSE(server.hasInMemoryClient());
-}
-
-TEST_F(MemoryDatasrcConfigTest, addDuplicateZones) {
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.zone\"},"
- " {\"origin\": \"example.com\","
- " \"file\": \"" TEST_DATA_DIR
- "/example.com.zone\"}]}]")),
- DataSourceError);
-}
-
-TEST_F(MemoryDatasrcConfigTest, addBadZone) {
- // origin and file are missing
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{}]}]")),
- DataSourceError);
-
- // origin is missing
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"file\": \"example.zone\"}]}]")),
- DataSourceError);
-
- // file is missing
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\"}]}]")),
- DataSourceError);
-
- // missing zone file
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example.com\"}]}]")),
- DataSourceError);
-
- // bogus origin name
- EXPECT_THROW(parser->build(Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"zones\": [{\"origin\": \"example..com\","
- " \"file\": \"example.zone\"}]}]")),
- DataSourceError);
-
- // bogus RR class name
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"class\": \"BADCLASS\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"example.zone\"}]}]")),
- InvalidRRClass);
-
- // valid RR class, but not currently supported
- EXPECT_THROW(parser->build(
- Element::fromJSON(
- "[{\"type\": \"memory\","
- " \"class\": \"CH\","
- " \"zones\": [{\"origin\": \"example.com\","
- " \"file\": \"example.zone\"}]}]")),
- isc::InvalidParameter);
-}
-
-TEST_F(MemoryDatasrcConfigTest,
-#ifdef USE_STATIC_LINK
- DISABLED_badDatasrcType
-#else
- badDatasrcType
-#endif
- )
-{
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": \"badsrc\"}]")),
- AuthConfigError);
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"notype\": \"memory\"}]")),
- AuthConfigError);
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": 1}]")),
- isc::data::TypeError);
- EXPECT_THROW(parser->build(Element::fromJSON("[{\"type\": \"memory\"},"
- " {\"type\": \"memory\"}]")),
- AuthConfigError);
-}
-
class StatisticsIntervalConfigTest : public AuthConfigTest {
protected:
StatisticsIntervalConfigTest() :
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index f2ac20e..d63a8eb 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -32,9 +32,9 @@
#include <dns/rdataclass.h>
#include <datasrc/memory_datasrc.h>
+#include <datasrc/client_list.h>
#include <auth/query.h>
-#include <auth/list.h>
#include <testutils/dnsmessage_test.h>
@@ -49,6 +49,32 @@ using namespace isc::testutils;
namespace {
+// Simple wrapper for a sincle data source client.
+// The list simply delegates all the answers to the single
+// client.
+class SingletonList : public ClientList {
+public:
+ SingletonList(DataSourceClient& client) :
+ client_(client)
+ {}
+ virtual FindResult find(const Name& zone, bool exact, bool) const {
+ DataSourceClient::FindResult result(client_.findZone(zone));
+ switch (result.code) {
+ case result::SUCCESS:
+ return (FindResult(&client_, result.zone_finder, true));
+ case result::PARTIALMATCH:
+ if (!exact) {
+ return (FindResult(&client_, result.zone_finder, false));
+ }
+ default:
+ return (FindResult());
+ }
+ }
+private:
+ DataSourceClient& client_;
+};
+
+
// This is the content of the mock zone (see below).
// It's a sequence of textual RRs that is supposed to be parsed by
// dns::masterLoad(). Some of the RRs are also used as the expected
More information about the bind10-changes
mailing list