mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[2207] Rename ZoneUpdater -> ZoneWriter
According to the review, Updater might be misleading.
This commit is contained in:
@@ -22,7 +22,7 @@ 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_finder.h zone_finder.cc
|
||||||
libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.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_table_segment_local.h zone_table_segment_local.cc
|
||||||
libdatasrc_memory_la_SOURCES += zone_reloader.h zone_reloader.cc
|
libdatasrc_memory_la_SOURCES += zone_writer.h zone_writer.cc
|
||||||
libdatasrc_memory_la_SOURCES += load_action.h
|
libdatasrc_memory_la_SOURCES += load_action.h
|
||||||
nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
|
nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ class RRClass;
|
|||||||
}
|
}
|
||||||
namespace datasrc {
|
namespace datasrc {
|
||||||
namespace memory {
|
namespace memory {
|
||||||
class ZoneReloader;
|
class ZoneWriter;
|
||||||
|
|
||||||
/// \brief Memory-management independent entry point that contains a
|
/// \brief Memory-management independent entry point that contains a
|
||||||
/// pointer to a zone table in memory.
|
/// pointer to a zone table in memory.
|
||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
/// \param rrclass The class of the zone to reload.
|
/// \param rrclass The class of the zone to reload.
|
||||||
/// \return New instance of a zone reloader. The ownership is passed
|
/// \return New instance of a zone reloader. The ownership is passed
|
||||||
/// onto the caller.
|
/// onto the caller.
|
||||||
virtual ZoneReloader* getZoneReloader(const LoadAction& load_action,
|
virtual ZoneWriter* getZoneWriter(const LoadAction& load_action,
|
||||||
const dns::Name& origin,
|
const dns::Name& origin,
|
||||||
const dns::RRClass& rrclass) = 0;
|
const dns::RRClass& rrclass) = 0;
|
||||||
};
|
};
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <datasrc/memory/zone_table_segment_local.h>
|
#include <datasrc/memory/zone_table_segment_local.h>
|
||||||
#include "zone_reloader.h"
|
#include "zone_writer.h"
|
||||||
|
|
||||||
using namespace isc::util;
|
using namespace isc::util;
|
||||||
|
|
||||||
@@ -39,12 +39,12 @@ ZoneTableSegmentLocal::getMemorySegment() {
|
|||||||
return (mem_sgmt_);
|
return (mem_sgmt_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneReloader*
|
ZoneWriter*
|
||||||
ZoneTableSegmentLocal::getZoneReloader(const LoadAction& load_action,
|
ZoneTableSegmentLocal::getZoneWriter(const LoadAction& load_action,
|
||||||
const dns::Name& name,
|
const dns::Name& name,
|
||||||
const dns::RRClass& rrclass)
|
const dns::RRClass& rrclass)
|
||||||
{
|
{
|
||||||
return (new ZoneReloaderLocal(this, load_action, name, rrclass));
|
return (new ZoneWriterLocal(this, load_action, name, rrclass));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace memory
|
} // namespace memory
|
||||||
|
@@ -54,8 +54,8 @@ public:
|
|||||||
/// implementation (a MemorySegmentLocal instance).
|
/// implementation (a MemorySegmentLocal instance).
|
||||||
virtual isc::util::MemorySegment& getMemorySegment();
|
virtual isc::util::MemorySegment& getMemorySegment();
|
||||||
|
|
||||||
/// \brief Concrete implementation of ZoneTableSegment::getZoneReloader
|
/// \brief Concrete implementation of ZoneTableSegment::getZoneWriter
|
||||||
virtual ZoneReloader* getZoneReloader(const LoadAction& load_action,
|
virtual ZoneWriter* getZoneWriter(const LoadAction& load_action,
|
||||||
const dns::Name& origin,
|
const dns::Name& origin,
|
||||||
const dns::RRClass& rrclass);
|
const dns::RRClass& rrclass);
|
||||||
private:
|
private:
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include "zone_reloader.h"
|
#include "zone_writer.h"
|
||||||
#include "zone_data.h"
|
#include "zone_data.h"
|
||||||
#include "zone_table_segment.h"
|
#include "zone_table_segment.h"
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ namespace isc {
|
|||||||
namespace datasrc {
|
namespace datasrc {
|
||||||
namespace memory {
|
namespace memory {
|
||||||
|
|
||||||
ZoneReloaderLocal::ZoneReloaderLocal(ZoneTableSegment* segment,
|
ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegment* segment,
|
||||||
const LoadAction& load_action,
|
const LoadAction& load_action,
|
||||||
const dns::Name& origin,
|
const dns::Name& origin,
|
||||||
const dns::RRClass& rrclass) :
|
const dns::RRClass& rrclass) :
|
||||||
@@ -37,14 +37,14 @@ ZoneReloaderLocal::ZoneReloaderLocal(ZoneTableSegment* segment,
|
|||||||
data_ready_(false)
|
data_ready_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ZoneReloaderLocal::~ZoneReloaderLocal() {
|
ZoneWriterLocal::~ZoneWriterLocal() {
|
||||||
// Clean up everything there might be left if someone forgot, just
|
// Clean up everything there might be left if someone forgot, just
|
||||||
// in case. Or should we assert instead?
|
// in case. Or should we assert instead?
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ZoneReloaderLocal::load() {
|
ZoneWriterLocal::load() {
|
||||||
if (loaded_) {
|
if (loaded_) {
|
||||||
isc_throw(isc::Unexpected, "Trying to load twice");
|
isc_throw(isc::Unexpected, "Trying to load twice");
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ ZoneReloaderLocal::load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ZoneReloaderLocal::install() {
|
ZoneWriterLocal::install() {
|
||||||
if (!data_ready_) {
|
if (!data_ready_) {
|
||||||
isc_throw(isc::Unexpected, "No data to install");
|
isc_throw(isc::Unexpected, "No data to install");
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ ZoneReloaderLocal::install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ZoneReloaderLocal::cleanup() {
|
ZoneWriterLocal::cleanup() {
|
||||||
// We eat the data (if any) now.
|
// We eat the data (if any) now.
|
||||||
data_ready_ = false;
|
data_ready_ = false;
|
||||||
|
|
@@ -35,7 +35,7 @@ class ZoneTableSegment;
|
|||||||
/// We divide them so the update of zone data can be done asynchronously,
|
/// We divide them so the update of zone data can be done asynchronously,
|
||||||
/// in a different thread. The install() operation is the only one that needs
|
/// in a different thread. The install() operation is the only one that needs
|
||||||
/// to be done in a critical section.
|
/// to be done in a critical section.
|
||||||
class ZoneReloader {
|
class ZoneWriter {
|
||||||
public:
|
public:
|
||||||
/// \brief Get the zone data into memory.
|
/// \brief Get the zone data into memory.
|
||||||
///
|
///
|
||||||
@@ -80,13 +80,13 @@ public:
|
|||||||
virtual void cleanup() = 0;
|
virtual void cleanup() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Reloader implementation which loads data locally.
|
/// \brief Writer implementation which loads data locally.
|
||||||
///
|
///
|
||||||
/// This implementation prepares a clean zone data and lets one callback
|
/// This implementation prepares a clean zone data and lets one callback
|
||||||
/// to fill it and another to install it somewhere. The class does mostly
|
/// to fill it and another to install it somewhere. The class does mostly
|
||||||
/// nothing (and delegates the work to the callbacks), just stores little bit
|
/// nothing (and delegates the work to the callbacks), just stores little bit
|
||||||
/// of state between the calls.
|
/// of state between the calls.
|
||||||
class ZoneReloaderLocal : public ZoneReloader {
|
class ZoneWriterLocal : public ZoneWriter {
|
||||||
public:
|
public:
|
||||||
/// \brief Constructor
|
/// \brief Constructor
|
||||||
///
|
///
|
||||||
@@ -94,10 +94,10 @@ public:
|
|||||||
/// \param load_action The callback used to load data.
|
/// \param load_action The callback used to load data.
|
||||||
/// \param install_action The callback used to install the loaded zone.
|
/// \param install_action The callback used to install the loaded zone.
|
||||||
/// \param rrclass The class of the zone.
|
/// \param rrclass The class of the zone.
|
||||||
ZoneReloaderLocal(ZoneTableSegment* segment, const LoadAction& load_action,
|
ZoneWriterLocal(ZoneTableSegment* segment, const LoadAction& load_action,
|
||||||
const dns::Name& name, const dns::RRClass& rrclass);
|
const dns::Name& name, const dns::RRClass& rrclass);
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
~ZoneReloaderLocal();
|
~ZoneWriterLocal();
|
||||||
/// \brief Loads the data.
|
/// \brief Loads the data.
|
||||||
///
|
///
|
||||||
/// This prepares an empty ZoneData and calls load_action (passed to
|
/// This prepares an empty ZoneData and calls load_action (passed to
|
@@ -33,7 +33,7 @@ run_unittests_SOURCES += memory_segment_test.h
|
|||||||
run_unittests_SOURCES += segment_object_holder_unittest.cc
|
run_unittests_SOURCES += segment_object_holder_unittest.cc
|
||||||
run_unittests_SOURCES += memory_client_unittest.cc
|
run_unittests_SOURCES += memory_client_unittest.cc
|
||||||
run_unittests_SOURCES += zone_table_segment_unittest.cc
|
run_unittests_SOURCES += zone_table_segment_unittest.cc
|
||||||
run_unittests_SOURCES += zone_reloader_unittest.cc
|
run_unittests_SOURCES += zone_writer_unittest.cc
|
||||||
|
|
||||||
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
||||||
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
|
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <datasrc/memory/zone_table_segment.h>
|
#include <datasrc/memory/zone_table_segment.h>
|
||||||
#include <datasrc/memory/zone_reloader.h>
|
#include <datasrc/memory/zone_writer.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
@@ -92,16 +92,16 @@ load_action(MemorySegment&) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test we can get a reloader.
|
// Test we can get a writer.
|
||||||
TEST_F(ZoneTableSegmentTest, getZoneReloader) {
|
TEST_F(ZoneTableSegmentTest, getZoneWriter) {
|
||||||
scoped_ptr<ZoneReloader>
|
scoped_ptr<ZoneWriter>
|
||||||
reloader(segment_->getZoneReloader(load_action, Name("example.org"),
|
writer(segment_->getZoneWriter(load_action, Name("example.org"),
|
||||||
RRClass::IN()));
|
RRClass::IN()));
|
||||||
// We have to get something
|
// We have to get something
|
||||||
EXPECT_NE(static_cast<void*>(NULL), reloader.get());
|
EXPECT_NE(static_cast<void*>(NULL), writer.get());
|
||||||
// And for now, it should be the local reloader
|
// And for now, it should be the local writer
|
||||||
EXPECT_NE(static_cast<void*>(NULL),
|
EXPECT_NE(static_cast<void*>(NULL),
|
||||||
dynamic_cast<ZoneReloaderLocal*>(reloader.get()));
|
dynamic_cast<ZoneWriterLocal*>(writer.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <datasrc/memory/zone_reloader.h>
|
#include <datasrc/memory/zone_writer.h>
|
||||||
#include <datasrc/memory/zone_table_segment.h>
|
#include <datasrc/memory/zone_table_segment.h>
|
||||||
#include <datasrc/memory/zone_data.h>
|
#include <datasrc/memory/zone_data.h>
|
||||||
|
|
||||||
@@ -35,16 +35,16 @@ namespace {
|
|||||||
|
|
||||||
class TestException {};
|
class TestException {};
|
||||||
|
|
||||||
class ZoneReloaderLocalTest : public ::testing::Test {
|
class ZoneWriterLocalTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
ZoneReloaderLocalTest() :
|
ZoneWriterLocalTest() :
|
||||||
// FIXME: The NullElement probably isn't the best one, but we don't
|
// FIXME: The NullElement probably isn't the best one, but we don't
|
||||||
// know how the config will look, so it just fills the argument
|
// know how the config will look, so it just fills the argument
|
||||||
// (which is currently ignored)
|
// (which is currently ignored)
|
||||||
segment_(ZoneTableSegment::create(isc::data::NullElement())),
|
segment_(ZoneTableSegment::create(isc::data::NullElement())),
|
||||||
reloader_(new
|
writer_(new
|
||||||
ZoneReloaderLocal(segment_.get(),
|
ZoneWriterLocal(segment_.get(),
|
||||||
bind(&ZoneReloaderLocalTest::loadAction, this,
|
bind(&ZoneWriterLocalTest::loadAction, this,
|
||||||
_1),
|
_1),
|
||||||
Name("example.org"), RRClass::IN())),
|
Name("example.org"), RRClass::IN())),
|
||||||
load_called_(false),
|
load_called_(false),
|
||||||
@@ -57,8 +57,8 @@ public:
|
|||||||
RRClass::IN()));
|
RRClass::IN()));
|
||||||
}
|
}
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
// Release the reloader
|
// Release the writer
|
||||||
reloader_.reset();
|
writer_.reset();
|
||||||
// Release the table we used
|
// Release the table we used
|
||||||
ZoneTable::destroy(segment_->getMemorySegment(),
|
ZoneTable::destroy(segment_->getMemorySegment(),
|
||||||
segment_->getHeader().getTable(), RRClass::IN());
|
segment_->getHeader().getTable(), RRClass::IN());
|
||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
scoped_ptr<ZoneTableSegment> segment_;
|
scoped_ptr<ZoneTableSegment> segment_;
|
||||||
scoped_ptr<ZoneReloaderLocal> reloader_;
|
scoped_ptr<ZoneWriterLocal> writer_;
|
||||||
bool load_called_;
|
bool load_called_;
|
||||||
bool load_throw_;
|
bool load_throw_;
|
||||||
bool load_null_;
|
bool load_null_;
|
||||||
@@ -94,112 +94,112 @@ private:
|
|||||||
|
|
||||||
// We call it the way we are supposed to, check every callback is called in the
|
// We call it the way we are supposed to, check every callback is called in the
|
||||||
// right moment.
|
// right moment.
|
||||||
TEST_F(ZoneReloaderLocalTest, correctCall) {
|
TEST_F(ZoneWriterLocalTest, correctCall) {
|
||||||
// Nothing called before we call it
|
// Nothing called before we call it
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
// Just the load gets called now
|
// Just the load gets called now
|
||||||
EXPECT_NO_THROW(reloader_->load());
|
EXPECT_NO_THROW(writer_->load());
|
||||||
EXPECT_TRUE(load_called_);
|
EXPECT_TRUE(load_called_);
|
||||||
load_called_ = false;
|
load_called_ = false;
|
||||||
|
|
||||||
EXPECT_NO_THROW(reloader_->install());
|
EXPECT_NO_THROW(writer_->install());
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
// We don't check explicitly how this works, but call it to free memory. If
|
// We don't check explicitly how this works, but call it to free memory. If
|
||||||
// everything is freed should be checked inside the TearDown.
|
// everything is freed should be checked inside the TearDown.
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ZoneReloaderLocalTest, loadTwice) {
|
TEST_F(ZoneWriterLocalTest, loadTwice) {
|
||||||
// Load it the first time
|
// Load it the first time
|
||||||
EXPECT_NO_THROW(reloader_->load());
|
EXPECT_NO_THROW(writer_->load());
|
||||||
EXPECT_TRUE(load_called_);
|
EXPECT_TRUE(load_called_);
|
||||||
load_called_ = false;
|
load_called_ = false;
|
||||||
|
|
||||||
// The second time, it should not be possible
|
// The second time, it should not be possible
|
||||||
EXPECT_THROW(reloader_->load(), isc::Unexpected);
|
EXPECT_THROW(writer_->load(), isc::Unexpected);
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
// The object should not be damaged, try installing and clearing now
|
// The object should not be damaged, try installing and clearing now
|
||||||
EXPECT_NO_THROW(reloader_->install());
|
EXPECT_NO_THROW(writer_->install());
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
// We don't check explicitly how this works, but call it to free memory. If
|
// We don't check explicitly how this works, but call it to free memory. If
|
||||||
// everything is freed should be checked inside the TearDown.
|
// everything is freed should be checked inside the TearDown.
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try loading after call to install and call to cleanup. Both is
|
// Try loading after call to install and call to cleanup. Both is
|
||||||
// forbidden.
|
// forbidden.
|
||||||
TEST_F(ZoneReloaderLocalTest, loadLater) {
|
TEST_F(ZoneWriterLocalTest, loadLater) {
|
||||||
// Load first, so we can install
|
// Load first, so we can install
|
||||||
EXPECT_NO_THROW(reloader_->load());
|
EXPECT_NO_THROW(writer_->load());
|
||||||
EXPECT_NO_THROW(reloader_->install());
|
EXPECT_NO_THROW(writer_->install());
|
||||||
// Reset so we see nothing is called now
|
// Reset so we see nothing is called now
|
||||||
load_called_ = false;
|
load_called_ = false;
|
||||||
|
|
||||||
EXPECT_THROW(reloader_->load(), isc::Unexpected);
|
EXPECT_THROW(writer_->load(), isc::Unexpected);
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
// Cleanup and try loading again. Still shouldn't work.
|
// Cleanup and try loading again. Still shouldn't work.
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
|
|
||||||
EXPECT_THROW(reloader_->load(), isc::Unexpected);
|
EXPECT_THROW(writer_->load(), isc::Unexpected);
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try calling install at various bad times
|
// Try calling install at various bad times
|
||||||
TEST_F(ZoneReloaderLocalTest, invalidInstall) {
|
TEST_F(ZoneWriterLocalTest, invalidInstall) {
|
||||||
// Nothing loaded yet
|
// Nothing loaded yet
|
||||||
EXPECT_THROW(reloader_->install(), isc::Unexpected);
|
EXPECT_THROW(writer_->install(), isc::Unexpected);
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
|
|
||||||
EXPECT_NO_THROW(reloader_->load());
|
EXPECT_NO_THROW(writer_->load());
|
||||||
load_called_ = false;
|
load_called_ = false;
|
||||||
// This install is OK
|
// This install is OK
|
||||||
EXPECT_NO_THROW(reloader_->install());
|
EXPECT_NO_THROW(writer_->install());
|
||||||
// But we can't call it second time now
|
// But we can't call it second time now
|
||||||
EXPECT_THROW(reloader_->install(), isc::Unexpected);
|
EXPECT_THROW(writer_->install(), isc::Unexpected);
|
||||||
EXPECT_FALSE(load_called_);
|
EXPECT_FALSE(load_called_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We check we can clean without installing first and nothing bad
|
// We check we can clean without installing first and nothing bad
|
||||||
// happens. We also misuse the testcase to check we can't install
|
// happens. We also misuse the testcase to check we can't install
|
||||||
// after cleanup.
|
// after cleanup.
|
||||||
TEST_F(ZoneReloaderLocalTest, cleanWithoutInstall) {
|
TEST_F(ZoneWriterLocalTest, cleanWithoutInstall) {
|
||||||
EXPECT_NO_THROW(reloader_->load());
|
EXPECT_NO_THROW(writer_->load());
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
|
|
||||||
EXPECT_TRUE(load_called_);
|
EXPECT_TRUE(load_called_);
|
||||||
|
|
||||||
// We cleaned up, no way to install now
|
// We cleaned up, no way to install now
|
||||||
EXPECT_THROW(reloader_->install(), isc::Unexpected);
|
EXPECT_THROW(writer_->install(), isc::Unexpected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the case when load callback throws
|
// Test the case when load callback throws
|
||||||
TEST_F(ZoneReloaderLocalTest, loadThrows) {
|
TEST_F(ZoneWriterLocalTest, loadThrows) {
|
||||||
load_throw_ = true;
|
load_throw_ = true;
|
||||||
EXPECT_THROW(reloader_->load(), TestException);
|
EXPECT_THROW(writer_->load(), TestException);
|
||||||
|
|
||||||
// We can't install now
|
// We can't install now
|
||||||
EXPECT_THROW(reloader_->install(), isc::Unexpected);
|
EXPECT_THROW(writer_->install(), isc::Unexpected);
|
||||||
EXPECT_TRUE(load_called_);
|
EXPECT_TRUE(load_called_);
|
||||||
|
|
||||||
// But we can cleanup
|
// But we can cleanup
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the reloader defends itsefl when load action returns NULL
|
// Check the writer defends itsefl when load action returns NULL
|
||||||
TEST_F(ZoneReloaderLocalTest, loadNull) {
|
TEST_F(ZoneWriterLocalTest, loadNull) {
|
||||||
load_null_ = true;
|
load_null_ = true;
|
||||||
EXPECT_THROW(reloader_->load(), isc::Unexpected);
|
EXPECT_THROW(writer_->load(), isc::Unexpected);
|
||||||
|
|
||||||
// We can't install that
|
// We can't install that
|
||||||
EXPECT_THROW(reloader_->install(), isc::Unexpected);
|
EXPECT_THROW(writer_->install(), isc::Unexpected);
|
||||||
|
|
||||||
// It should be possible to clean up safely
|
// It should be possible to clean up safely
|
||||||
EXPECT_NO_THROW(reloader_->cleanup());
|
EXPECT_NO_THROW(writer_->cleanup());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user