]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Merge branch 'master' into trac2268
authorMukund Sivaraman <muks@isc.org>
Thu, 11 Oct 2012 13:09:13 +0000 (18:39 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 11 Oct 2012 13:22:37 +0000 (18:52 +0530)
Conflicts:
src/lib/datasrc/memory/Makefile.am
src/lib/datasrc/memory/memory_client.cc
src/lib/datasrc/memory/memory_client.h
src/lib/datasrc/tests/memory/memory_client_unittest.cc

1  2 
src/lib/datasrc/memory/Makefile.am
src/lib/datasrc/memory/memory_client.cc
src/lib/datasrc/memory/memory_client.h
src/lib/datasrc/tests/memory/memory_client_unittest.cc
src/lib/datasrc/tests/memory/zone_table_unittest.cc

index d46a9078ee5f5ef456d7844691197a26a6f2a7ac,743caa22f5b3542929cdc9a25a0caefdcc45862b..205f1374c192b8dd76140a262f7e061a98aa0ff9
@@@ -19,8 -19,9 +19,11 @@@ libdatasrc_memory_la_SOURCES += segment
  libdatasrc_memory_la_SOURCES += logger.h logger.cc
  libdatasrc_memory_la_SOURCES += zone_table.h zone_table.cc
  libdatasrc_memory_la_SOURCES += zone_finder.h zone_finder.cc
+ libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.cc
+ libdatasrc_memory_la_SOURCES += zone_table_segment_local.h zone_table_segment_local.cc
 +libdatasrc_memory_la_SOURCES += zone_data_updater.h zone_data_updater.cc
 +libdatasrc_memory_la_SOURCES += memory_client.h memory_client.cc
++
  nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
  
  EXTRA_DIST  = rdata_serialization_priv.cc
index 0857541ecc062e79ace3ab5c5205aceb24b11556,f4213470feda87c79e14223ade27302a37f29ecc..d6b280311ff6a99c15e62c4f763f96f2a5afc4aa
  #include <datasrc/result.h>
  
  #include <dns/name.h>
 -#include <dns/nsec3hash.h>
  #include <dns/rdataclass.h>
  #include <dns/rrclass.h>
- #include <dns/rrsetlist.h>
  #include <dns/masterload.h>
  
 -#include <boost/function.hpp>
 -#include <boost/shared_ptr.hpp>
 -#include <boost/scoped_ptr.hpp>
  #include <boost/bind.hpp>
 -#include <boost/foreach.hpp>
 -#include <boost/noncopyable.hpp>
  
  #include <algorithm>
 -#include <map>
  #include <utility>
  #include <cctype>
  #include <cassert>
@@@ -232,8 -729,9 +229,8 @@@ InMemoryClient::load(const isc::dns::Na
  
  const std::string
  InMemoryClient::getFileName(const isc::dns::Name& zone_name) const {
-     FileNameNode* node(NULL);
-     FileNameTree::Result result = file_name_tree_->find(zone_name, &node);
+     const FileNameNode* node(NULL);
 -    const FileNameTree::Result result = impl_->file_name_tree_->find(zone_name,
 -                                                                     &node);
++    const FileNameTree::Result result = file_name_tree_->find(zone_name, &node);
      if (result == FileNameTree::EXACTMATCH) {
          return (*node->getData());
      } else {
index edd3837b6f5da277529dcce457f91ccaf2745b69,c37ad53c0b28dcf04b186ee8f7eec0bd1bc511b7..9b3113e406e86cb6cac3900e8e0019eeeee9ddaa
@@@ -159,35 -139,40 +159,6 @@@ public
      /// zone from a file before.
      const std::string getFileName(const isc::dns::Name& zone_name) const;
  
-     /// \brief Inserts an rrset into the zone.
-     ///
-     /// It puts another RRset into the zone.
 -    /// \brief RRset is NULL exception.
--    ///
-     /// In the current implementation, this method doesn't allow an existing
-     /// RRset to be updated or overridden.  So the caller must make sure that
-     /// all RRs of the same type and name must be given in the form of a
-     /// single RRset.  The current implementation will also require that
-     /// when an RRSIG is added, the RRset to be covered has already been
-     /// added.  These restrictions are probably too strict when this data
-     /// source accepts various forms of input, so they should be revisited
-     /// later.
 -    /// This is thrown if the provided RRset parameter is NULL.
 -    struct NullRRset : public InvalidParameter {
 -        NullRRset(const char* file, size_t line, const char* what) :
 -            InvalidParameter(file, line, what)
 -        { }
 -    };
 -
 -    /// \brief Zone is empty exception.
--    ///
-     /// Except for NullRRset and OutOfZone, this method does not guarantee
-     /// strong exception safety (it is currently not needed, if it is needed
-     /// in future, it should be implemented).
 -    /// This is thrown if we have an empty zone created as a result of
 -    /// load().
 -    struct EmptyZone : public InvalidParameter {
 -        EmptyZone(const char* file, size_t line, const char* what) :
 -            InvalidParameter(file, line, what)
 -        { }
 -    };
 -
 -    /// \brief General failure exception for \c add().
--    ///
-     /// \throw NullRRset \c rrset is a NULL pointer.
-     /// \throw OutOfZone The owner name of \c rrset is outside of the
-     /// origin of the zone.
-     /// \throw AddError Other general errors.
-     /// \throw Others This method might throw standard allocation exceptions.
 -    /// This is thrown against general error cases in adding an RRset
 -    /// to the zone.
--    ///
-     /// \param rrset The set to add.
-     /// \return SUCCESS or EXIST (if an rrset for given name and type already
-     ///    exists).
-     result::Result add(const isc::dns::Name& zone_name,
-                        const isc::dns::ConstRRsetPtr& rrset);
 -    /// Note: this exception would cover cases for \c OutOfZone or
 -    /// \c NullRRset.  We'll need to clarify and unify the granularity
 -    /// of exceptions eventually.  For now, exceptions are added as
 -    /// developers see the need for it.
 -    struct AddError : public InvalidParameter {
 -        AddError(const char* file, size_t line, const char* what) :
 -            InvalidParameter(file, line, what)
 -        { }
 -    };
--
      /// Returns a \c ZoneFinder result that best matches the given name.
      ///
      /// This derived version of the method never throws an exception.
index 4a34badb3127e07bc762d176c994a4a3d5739c3c,c5b6c10622015acd72896ffa99029ab4f176b879..295c44cb559b5cbbb943c8fccb2ec633586b5c30
@@@ -547,29 -542,6 +546,33 @@@ TEST_F(MemoryClientTest, loadRRSIGs) 
      EXPECT_EQ(1, client_->getZoneCount());
  }
  
++#if 0 // FIXME
++
 +TEST_F(MemoryClientTest, loadRRSIGsRdataMixedCoveredTypes) {
 +    client_->load(Name("example.org"),
 +                  TEST_DATA_DIR "/example.org-rrsigs.zone");
 +
 +    RRsetPtr rrset(new RRset(Name("example.org"),
 +                             RRClass::IN(), RRType::A(), RRTTL(3600)));
 +    rrset->addRdata(in::A("192.0.2.1"));
 +    rrset->addRdata(in::A("192.0.2.2"));
 +
 +    RRsetPtr rrsig(new RRset(Name("example.org"), zclass_,
 +                             RRType::RRSIG(), RRTTL(300)));
 +    rrsig->addRdata(generic::RRSIG("A 5 3 3600 20000101000000 20000201000000 "
 +                                   "12345 example.org. FAKEFAKEFAKE"));
 +    rrsig->addRdata(generic::RRSIG("NS 5 3 3600 20000101000000 20000201000000 "
 +                                   "54321 example.org. FAKEFAKEFAKEFAKE"));
 +    rrset->addRRsig(rrsig);
 +
 +    EXPECT_THROW(client_->add(Name("example.org"), rrset),
 +                 ZoneDataUpdater::AddError);
 +
 +    // Teardown checks for memory segment leaks
 +}
 +
++#endif
++
  TEST_F(MemoryClientTest, getZoneCount) {
      EXPECT_EQ(0, client_->getZoneCount());
      client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");
@@@ -659,75 -631,6 +662,79 @@@ TEST_F(MemoryClientTest, getIteratorGet
      EXPECT_THROW(iterator->getSOA(), isc::NotImplemented);
  }
  
++#if 0 // FIXME
++
 +TEST_F(MemoryClientTest, addRRsetToNonExistentZoneThrows) {
 +    // The zone "example.org" doesn't exist, so we can't add an RRset to
 +    // it.
 +    RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
 +                               RRTTL(300)));
 +    rrset_a->addRdata(rdata::in::A("192.0.2.1"));
 +    EXPECT_THROW(client_->add(Name("example.org"), rrset_a), DataSourceError);
 +}
 +
 +TEST_F(MemoryClientTest, addOutOfZoneThrows) {
 +    // Out of zone names should throw.
 +    client_->load(Name("example.org"),
 +                  TEST_DATA_DIR "/example.org-empty.zone");
 +
 +    RRsetPtr rrset_a(new RRset(Name("a.example.com"),
 +                               RRClass::IN(), RRType::A(), RRTTL(300)));
 +    rrset_a->addRdata(rdata::in::A("192.0.2.1"));
 +
 +    EXPECT_THROW(client_->add(Name("example.org"), rrset_a),
 +                 OutOfZone);
 +    // Teardown checks for memory segment leaks
 +}
 +
 +TEST_F(MemoryClientTest, addNullRRsetThrows) {
 +    client_->load(Name("example.org"),
 +                  TEST_DATA_DIR "/example.org-rrsigs.zone");
 +
 +    EXPECT_THROW(client_->add(Name("example.org"), ConstRRsetPtr()),
 +                 ZoneDataUpdater::NullRRset);
 +
 +    // Teardown checks for memory segment leaks
 +}
 +
 +TEST_F(MemoryClientTest, addEmptyRRsetThrows) {
 +    client_->load(Name("example.org"),
 +                  TEST_DATA_DIR "/example.org-rrsigs.zone");
 +
 +    RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
 +                               RRTTL(300)));
 +    EXPECT_THROW(client_->add(Name("example.org"), rrset_a),
 +                 ZoneDataUpdater::AddError);
 +
 +    // Teardown checks for memory segment leaks
 +}
 +
 +TEST_F(MemoryClientTest, add) {
 +    client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");
 +
 +    // Add another RRset
 +    RRsetPtr rrset_a(new RRset(Name("example.org"), RRClass::IN(), RRType::A(),
 +                               RRTTL(300)));
 +    rrset_a->addRdata(rdata::in::A("192.0.2.1"));
 +    client_->add(Name("example.org"), rrset_a);
 +
 +    ZoneIteratorPtr iterator(client_->getIterator(Name("example.org")));
 +
 +    // First we have the SOA
 +    ConstRRsetPtr rrset(iterator->getNextRRset());
 +    EXPECT_TRUE(rrset);
 +    EXPECT_EQ(RRType::A(), rrset->getType());
 +
 +    rrset = iterator->getNextRRset();
 +    EXPECT_TRUE(rrset);
 +    EXPECT_EQ(RRType::SOA(), rrset->getType());
 +
 +    // There's nothing else in this zone
 +    EXPECT_EQ(ConstRRsetPtr(), iterator->getNextRRset());
 +}
 +
