BIND 10 trac491, updated. 4864018bdb5a6f3f9ea9d7a9cc608521655233dd [trac491] initial basic hookup of the cache
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Feb 16 15:16:20 UTC 2011
The branch, trac491 has been updated
via 4864018bdb5a6f3f9ea9d7a9cc608521655233dd (commit)
via c2a34db25f4b0c903a025514cdff758e7ea55e42 (commit)
via 98908690535371b9128a1263c7a4b59150609526 (commit)
via a01b61f9915856af9c915beca5061867804e5a86 (commit)
via 5ba0bcb7d12da8e28ca791fef5bdb82ee2619fa8 (commit)
via 4f992e158c48eba97d4cfd497a1abba12336e38d (commit)
via 496a0353cded1f60342e7713c28fecdffcecbbbe (commit)
from 6c11d9c51b88e2a6d238eac951d1d0317978f636 (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 4864018bdb5a6f3f9ea9d7a9cc608521655233dd
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Feb 16 16:14:39 2011 +0100
[trac491] initial basic hookup of the cache
It only stores the final result, and only looks into the cache at the start of a resolve() call right now, but it appears to work
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/Makefile.am | 1 +
src/bin/auth/benchmarks/Makefile.am | 1 +
src/bin/auth/tests/Makefile.am | 1 +
src/bin/resolver/Makefile.am | 2 +
src/bin/resolver/resolver.cc | 11 +---
src/bin/resolver/tests/Makefile.am | 2 +
src/lib/asiolink/Makefile.am | 2 +
src/lib/asiolink/recursive_query.cc | 67 ++++++++++++++++----
src/lib/asiolink/recursive_query.h | 4 +
src/lib/asiolink/tests/Makefile.am | 2 +
src/lib/asiolink/udp_server.cc | 2 +
src/lib/cache/TODO | 2 +
src/lib/cache/message_cache.cc | 4 +
src/lib/cache/message_entry.cc | 4 +-
src/lib/cache/message_entry.h | 11 +--
src/lib/cache/resolver_cache.cc | 7 +-
src/lib/cache/rrset_cache.cc | 5 +-
src/lib/cache/rrset_cache.h | 2 +-
src/lib/cache/rrset_entry.cc | 2 +
src/lib/cache/tests/Makefile.am | 9 +++
...he_test_util.h => cache_test_messagefromfile.h} | 18 -----
...cache_test_util.h => cache_test_sectioncount.h} | 15 +----
src/lib/cache/tests/local_zone_data_unittest.cc | 2 +-
src/lib/cache/tests/message_cache_unittest.cc | 2 +-
src/lib/cache/tests/message_entry_unittest.cc | 3 +-
src/lib/cache/tests/resolver_cache_unittest.cc | 2 +-
src/lib/cache/tests/rrset_entry_unittest.cc | 3 +-
27 files changed, 114 insertions(+), 72 deletions(-)
copy src/lib/cache/tests/{cache_test_util.h => cache_test_messagefromfile.h} (74%)
rename src/lib/cache/tests/{cache_test_util.h => cache_test_sectioncount.h} (76%)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am
index e9097f2..36de53d 100644
--- a/src/bin/auth/Makefile.am
+++ b/src/bin/auth/Makefile.am
@@ -50,6 +50,7 @@ b10_auth_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.la
b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
b10_auth_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
+b10_auth_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
b10_auth_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
b10_auth_LDADD += $(SQLITE_LIBS)
diff --git a/src/bin/auth/benchmarks/Makefile.am b/src/bin/auth/benchmarks/Makefile.am
index 05ab754..653d502 100644
--- a/src/bin/auth/benchmarks/Makefile.am
+++ b/src/bin/auth/benchmarks/Makefile.am
@@ -21,5 +21,6 @@ query_bench_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
query_bench_LDADD += $(top_builddir)/src/lib/cc/libcc.la
query_bench_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
query_bench_LDADD += $(top_builddir)/src/lib/log/liblog.la
+query_bench_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
query_bench_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
query_bench_LDADD += $(SQLITE_LIBS)
diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am
index a1114e4..def99b0 100644
--- a/src/bin/auth/tests/Makefile.am
+++ b/src/bin/auth/tests/Makefile.am
@@ -45,6 +45,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
endif
noinst_PROGRAMS = $(TESTS)
diff --git a/src/bin/resolver/Makefile.am b/src/bin/resolver/Makefile.am
index 9e86ddd..75d6249 100644
--- a/src/bin/resolver/Makefile.am
+++ b/src/bin/resolver/Makefile.am
@@ -48,6 +48,8 @@ b10_resolver_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
b10_resolver_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
b10_resolver_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
b10_resolver_LDADD += $(top_builddir)/src/lib/log/liblog.la
+b10_resolver_LDADD += $(top_builddir)/src/lib/cache/libcache.la
+b10_resolver_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
b10_resolver_LDADD += $(top_builddir)/src/bin/auth/change_user.o
b10_resolver_LDFLAGS = -pthread
diff --git a/src/bin/resolver/resolver.cc b/src/bin/resolver/resolver.cc
index dfd84a6..c635fc9 100644
--- a/src/bin/resolver/resolver.cc
+++ b/src/bin/resolver/resolver.cc
@@ -256,11 +256,10 @@ public:
const qid_t qid = query_message->getQid();
const bool rd = query_message->getHeaderFlag(Message::HEADERFLAG_RD);
const bool cd = query_message->getHeaderFlag(Message::HEADERFLAG_CD);
- const Opcode& opcode = query_message->getOpcode();
-
- // Fill in the final details of the answer message
+
+ // The opcode and question section should have already been set,
+ // fill in the final details of the answer message
answer_message->setQid(qid);
- answer_message->setOpcode(opcode);
answer_message->setHeaderFlag(Message::HEADERFLAG_QR);
answer_message->setHeaderFlag(Message::HEADERFLAG_RA);
@@ -271,10 +270,6 @@ public:
answer_message->setHeaderFlag(Message::HEADERFLAG_CD);
}
- vector<QuestionPtr> questions;
- questions.assign(query_message->beginQuestion(), query_message->endQuestion());
- for_each(questions.begin(), questions.end(), QuestionInserter(answer_message));
-
// Now we can clear the buffer and render the new message into it
buffer->clear();
MessageRenderer renderer(*buffer);
diff --git a/src/bin/resolver/tests/Makefile.am b/src/bin/resolver/tests/Makefile.am
index a03439c..3dc6b3b 100644
--- a/src/bin/resolver/tests/Makefile.am
+++ b/src/bin/resolver/tests/Makefile.am
@@ -37,6 +37,8 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
# Note the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS
diff --git a/src/lib/asiolink/Makefile.am b/src/lib/asiolink/Makefile.am
index 868fde5..2c76fd9 100644
--- a/src/lib/asiolink/Makefile.am
+++ b/src/lib/asiolink/Makefile.am
@@ -43,3 +43,5 @@ endif
libasiolink_la_CPPFLAGS = $(AM_CPPFLAGS)
libasiolink_la_LIBADD = $(top_builddir)/src/lib/log/liblog.la
libasiolink_la_LIBADD += $(top_builddir)/src/lib/resolve/libresolve.la
+libasiolink_la_LIBADD += $(top_builddir)/src/lib/cache/libcache.la
+libasiolink_la_LIBADD += $(top_builddir)/src/lib/nsas/libnsas.la
diff --git a/src/lib/asiolink/recursive_query.cc b/src/lib/asiolink/recursive_query.cc
index 9f814b0..a5e3d79 100644
--- a/src/lib/asiolink/recursive_query.cc
+++ b/src/lib/asiolink/recursive_query.cc
@@ -32,9 +32,12 @@
#include <dns/question.h>
#include <dns/message.h>
+#include <dns/opcode.h>
#include <resolve/resolve.h>
+#include <cache/resolver_cache.h>
+
using isc::log::dlog;
using namespace isc::dns;
@@ -123,7 +126,7 @@ private:
asio::deadline_timer lookup_timer;
size_t queries_out_;
-
+
// If we timed out ourselves (lookup timeout), stop issuing queries
bool done_;
@@ -132,6 +135,9 @@ private:
// answer if we do find one later (or if we have a lookup_timeout)
bool answer_sent_;
+ // Reference to our cache
+ isc::cache::ResolverCache& cache_;
+
// (re)send the query to the server.
void send() {
const int uc = upstream_->size();
@@ -291,7 +297,8 @@ public:
OutputBufferPtr buffer,
isc::resolve::ResolverInterface::CallbackPtr cb,
int query_timeout, int client_timeout, int lookup_timeout,
- unsigned retries) :
+ unsigned retries,
+ isc::cache::ResolverCache& cache) :
io_(io),
question_(question),
answer_message_(answer_message),
@@ -306,7 +313,8 @@ public:
lookup_timer(io),
queries_out_(0),
done_(false),
- answer_sent_(false)
+ answer_sent_(false),
+ cache_(cache)
{
// Setup the timer to stop trying (lookup_timeout)
if (lookup_timeout >= 0) {
@@ -366,6 +374,11 @@ public:
// until that one comes back to us)
done_ = true;
if (resume && !answer_sent_) {
+ // Store the answer we found in our cache
+ std::cout << "[XX] caching our answer:" << std::endl;
+ std::cout << answer_message_->toText();
+ cache_.update(*answer_message_);
+ std::cout << "[XX] done caching our answer" << std::endl;
resolvercallback_->success(answer_message_);
} else {
resolvercallback_->failure();
@@ -424,11 +437,26 @@ RecursiveQuery::resolve(const QuestionPtr& question,
MessagePtr answer_message(new Message(Message::RENDER));
OutputBufferPtr buffer(new OutputBuffer(0));
-
- // It will delete itself when it is done
- new RunningQuery(io, *question, answer_message, upstream_,
- upstream_root_, buffer, callback, query_timeout_,
- client_timeout_, lookup_timeout_, retries_);
+
+ // TODO: general 'prepareinitialanswer'
+ answer_message->setOpcode(isc::dns::Opcode::QUERY());
+ answer_message->addQuestion(question);
+ dlog("Try out cache first (direct call to resolve)");
+ // First try to see if we have something cached in the messagecache
+ if (cache_.lookup(question->getName(), question->getType(),
+ question->getClass(), *answer_message)) {
+ dlog("Message found in cache, returning that");
+ // TODO: err, should cache set rcode as well?
+ answer_message->setRcode(Rcode::NOERROR());
+ callback->success(answer_message);
+ } else {
+ dlog("Message not found in cache, starting recursive query");
+ // It will delete itself when it is done
+ new RunningQuery(io, *question, answer_message, upstream_,
+ upstream_root_, buffer, callback, query_timeout_,
+ client_timeout_, lookup_timeout_, retries_,
+ cache_);
+ }
}
void
@@ -445,11 +473,26 @@ RecursiveQuery::resolve(const Question& question,
isc::resolve::ResolverInterface::CallbackPtr crs(
new isc::resolve::ResolverCallbackServer(server));
+
+ // TODO: general 'prepareinitialanswer'
+ answer_message->setOpcode(isc::dns::Opcode::QUERY());
+ answer_message->addQuestion(question);
- // It will delete itself when it is done
- new RunningQuery(io, question, answer_message, upstream_, upstream_root_,
- buffer, crs, query_timeout_, client_timeout_,
- lookup_timeout_, retries_);
+ // First try to see if we have something cached in the messagecache
+ dlog("Try out cache first (started by incoming event)");
+ if (cache_.lookup(question.getName(), question.getType(),
+ question.getClass(), *answer_message)) {
+ dlog("Message found in cache, returning that");
+ // TODO: err, should cache set rcode as well?
+ answer_message->setRcode(Rcode::NOERROR());
+ crs->success(answer_message);
+ } else {
+ dlog("Message not found in cache, starting recursive query");
+ // It will delete itself when it is done
+ new RunningQuery(io, question, answer_message, upstream_, upstream_root_,
+ buffer, crs, query_timeout_, client_timeout_,
+ lookup_timeout_, retries_, cache_);
+ }
}
diff --git a/src/lib/asiolink/recursive_query.h b/src/lib/asiolink/recursive_query.h
index 0660c09..6ef0069 100644
--- a/src/lib/asiolink/recursive_query.h
+++ b/src/lib/asiolink/recursive_query.h
@@ -18,6 +18,7 @@
#include <asiolink/dns_service.h>
#include <asiolink/dns_server.h>
#include <dns/buffer.h>
+#include <cache/resolver_cache.h>
namespace asiolink {
/// \brief The \c RecursiveQuery class provides a layer of abstraction around
@@ -107,6 +108,9 @@ private:
int client_timeout_;
int lookup_timeout_;
unsigned retries_;
+ // Cache. TODO: I think we want this initialized in Resolver class,
+ // not here
+ isc::cache::ResolverCache cache_;
};
} // namespace asiolink
diff --git a/src/lib/asiolink/tests/Makefile.am b/src/lib/asiolink/tests/Makefile.am
index 7fe268e..619221c 100644
--- a/src/lib/asiolink/tests/Makefile.am
+++ b/src/lib/asiolink/tests/Makefile.am
@@ -33,6 +33,8 @@ run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS)
run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
diff --git a/src/lib/asiolink/udp_server.cc b/src/lib/asiolink/udp_server.cc
index 9a18d76..3331cd1 100644
--- a/src/lib/asiolink/udp_server.cc
+++ b/src/lib/asiolink/udp_server.cc
@@ -28,6 +28,8 @@
#include <asiolink/udp_server.h>
+#include <dns/opcode.h>
+
using namespace asio;
using asio::ip::udp;
using asio::ip::tcp;
diff --git a/src/lib/cache/TODO b/src/lib/cache/TODO
index 0743ee4..a7d2458 100644
--- a/src/lib/cache/TODO
+++ b/src/lib/cache/TODO
@@ -9,4 +9,6 @@
can removed first.
* Make resolver cache be smart to refetch the messages that are about
to expire.
+* When the rrset beging updated is an NS rrset, NSAS should be updated
+ together.
diff --git a/src/lib/cache/message_cache.cc b/src/lib/cache/message_cache.cc
index 9706fc4..5edf81c 100644
--- a/src/lib/cache/message_cache.cc
+++ b/src/lib/cache/message_cache.cc
@@ -14,6 +14,8 @@
// $Id$
+#include <config.h>
+
#include <nsas/nsas_entry_compare.h>
#include <nsas/hash_table.h>
#include <nsas/hash_deleter.h>
@@ -43,6 +45,7 @@ MessageCache::lookup(const isc::dns::Name& qname,
isc::dns::Message& response)
{
std::string entry_name = genCacheEntryName(qname, qtype);
+ std::cout << "[XX] MESSAGECACHE LOOKUP: " << entry_name << std::endl;
HashKey entry_key = HashKey(entry_name, RRClass(message_class_));
MessageEntryPtr msg_entry = message_table_.get(entry_key);
if(msg_entry) {
@@ -57,6 +60,7 @@ bool
MessageCache::update(const Message& msg) {
QuestionIterator iter = msg.beginQuestion();
std::string entry_name = genCacheEntryName((*iter)->getName(), (*iter)->getType());
+ std::cout << "[XX] MESSAGECACHE UDPATE: " << entry_name << std::endl;
HashKey entry_key = HashKey(entry_name, RRClass(message_class_));
// The simplest way to update is removing the old message entry directly.
diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc
index 26c8bee..2fdb07c 100644
--- a/src/lib/cache/message_entry.cc
+++ b/src/lib/cache/message_entry.cc
@@ -14,6 +14,8 @@
// $Id$
+#include <config.h>
+
#include <limits>
#include <dns/message.h>
#include <nsas/nsas_entry.h>
@@ -129,7 +131,7 @@ MessageEntry::getRRsetTrustLevel(const Message& message,
++rrset_iter;
}
assert(rrset_iter != message.endSection(section));
-
+
// According RFC2181 section 5.4.1, only the record
// describing that ailas is necessarily authoritative.
// If there is one or more CNAME records in answer section.
diff --git a/src/lib/cache/message_entry.h b/src/lib/cache/message_entry.h
index 0ed00f0..20b2472 100644
--- a/src/lib/cache/message_entry.h
+++ b/src/lib/cache/message_entry.h
@@ -89,16 +89,14 @@ public:
return (*hash_key_ptr_);
}
+ /// \short Protected memebers, so they can be accessed by tests.
+ //@{
protected:
/// \brief Initialize the message entry with dns message.
///
/// \param message The Message to initialize the entry with
void initMessageEntry(const isc::dns::Message& message);
- /// \brief These two functions should be static functions
- /// placed in cc file. Put them here just for easy unit
- /// tests.
- //@{
/// \brief Parse the rrsets in specified section.
///
/// \param msg The message to parse the RRsets from
@@ -148,10 +146,9 @@ protected:
/// otherwise.
bool getRRsetEntries(std::vector<RRsetEntryPtr>& rrset_entry_vec,
const time_t time_now);
- //@}
-protected:
- /// \note Make the variable be protected for easy test.
+
time_t expire_time_; // Expiration time of the message.
+ //@}
private:
std::string entry_name_; // The name for this entry(name + type)
diff --git a/src/lib/cache/resolver_cache.cc b/src/lib/cache/resolver_cache.cc
index 41a8487..c9183b0 100644
--- a/src/lib/cache/resolver_cache.cc
+++ b/src/lib/cache/resolver_cache.cc
@@ -14,6 +14,8 @@
// $Id$
+#include <config.h>
+
#include "resolver_cache.h"
#include "dns/message.h"
#include "rrset_cache.h"
@@ -199,8 +201,8 @@ ResolverCache::lookupClosestRRset(const isc::dns::Name& qname,
bool
ResolverCache::update(const isc::dns::Message& msg) {
-
QuestionIterator iter = msg.beginQuestion();
+ RRClass c = (*iter)->getClass();
ResolverClassCache* cc = getClassCache((*iter)->getClass());
if (cc) {
return (cc->update(msg));
@@ -239,9 +241,6 @@ ResolverCache::getClassCache(const isc::dns::RRClass& cache_class) const {
return NULL;
}
-
-
-
} // namespace cache
} // namespace isc
diff --git a/src/lib/cache/rrset_cache.cc b/src/lib/cache/rrset_cache.cc
index d374164..86ee867 100644
--- a/src/lib/cache/rrset_cache.cc
+++ b/src/lib/cache/rrset_cache.cc
@@ -14,6 +14,8 @@
// $Id$
+#include <config.h>
+
#include <string>
#include "rrset_cache.h"
#include <nsas/nsas_entry_compare.h>
@@ -74,11 +76,10 @@ RRsetCache::update(const isc::dns::RRset& rrset, const RRsetTrustLevel& level) {
return (entry_ptr);
} else {
HashKey key = entry_ptr->hashKey();
- rrset_table_.remove(key);
entry_ptr.reset(new RRsetEntry(rrset, level));
//TODO, lru list touch.
// Replace the expired rrset entry if it exists.
- rrset_table_.add(entry_ptr, key, true);
+ rrset_table_.add(entry_ptr, entry_ptr->hashKey(), true);
return (entry_ptr);
}
}
diff --git a/src/lib/cache/rrset_cache.h b/src/lib/cache/rrset_cache.h
index d082b3c..3dda239 100644
--- a/src/lib/cache/rrset_cache.h
+++ b/src/lib/cache/rrset_cache.h
@@ -17,7 +17,7 @@
#ifndef __RRSET_CACHE_H
#define __RRSET_CACHE_H
-#include <rrset_entry.h>
+#include <cache/rrset_entry.h>
#include <nsas/hash_table.h>
#include <nsas/lru_list.h>
diff --git a/src/lib/cache/rrset_entry.cc b/src/lib/cache/rrset_entry.cc
index 7c8b2bf..9407e97 100644
--- a/src/lib/cache/rrset_entry.cc
+++ b/src/lib/cache/rrset_entry.cc
@@ -14,6 +14,8 @@
// $Id$
+#include <config.h>
+
#include <dns/message.h>
#include <nsas/nsas_entry.h>
#include <nsas/fetchable.h>
diff --git a/src/lib/cache/tests/Makefile.am b/src/lib/cache/tests/Makefile.am
index 9bc3e3a..b93c9a7 100644
--- a/src/lib/cache/tests/Makefile.am
+++ b/src/lib/cache/tests/Makefile.am
@@ -38,6 +38,8 @@ run_unittests_SOURCES += message_cache_unittest.cc
run_unittests_SOURCES += message_entry_unittest.cc
run_unittests_SOURCES += local_zone_data_unittest.cc
run_unittests_SOURCES += resolver_cache_unittest.cc
+run_unittests_SOURCES += cache_test_messagefromfile.h
+run_unittests_SOURCES += cache_test_sectioncount.h
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
@@ -55,3 +57,10 @@ run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
noinst_PROGRAMS = $(TESTS)
+
+EXTRA_DIST = testdata/message_fromWire1
+EXTRA_DIST += testdata/message_fromWire2
+EXTRA_DIST += testdata/message_fromWire3
+EXTRA_DIST += testdata/message_fromWire4
+EXTRA_DIST += testdata/message_fromWire5
+EXTRA_DIST += testdata/message_fromWire6
diff --git a/src/lib/cache/tests/cache_test_messagefromfile.h b/src/lib/cache/tests/cache_test_messagefromfile.h
new file mode 100644
index 0000000..820d822
--- /dev/null
+++ b/src/lib/cache/tests/cache_test_messagefromfile.h
@@ -0,0 +1,40 @@
+// Copyright (C) 2010 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.
+
+// $Id$
+#include <vector>
+#include <dns/tests/unittest_util.h>
+#include <dns/buffer.h>
+#include <dns/message.h>
+
+using namespace isc;
+using namespace isc::dns;
+
+namespace {
+
+/// \brief Reads a Message from a data file
+///
+/// \param message Message to put the read data in
+/// \param datafile The file to read from
+void
+messageFromFile(Message& message, const char* datafile) {
+ std::vector<unsigned char> data;
+ UnitTestUtil::readWireData(datafile, data);
+
+ InputBuffer buffer(&data[0], data.size());
+ message.fromWire(buffer);
+}
+
+} // namespace
+
diff --git a/src/lib/cache/tests/cache_test_sectioncount.h b/src/lib/cache/tests/cache_test_sectioncount.h
new file mode 100644
index 0000000..a385133
--- /dev/null
+++ b/src/lib/cache/tests/cache_test_sectioncount.h
@@ -0,0 +1,45 @@
+// Copyright (C) 2010 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.
+
+// $Id$
+#include <vector>
+#include <dns/tests/unittest_util.h>
+#include <dns/buffer.h>
+#include <dns/message.h>
+
+using namespace isc;
+using namespace isc::dns;
+
+namespace {
+
+/// \brief Counts the number of rrsets in the given section
+///
+/// \param msg The message to count in
+/// \param section The section to count
+///
+/// \return The number of RRsets in the given section
+int
+sectionRRsetCount(Message& msg, Message::Section section) {
+ int count = 0;
+ for (RRsetIterator rrset_iter = msg.beginSection(section);
+ rrset_iter != msg.endSection(section);
+ ++rrset_iter) {
+ ++count;
+ }
+
+ return count;
+}
+
+} // namespace
+
diff --git a/src/lib/cache/tests/cache_test_util.h b/src/lib/cache/tests/cache_test_util.h
deleted file mode 100644
index ed9988b..0000000
--- a/src/lib/cache/tests/cache_test_util.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (C) 2010 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.
-
-// $Id$
-#include <vector>
-#include <dns/tests/unittest_util.h>
-#include <dns/buffer.h>
-#include <dns/message.h>
-
-using namespace isc;
-using namespace isc::dns;
-
-namespace {
-
-/// \brief Reads a Message from a data file
-///
-/// \param message Message to put the read data in
-/// \param datafile The file to read from
-void
-messageFromFile(Message& message, const char* datafile) {
- std::vector<unsigned char> data;
- UnitTestUtil::readWireData(datafile, data);
-
- InputBuffer buffer(&data[0], data.size());
- message.fromWire(buffer);
-}
-
-/// \brief Counts the number of rrsets in the given section
-///
-/// \param msg The message to count in
-/// \param section The section to count
-///
-/// \return The number of RRsets in the given section
-int
-sectionRRsetCount(Message& msg, Message::Section section) {
- int count = 0;
- for (RRsetIterator rrset_iter = msg.beginSection(section);
- rrset_iter != msg.endSection(section);
- ++rrset_iter) {
- ++count;
- }
-
- return count;
-}
-
-} // namespace
-
diff --git a/src/lib/cache/tests/local_zone_data_unittest.cc b/src/lib/cache/tests/local_zone_data_unittest.cc
index 01e035b..28de4be 100644
--- a/src/lib/cache/tests/local_zone_data_unittest.cc
+++ b/src/lib/cache/tests/local_zone_data_unittest.cc
@@ -19,7 +19,7 @@
#include <cache/local_zone_data.h>
#include <dns/rrset.h>
#include <dns/rrttl.h>
-#include "cache_test_util.h"
+#include "cache_test_messagefromfile.h"
using namespace isc::cache;
using namespace isc::dns;
diff --git a/src/lib/cache/tests/message_cache_unittest.cc b/src/lib/cache/tests/message_cache_unittest.cc
index ed6ebc4..f984312 100644
--- a/src/lib/cache/tests/message_cache_unittest.cc
+++ b/src/lib/cache/tests/message_cache_unittest.cc
@@ -21,7 +21,7 @@
#include "../message_cache.h"
#include "../rrset_cache.h"
#include "../resolver_cache.h"
-#include "cache_test_util.h"
+#include "cache_test_messagefromfile.h"
using namespace isc::cache;
using namespace isc;
diff --git a/src/lib/cache/tests/message_entry_unittest.cc b/src/lib/cache/tests/message_entry_unittest.cc
index 48a02b9..f0fc777 100644
--- a/src/lib/cache/tests/message_entry_unittest.cc
+++ b/src/lib/cache/tests/message_entry_unittest.cc
@@ -22,7 +22,8 @@
#include "../message_entry.h"
#include "../rrset_cache.h"
#include "../resolver_cache.h"
-#include "cache_test_util.h"
+#include "cache_test_messagefromfile.h"
+#include "cache_test_sectioncount.h"
using namespace isc::cache;
using namespace isc;
diff --git a/src/lib/cache/tests/resolver_cache_unittest.cc b/src/lib/cache/tests/resolver_cache_unittest.cc
index 6621df0..a3cf728 100644
--- a/src/lib/cache/tests/resolver_cache_unittest.cc
+++ b/src/lib/cache/tests/resolver_cache_unittest.cc
@@ -18,7 +18,7 @@
#include <gtest/gtest.h>
#include <dns/rrset.h>
#include "resolver_cache.h"
-#include "cache_test_util.h"
+#include "cache_test_messagefromfile.h"
using namespace isc::cache;
using namespace isc::dns;
diff --git a/src/lib/cache/tests/rrset_entry_unittest.cc b/src/lib/cache/tests/rrset_entry_unittest.cc
index ce6238f..29c05b5 100644
--- a/src/lib/cache/tests/rrset_entry_unittest.cc
+++ b/src/lib/cache/tests/rrset_entry_unittest.cc
@@ -49,9 +49,10 @@ TEST_F(GenCacheKeyTest, genCacheEntryKey2) {
class DerivedRRsetEntry: public RRsetEntry {
public:
+ DerivedRRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& level) : RRsetEntry(rrset, level) {};
void updateTTLForTest() {
-
+
}
};
More information about the bind10-changes
mailing list