TESTS += run_unittests
run_unittests_SOURCES = run_unittests.cc
+run_unittests_SOURCES += zone_loader_util.h zone_loader_util.cc
run_unittests_SOURCES += rdata_serialization_unittest.cc
run_unittests_SOURCES += rdataset_unittest.cc
run_unittests_SOURCES += domaintree_unittest.cc
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include "memory_segment_test.h"
-#include "zone_table_segment_test.h"
+#include <datasrc/tests/memory/memory_segment_test.h>
+#include <datasrc/tests/memory/zone_table_segment_test.h>
+#include <datasrc/tests/memory/zone_loader_util.h>
// NOTE: this faked_nsec3 inclusion (and all related code below)
// was ported during #2109 for the convenience of implementing #2218
// In #2219 the original is expected to be removed, and this file should
// probably be moved here (and any leftover code not handled in #2218 should
// be cleaned up)
-#include "../../tests/faked_nsec3.h"
+#include <datasrc/tests/faked_nsec3.h>
#include <datasrc/memory/zone_finder.h>
#include <datasrc/memory/zone_data_updater.h>
// \brief testcase for #2504 (Problem in inmem NSEC denial of existence
// handling)
TEST_F(InMemoryZoneFinderTest, NSECNonExistentTest) {
+ const Name name("example.com.");
shared_ptr<ZoneTableSegment> ztable_segment(
new ZoneTableSegmentTest(class_, mem_sgmt_));
+ loadZoneIntoTable(*ztable_segment, name, class_,
+ TEST_DATA_DIR "/2504-test.zone");
InMemoryClient client(ztable_segment, class_);
- Name name("example.com.");
- client.load(name, TEST_DATA_DIR "/2504-test.zone");
DataSourceClient::FindResult result(client.findZone(name));
// Check for a non-existing name
DefaultNSEC3HashCreator creator;
setNSEC3HashCreator(&creator);
+ const Name name("example.com.");
shared_ptr<ZoneTableSegment> ztable_segment(
new ZoneTableSegmentTest(class_, mem_sgmt_));
+ loadZoneIntoTable(*ztable_segment, name, class_,
+ TEST_DATA_DIR "/2503-test.zone");
InMemoryClient client(ztable_segment, class_);
- Name name("example.com.");
- client.load(name, TEST_DATA_DIR "/2503-test.zone");
DataSourceClient::FindResult result(client.findZone(name));
// Check for a non-existing name
- Name search_name("nonexist.example.com.");
+ const Name search_name("nonexist.example.com.");
ZoneFinder::FindNSEC3Result find_result(
result.zone_finder->findNSEC3(search_name, true));
// findNSEC3() must have completed (not throw or assert). Because
--- /dev/null
+// 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.
+
+#include <datasrc/tests/memory/zone_loader_util.h>
+
+#include <datasrc/cache_config.h>
+#include <datasrc/memory/zone_table_segment.h>
+#include <datasrc/memory/zone_writer.h>
+
+#include <dns/dns_fwd.h>
+
+#include <cc/data.h>
+
+#include <boost/scoped_ptr.hpp>
+
+#include <string>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+namespace test {
+
+void
+loadZoneIntoTable(ZoneTableSegment& zt_sgmt, const dns::Name& zname,
+ const dns::RRClass& zclass, const std::string& zone_file)
+{
+ const isc::datasrc::internal::CacheConfig cache_conf(
+ "MasterFiles", 0, *data::Element::fromJSON(
+ "{\"cache-enable\": true,"
+ " \"params\": {\"" + zname.toText() + "\": \"" + zone_file +
+ "\"}}"), true);
+ boost::scoped_ptr<memory::ZoneWriter> writer(
+ zt_sgmt.getZoneWriter(cache_conf.getLoadAction(zclass, zname),
+ zname, zclass));
+ writer->load();
+ writer->install();
+ writer->cleanup();
+}
+
+} // namespace test
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// 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_MEMORY_TEST_ZONE_LOADER_UTIL_H
+#define DATASRC_MEMORY_TEST_ZONE_LOADER_UTIL_H 1
+
+#include <datasrc/memory/zone_table_segment.h>
+
+#include <dns/dns_fwd.h>
+
+#include <string>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+namespace test {
+
+/// \brief A shortcut utility to load a specified zone into ZoneTableSegment.
+///
+/// This function does nothing special, simply provides a shortcut for commonly
+/// used pattern that would be used in tests with a ZoneTableSegment loading
+/// a zone from file into it.
+void
+loadZoneIntoTable(ZoneTableSegment& zt_sgmt, const dns::Name& zname,
+ const dns::RRClass& zclass, const std::string& zone_file);
+
+} // namespace test
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // DATASRC_MEMORY_TEST_ZONE_LOADER_UTIL_H
+
+// Local Variables:
+// mode: c++
+// End:
#include <dns/name.h>
#include <dns/rrclass.h>
+#include <cc/data.h>
+
#include <datasrc/zone_finder.h>
+#include <datasrc/cache_config.h>
#include <datasrc/memory/memory_client.h>
#include <datasrc/memory/zone_table_segment.h>
+#include <datasrc/memory/zone_writer.h>
#include <datasrc/database.h>
#include <datasrc/sqlite3_accessor.h>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
#include <fstream>
#include <sstream>
using namespace std;
using boost::shared_ptr;
+using boost::scoped_ptr;
using namespace isc::data;
using namespace isc::util;
using namespace isc::dns;
using namespace isc::datasrc;
+using isc::data::Element;
using isc::datasrc::memory::InMemoryClient;
using isc::datasrc::memory::ZoneTableSegment;
using namespace isc::testutils;
// Creator for the in-memory client to be tested
DataSourceClientPtr
createInMemoryClient(RRClass zclass, const Name& zname) {
+ const internal::CacheConfig cache_conf(
+ "MasterFiles", 0, *Element::fromJSON(
+ "{\"cache-enable\": true,"
+ " \"params\":"
+ " {\"" + zname.toText() + "\": \"" +
+ string(TEST_ZONE_FILE) + "\"}}"), true);
shared_ptr<ZoneTableSegment> ztable_segment(
- ZoneTableSegment::create(zclass, "local"));
+ ZoneTableSegment::create(zclass, cache_conf.getSegmentType()));
+ scoped_ptr<memory::ZoneWriter> writer(
+ ztable_segment->getZoneWriter(cache_conf.getLoadAction(zclass, zname),
+ zname, zclass));
+ writer->load();
+ writer->install();
+ writer->cleanup();
shared_ptr<InMemoryClient> client(new InMemoryClient(ztable_segment,
zclass));
- client->load(zname, TEST_ZONE_FILE);
return (client);
}
#include <datasrc/zone_loader.h>
#include <datasrc/exceptions.h>
#include <datasrc/rrset_collection_base.h>
+#include <datasrc/cache_config.h>
#include <datasrc/memory/zone_table_segment.h>
#include <datasrc/memory/memory_client.h>
+#include <datasrc/memory/zone_writer.h>
#include <dns/rrclass.h>
#include <dns/name.h>
#include <util/memory_segment_local.h>
#include <exceptions/exceptions.h>
+#include <cc/data.h>
+
#include <gtest/gtest.h>
#include <boost/shared_ptr.hpp>
using namespace isc::dns;
using namespace isc::datasrc;
+using isc::data::Element;
using boost::shared_ptr;
using std::string;
using std::vector;
// (re)configure zone table, then (re)construct the in-memory client
// with it.
- ztable_segment_.reset(memory::ZoneTableSegment::create(rrclass_,
- "local"));
- source_client_.reset(new memory::InMemoryClient(ztable_segment_,
- rrclass_));
+ string param_data;
if (filename) {
- source_client_->load(zone, string(TEST_DATA_DIR) + "/" + filename);
+ param_data = "\"" + zone.toText() + "\": \"" +
+ string(TEST_DATA_DIR) + "/" + filename + "\"";
}
+ const internal::CacheConfig cache_conf(
+ "MasterFiles", 0, *Element::fromJSON(
+ "{\"cache-enable\": true,"
+ " \"params\": {" + param_data + "}}"), true);
+ ztable_segment_.reset(memory::ZoneTableSegment::create(
+ rrclass_, cache_conf.getSegmentType()));
+ if (filename) {
+ boost::scoped_ptr<memory::ZoneWriter> writer(
+ ztable_segment_->getZoneWriter(cache_conf.getLoadAction(
+ rrclass_, zone),
+ zone, rrclass_));
+ writer->load();
+ writer->install();
+ writer->cleanup();
+ }
+ source_client_.reset(new memory::InMemoryClient(ztable_segment_,
+ rrclass_));
}
private:
const RRClass rrclass_;