++#endif
++
  TEST_F(MemoryClientTest, findZoneData) {
      client_->load(Name("example.org"),
                    TEST_DATA_DIR "/example.org-rrsigs.zone");
@@@ -778,4 -681,16 +785,5 @@@ TEST_F(MemoryClientTest, getJournalRead
      EXPECT_THROW(client_->getJournalReader(Name("."), 0, 0),
                   isc::NotImplemented);
  }
 -// TODO (upon merge of #2268): Re-add (and modify not to need
 -// InMemoryClient::add) the tests removed in
 -// 7a628baa1a158b5837d6f383e10b30542d2ac59b. Maybe some of them
 -// are really not needed.
 -//
 -// * MemoryClientTest::loadRRSIGsRdataMixedCoveredTypes
 -// * MemoryClientTest::addRRsetToNonExistentZoneThrows
 -// * MemoryClientTest::addOutOfZoneThrows
 -// * MemoryClientTest::addNullRRsetThrows
 -// * MemoryClientTest::addEmptyRRsetThrows
 -// * MemoryClientTest::add
  }
index a8ee6144e23b6124e882771495e94d9a0c4afe78,401d43431b49cd2068b157e43fcddf0b46204024..80f2a6e5f23e70d64c739f59e5fbcd4bcd333cba
  using namespace isc::dns;
  using namespace isc::datasrc;
  using namespace isc::datasrc::memory;
+ using namespace isc::datasrc::memory::detail;
  
  namespace {
 -// Memory segment specified for tests.  It normally behaves like a "local"
 -// memory segment.  If "throw count" is set to non 0 via setThrowCount(),
 -// it continues the normal behavior up to the specified number of calls to
 -// allocate(), and throws an exception at the next call.
 -class TestMemorySegment : public isc::util::MemorySegmentLocal {
 -public:
 -    TestMemorySegment() : throw_count_(0) {}
 -    virtual void* allocate(size_t size) {
 -        if (throw_count_ > 0) {
 -            if (--throw_count_ == 0) {
 -                throw std::bad_alloc();
 -            }
 -        }
 -        return (isc::util::MemorySegmentLocal::allocate(size));
 -    }
 -    void setThrowCount(size_t count) { throw_count_ = count; }
 -
 -private:
 -    size_t throw_count_;
 -};
 -
  class ZoneTableTest : public ::testing::Test {
  protected:
      ZoneTableTest() : zclass_(RRClass::IN()),