Commit 0363b418 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2833] cleanup: removed static data source module.

we can do everything that the dedicated static data source did with
"MasterFiles" type of data source with preconfigured parameters.
this cleanup is not directly related to the subject of this task, but
will make later changes simpler.
parent 1a11b2d5
......@@ -261,8 +261,6 @@ updateDatabase(AuthSrv& server, const char* params) {
installDataSrcClientLists(server, configureDataSource(config));
}
// Note: if with_static is set to true, the corresponding test should be
// disabled in case of USE_STATIC_LINK.
void
updateInMemory(AuthSrv& server, const char* origin, const char* filename,
bool with_static = true)
......@@ -277,8 +275,9 @@ updateInMemory(AuthSrv& server, const char* origin, const char* filename,
"}]";
if (with_static) {
spec_txt += ", \"CH\": [{"
" \"type\": \"static\","
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
" \"type\": \"MasterFiles\","
" \"cache-enable\": true,"
" \"params\": {\"BIND\": \"" + string(STATIC_DSRC_FILE) + "\"}"
"}]";
}
spec_txt += "}";
......@@ -287,14 +286,13 @@ updateInMemory(AuthSrv& server, const char* origin, const char* filename,
installDataSrcClientLists(server, configureDataSource(config));
}
// Note: tests using this function should be disabled in case of
// USE_STATIC_LINK.
void
updateBuiltin(AuthSrv& server) {
const ConstElementPtr config(Element::fromJSON("{"
"\"CH\": [{"
" \"type\": \"static\","
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
" \"type\": \"MasterFiles\","
" \"cache-enable\": true,"
" \"params\": {\"BIND\": \"" + string(STATIC_DSRC_FILE) + "\"}"
"}]}"));
installDataSrcClientLists(server, configureDataSource(config));
}
......@@ -747,11 +745,7 @@ TEST_F(AuthSrvTest, notify) {
checkStatisticsCounters(stats_after, expect);
}
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_notifyForCHClass) {
#else
TEST_F(AuthSrvTest, notifyForCHClass) {
#endif
// Same as the previous test, but for the CH RRClass (so we install the
// builtin (static) data source.
updateBuiltin(server);
......@@ -995,11 +989,7 @@ TEST_F(AuthSrvTest, notifyNotAuthNoClass) {
// Try giving the server a TSIG signed request and see it can anwer signed as
// well
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_TSIGSigned) { // Needs builtin
#else
TEST_F(AuthSrvTest, TSIGSigned) {
#endif
// Prepare key, the client message, etc
updateBuiltin(server);
const TSIGKey key("key:c2VjcmV0Cg==:hmac-sha1");
......@@ -1057,11 +1047,7 @@ TEST_F(AuthSrvTest, TSIGSigned) {
// 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.
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_builtInQueryViaDNSServer) {
#else
TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
#endif
updateBuiltin(server);
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
default_qid, Name("VERSION.BIND."),
......@@ -1089,11 +1075,7 @@ TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
// The most primitive check: checking the result of the processMessage()
// method
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_builtInQuery) {
#else
TEST_F(AuthSrvTest, builtInQuery) {
#endif
updateBuiltin(server);
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
default_qid, Name("VERSION.BIND."),
......@@ -1110,11 +1092,7 @@ TEST_F(AuthSrvTest, builtInQuery) {
}
// Same type of test as builtInQueryViaDNSServer but for an error response.
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_iqueryViaDNSServer) { // Needs builtin
#else
TEST_F(AuthSrvTest, iqueryViaDNSServer) { // Needs builtin
#endif
TEST_F(AuthSrvTest, iqueryViaDNSServer) {
updateBuiltin(server);
createDataFromFile("iquery_fromWire.wire");
(*server.getDNSLookupProvider())(*io_message, parse_message,
......@@ -1225,11 +1203,7 @@ TEST_F(AuthSrvTest, updateWithInMemoryClient) {
opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
}
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_queryWithInMemoryClientNoDNSSEC) {
#else
TEST_F(AuthSrvTest, queryWithInMemoryClientNoDNSSEC) {
#endif
// In this example, we do simple check that query is handled from the
// query handler class, and confirm it returns no error and a non empty
// answer section. Detailed examination on the response content
......@@ -1245,11 +1219,7 @@ TEST_F(AuthSrvTest, queryWithInMemoryClientNoDNSSEC) {
opcode.getCode(), QR_FLAG | AA_FLAG, 1, 1, 2, 1);
}
#ifdef USE_STATIC_LINK
TEST_F(AuthSrvTest, DISABLED_queryWithInMemoryClientDNSSEC) {
#else
TEST_F(AuthSrvTest, queryWithInMemoryClientDNSSEC) {
#endif
// Similar to the previous test, but the query has the DO bit on.
// The response should contain RRSIGs, and should have more RRs than
// the previous case.
......@@ -1264,14 +1234,7 @@ TEST_F(AuthSrvTest, queryWithInMemoryClientDNSSEC) {
opcode.getCode(), QR_FLAG | AA_FLAG, 1, 2, 3, 3);
}
TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_chQueryWithInMemoryClient
#else
chQueryWithInMemoryClient
#endif
)
{
TEST_F(AuthSrvTest, chQueryWithInMemoryClient) {
// Set up the in-memory
updateInMemory(server, "example.", CONFIG_INMEMORY_EXAMPLE);
......@@ -1772,14 +1735,7 @@ private:
//
// Set the proxies to never throw, this should have the same result as
// queryWithInMemoryClientNoDNSSEC, and serves to test the two proxy classes
TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientProxy
#else
queryWithInMemoryClientProxy
#endif
)
{
TEST_F(AuthSrvTest, queryWithInMemoryClientProxy) {
// Set real inmem client to proxy
updateInMemory(server, "example.", CONFIG_INMEMORY_EXAMPLE);
boost::shared_ptr<isc::datasrc::ConfigurableClientList> list;
......@@ -1826,14 +1782,7 @@ setupThrow(AuthSrv& server, ThrowWhen throw_when, bool isc_exception,
mgr.setDataSrcClientLists(lists);
}
TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithThrowingProxyServfails
#else
queryWithThrowingProxyServfails
#endif
)
{
TEST_F(AuthSrvTest, queryWithThrowingProxyServfails) {
// Test the common cases, all of which should simply return SERVFAIL
// Use THROW_NEVER as end marker
ThrowWhen throws[] = { THROW_AT_FIND_ZONE,
......@@ -1857,14 +1806,7 @@ TEST_F(AuthSrvTest,
// Throw isc::Exception in getClass(). (Currently?) getClass is not called
// in the processMessage path, so this should result in a normal answer
TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithInMemoryClientProxyGetClass
#else
queryWithInMemoryClientProxyGetClass
#endif
)
{
TEST_F(AuthSrvTest, queryWithInMemoryClientProxyGetClass) {
createDataFromFile("nsec3query_nodnssec_fromWire.wire");
setupThrow(server, THROW_AT_GET_CLASS, true);
......@@ -1877,14 +1819,7 @@ TEST_F(AuthSrvTest,
opcode.getCode(), QR_FLAG | AA_FLAG, 1, 1, 2, 1);
}
TEST_F(AuthSrvTest,
#ifdef USE_STATIC_LINK
DISABLED_queryWithThrowingInToWire
#else
queryWithThrowingInToWire
#endif
)
{
TEST_F(AuthSrvTest, queryWithThrowingInToWire) {
// Set up a faked data source. It will return an empty RRset for the
// query.
ConstRRsetPtr empty_rrset(new RRset(Name("foo.example"),
......
......@@ -18,9 +18,9 @@
],
"CH": [
{
"type": "static",
"cache-enable": false,
"params": "@@STATIC_ZONE_FILE@@"
"type": "MasterFiles",
"cache-enable": true,
"params": {"BIND": "@@STATIC_ZONE_FILE@@"}
}
]
},
......
......@@ -11,6 +11,8 @@ LIBRARY_PATH_PLACEHOLDER += $(ENV_LIBRARY_PATH)=$(abs_top_builddir)/src/lib/cryp
endif
# test using command-line arguments, so use check-local target instead of TESTS
# We need to set B10_FROM_BUILD as some of the tests need to create lock file
# for logging.
check-local:
if ENABLE_PYTHON_COVERAGE
touch $(abs_top_srcdir)/.coverage
......@@ -20,6 +22,7 @@ endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
B10_TEST_PLUGIN_DIR=$(abs_srcdir)/..:$(abs_builddir)/.. \
B10_FROM_BUILD=$(abs_top_builddir) \
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/cfgmgr:$(abs_top_builddir)/src/lib/dns/python/.libs \
$(LIBRARY_PATH_PLACEHOLDER) \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
......
......@@ -43,7 +43,7 @@ libb10_datasrc_la_SOURCES += cache_config.h cache_config.cc
nodist_libb10_datasrc_la_SOURCES = datasrc_messages.h datasrc_messages.cc
libb10_datasrc_la_LDFLAGS = -no-undefined -version-info 1:0:1
pkglib_LTLIBRARIES = sqlite3_ds.la static_ds.la
pkglib_LTLIBRARIES = sqlite3_ds.la
sqlite3_ds_la_SOURCES = sqlite3_accessor.h sqlite3_accessor.cc
sqlite3_ds_la_SOURCES += sqlite3_accessor_link.cc
......@@ -54,12 +54,6 @@ sqlite3_ds_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
sqlite3_ds_la_LIBADD += libb10-datasrc.la
sqlite3_ds_la_LIBADD += $(SQLITE_LIBS)
static_ds_la_SOURCES = static_datasrc_link.cc
static_ds_la_SOURCES += static_datasrc.h
static_ds_la_LDFLAGS = -module -avoid-version
static_ds_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
static_ds_la_LIBADD += libb10-datasrc.la
libb10_datasrc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
libb10_datasrc_la_LIBADD += $(top_builddir)/src/lib/dns/libb10-dns++.la
libb10_datasrc_la_LIBADD += $(top_builddir)/src/lib/log/libb10-log.la
......
// Copyright (C) 2013 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.
#ifndef DATASRC_STATIC_H
#define DATASRC_STATIC_H
#include <datasrc/database.h>
#include <cc/data.h>
#include <string>
namespace isc {
namespace datasrc {
/// \brief Creates an instance of the static datasource client
///
/// Currently the configuration passed here must be a StringElement,
/// containing the path to a zone file for the BIND./CH zone.
///
/// \param config The configuration for the datasource instance (see above)
/// \param error This string will be set to an error message if an error occurs
/// during initialization
/// \return An instance of the static datasource client, or NULL if there was
/// an error
extern "C" DataSourceClient* createInstance(isc::data::ConstElementPtr config,
std::string& error);
/// \brief Destroy the instance created by createInstance()
extern "C" void destroyInstance(DataSourceClient* instance);
}
}
#endif // DATASRC_STATIC_H
// Local Variables:
// mode: c++
// End:
// 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 "static_datasrc.h"
#include <datasrc/memory/memory_client.h>
#include <datasrc/memory/zone_table_segment.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 {
shared_ptr<memory::ZoneTableSegment> ztable_segment(
memory::ZoneTableSegment::create(RRClass::CH(), "local"));
// Create the data source
auto_ptr<memory::InMemoryClient> client
(new memory::InMemoryClient(ztable_segment, RRClass::CH()));
// Fill it with data
const string path(config->stringValue());
client->load(Name("BIND"), path);
return (client.release());
} catch (const std::exception& e) {
error = e.what();
} catch (...) {
error = "Unknown exception";
}
return (NULL);
}
void
destroyInstance(DataSourceClient* instance) {
delete instance;
}
}
}
......@@ -28,8 +28,6 @@ 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 STATIC_BAD_DS_FILE = TEST_DATA_DIR "/static-bad.zone";
const std::string ROOT_ZONE_FILE = TEST_DATA_DIR "/root.zone";
namespace {
......@@ -166,55 +164,5 @@ 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
TEST(FactoryTest, staticDSBadFile) {
// The only configuration is the file to load.
const ConstElementPtr config(new StringElement(STATIC_BAD_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
......@@ -33,8 +33,11 @@ WRITE_ZONE_DB_FILE = TESTDATA_WRITE_PATH + "rwtest.sqlite3.copied"
READ_ZONE_DB_CONFIG = "{ \"database_file\": \"" + READ_ZONE_DB_FILE + "\" }"
WRITE_ZONE_DB_CONFIG = "{ \"database_file\": \"" + WRITE_ZONE_DB_FILE + "\"}"
STATIC_ZONE_CONFIG = '"' + TESTDATA_PATH + "static.zone" + '"'
# Static zone must be built from client list.
STATIC_ZONE_CONFIG = '''[{
"type": "MasterFiles",
"cache-enable": true,
"params": {"BIND": "''' + TESTDATA_PATH + 'static.zone"}}]'
def add_rrset(rrset_list, name, rrclass, rrtype, ttl, rdatas):
rrset_to_add = isc.dns.RRset(name, rrclass, rrtype, ttl)
......@@ -567,7 +570,9 @@ class DataSrcUpdater(unittest.TestCase):
# memory datasource module no longer exists, we check the static
# datasource instead (as that uses the memory datasource
# anyway).
dsc_static = isc.datasrc.DataSourceClient("static", STATIC_ZONE_CONFIG)
clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH)
clist.configure(STATIC_ZONE_CONFIG, True)
dsc_static = clist.find(isc.dns.Name("bind"), True, False)[0]
dsc_sql = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
# check if exceptions are working
......@@ -727,7 +732,9 @@ class DataSrcUpdater(unittest.TestCase):
# As the memory datasource module no longer exists, we check the
# static datasource instead (as that uses the memory datasource
# anyway).
dsc = isc.datasrc.DataSourceClient("static", STATIC_ZONE_CONFIG)
clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH)
clist.configure(STATIC_ZONE_CONFIG, True)
dsc = clist.find(isc.dns.Name("bind"), True, False)[0]
self.assertRaises(isc.datasrc.NotImplemented, dsc.create_zone,
isc.dns.Name("example.com"))
......
......@@ -34,7 +34,11 @@ ORIG_DB_FILE = TESTDATA_PATH + '/example.com.sqlite3'
DB_FILE = TESTDATA_WRITE_PATH + '/zoneloadertest.sqlite3'
DB_CLIENT_CONFIG = '{ "database_file": "' + DB_FILE + '" }'
DB_SOURCE_CLIENT_CONFIG = '{ "database_file": "' + SOURCE_DB_FILE + '" }'
STATIC_ZONE_CONFIG = '"' + TESTDATA_PATH + "/static.zone" + '"'
# Static zone must be built from client list.
STATIC_ZONE_CONFIG = '''[{
"type": "MasterFiles",
"cache-enable": true,
"params": {"BIND": "''' + TESTDATA_PATH + '/static.zone"}}]'
ORIG_SOA_TXT = 'example.com. 3600 IN SOA master.example.com. ' +\
'admin.example.com. 1234 3600 1800 2419200 7200\n'
......@@ -223,8 +227,9 @@ class ZoneLoaderTests(unittest.TestCase):
# This may change in the future, but ATM, the static ds does not
# support the API the zone loader uses (it has direct load
# calls).
inmem_client = isc.datasrc.DataSourceClient('static',
STATIC_ZONE_CONFIG);
clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH)
clist.configure(STATIC_ZONE_CONFIG, True)
inmem_client = clist.find(isc.dns.Name("bind"), True, False)[0]
self.assertRaises(isc.datasrc.NotImplemented,
isc.datasrc.ZoneLoader,
inmem_client, self.test_name, self.test_file)
......@@ -239,8 +244,10 @@ class ZoneLoaderTests(unittest.TestCase):
# For ds->ds loading, wrong class is detected upon construction
# Need a bit of the extended setup for CH source client
clientlist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH)
clientlist.configure('[ { "type": "static", "params": "' +
STATIC_ZONE_FILE +'" } ]', False)
clientlist.configure('[ { "type": "MasterFiles", ' +
'"cache-enable": true, ' +
'"params": {"BIND": "' +
STATIC_ZONE_FILE + '" }} ]', True)
self.source_client, _, _ = clientlist.find(isc.dns.Name("bind."),
False, False)
self.assertRaises(isc.dns.InvalidParameter, isc.datasrc.ZoneLoader,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment