mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[2203] pass server obj to configurator's reconfigure().
now the configurator class is completely stateless.
This commit is contained in:
@@ -81,7 +81,6 @@ protected:
|
||||
QueryBenchMark(const BenchQueries& queries, Message& query_message,
|
||||
OutputBuffer& buffer) :
|
||||
server_(new AuthSrv(xfrout_client, ddns_forwarder)),
|
||||
datasrc_configurator_(server_.get()),
|
||||
queries_(queries),
|
||||
query_message_(query_message),
|
||||
buffer_(buffer),
|
||||
@@ -128,6 +127,7 @@ public:
|
||||
QueryBenchMark(queries, query_message, buffer)
|
||||
{
|
||||
datasrc_configurator_.reconfigure(
|
||||
*server_,
|
||||
Element::fromJSON("{\"IN\":"
|
||||
" [{\"type\": \"sqlite3\","
|
||||
" \"params\": {"
|
||||
@@ -146,6 +146,7 @@ public:
|
||||
QueryBenchMark(queries, query_message, buffer)
|
||||
{
|
||||
datasrc_configurator_.reconfigure(
|
||||
*server_,
|
||||
Element::fromJSON("{\"IN\":"
|
||||
" [{\"type\": \"MasterFiles\","
|
||||
" \"cache-enable\": true, "
|
||||
|
@@ -18,8 +18,6 @@
|
||||
#include "auth_srv.h"
|
||||
|
||||
#include <datasrc/client_list.h>
|
||||
#include <config/ccsession.h>
|
||||
#include <cc/data.h>
|
||||
#include <util/threads/lock.h>
|
||||
|
||||
#include <set>
|
||||
@@ -36,48 +34,10 @@
|
||||
template<class Server, class List>
|
||||
class DataSourceConfiguratorGeneric {
|
||||
private:
|
||||
Server* server_;
|
||||
typedef boost::shared_ptr<List> ListPtr;
|
||||
public:
|
||||
/// \brief Constructor.
|
||||
///
|
||||
/// \throw isc::InvalidParameter if server is NULL
|
||||
/// \param server The server to configure.
|
||||
DataSourceConfiguratorGeneric(Server* server) : server_(server) {
|
||||
if (server == NULL) {
|
||||
isc_throw(isc::InvalidParameter, "The server must not be NULL");
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Initializes the class.
|
||||
///
|
||||
/// This configures which session and server should be used.
|
||||
/// It hooks to the session now and downloads the configuration.
|
||||
/// It is synchronous (it may block for some time).
|
||||
///
|
||||
/// Note that you need to call cleanup before the server or
|
||||
/// session dies, otherwise it might access them after they
|
||||
/// are destroyed.
|
||||
///
|
||||
/// \param server It is the server to configure.
|
||||
/// \throw isc::InvalidOperation if this is called when already
|
||||
/// initialized.
|
||||
/// \throw isc::InvalidParameter if any of the parameters is NULL
|
||||
/// \throw isc::config::ModuleCCError if the remote configuration is not
|
||||
/// available for some reason.
|
||||
void init() {
|
||||
}
|
||||
|
||||
/// \brief Deinitializes the class.
|
||||
///
|
||||
/// This detaches from the session and removes the server from internal
|
||||
/// storage. The current configuration in the server is preserved.
|
||||
///
|
||||
/// This can be called even if it is not initialized currently. You
|
||||
/// can initialize it again after this.
|
||||
void cleanup() {
|
||||
server_ = NULL;
|
||||
}
|
||||
/// \brief Default constructor.
|
||||
DataSourceConfiguratorGeneric() {}
|
||||
|
||||
/// \brief Reads new configuration and replaces the old one.
|
||||
///
|
||||
@@ -86,16 +46,15 @@ public:
|
||||
/// is unknown and it would be questionable at least). It is called
|
||||
/// automatically on normal updates.
|
||||
///
|
||||
/// \param server The server for which the data sources are to be
|
||||
/// configured.
|
||||
/// \param config The configuration value to parse. It is in the form
|
||||
/// as an update from the config manager.
|
||||
/// \throw InvalidOperation if it is called when not initialized.
|
||||
void reconfigure(const isc::data::ConstElementPtr& config) {
|
||||
if (server_ == NULL) {
|
||||
isc_throw(isc::InvalidOperation,
|
||||
"Can't reconfigure while not initialized by init()");
|
||||
}
|
||||
void reconfigure(Server& server,
|
||||
const isc::data::ConstElementPtr& config)
|
||||
{
|
||||
// Lock the client lists, we're going to manipulate them.
|
||||
isc::util::thread::Mutex::Locker locker(server_->getClientListMutex());
|
||||
isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
|
||||
typedef std::map<std::string, isc::data::ConstElementPtr> Map;
|
||||
typedef std::pair<isc::dns::RRClass, ListPtr> RollbackPair;
|
||||
typedef std::pair<isc::dns::RRClass, isc::data::ConstElementPtr>
|
||||
@@ -107,14 +66,14 @@ public:
|
||||
// Get the configuration and current state.
|
||||
const Map& map(config->mapValue());
|
||||
const std::vector<isc::dns::RRClass>
|
||||
activeVector(server_->getClientListClasses());
|
||||
activeVector(server.getClientListClasses());
|
||||
std::set<isc::dns::RRClass> active(activeVector.begin(),
|
||||
activeVector.end());
|
||||
// Go through the configuration and change everything.
|
||||
for (Map::const_iterator it(map.begin()); it != map.end(); ++it) {
|
||||
isc::dns::RRClass rrclass(it->first);
|
||||
active.erase(rrclass);
|
||||
ListPtr list(server_->getClientList(rrclass));
|
||||
ListPtr list(server.getClientList(rrclass));
|
||||
bool need_set(false);
|
||||
if (list) {
|
||||
rollback_configurations.
|
||||
@@ -127,7 +86,7 @@ public:
|
||||
}
|
||||
list->configure(it->second, true);
|
||||
if (need_set) {
|
||||
server_->setClientList(rrclass, list);
|
||||
server.setClientList(rrclass, list);
|
||||
}
|
||||
}
|
||||
// Remove the ones that are not in the configuration.
|
||||
@@ -137,20 +96,20 @@ public:
|
||||
// But this is just to make sure in case it did to restore
|
||||
// the original.
|
||||
rollback_sets.push_back(
|
||||
RollbackPair(*it, server_->getClientList(*it)));
|
||||
server_->setClientList(*it, ListPtr());
|
||||
RollbackPair(*it, server.getClientList(*it)));
|
||||
server.setClientList(*it, ListPtr());
|
||||
}
|
||||
} catch (...) {
|
||||
// Perform a rollback of the changes. The old configuration should
|
||||
// work.
|
||||
for (typename std::vector<RollbackPair>::const_iterator
|
||||
it(rollback_sets.begin()); it != rollback_sets.end(); ++it) {
|
||||
server_->setClientList(it->first, it->second);
|
||||
server.setClientList(it->first, it->second);
|
||||
}
|
||||
for (typename std::vector<RollbackConfiguration>::const_iterator
|
||||
it(rollback_configurations.begin());
|
||||
it != rollback_configurations.end(); ++it) {
|
||||
server_->getClientList(it->first)->configure(it->second, true);
|
||||
server.getClientList(it->first)->configure(it->second, true);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ namespace {
|
||||
/* need global var for config/command handlers.
|
||||
* todo: turn this around, and put handlers in the authserver
|
||||
* class itself? */
|
||||
AuthSrv *auth_server;
|
||||
AuthSrv* auth_server;
|
||||
|
||||
ConstElementPtr
|
||||
my_config_handler(ConstElementPtr new_config) {
|
||||
@@ -87,12 +87,13 @@ my_command_handler(const string& command, ConstElementPtr args) {
|
||||
}
|
||||
|
||||
void
|
||||
datasrcConfigHandler(DataSourceConfigurator* configurator, const std::string&,
|
||||
isc::data::ConstElementPtr config,
|
||||
datasrcConfigHandler(AuthSrv* server, DataSourceConfigurator* configurator,
|
||||
const std::string&, isc::data::ConstElementPtr config,
|
||||
const isc::config::ConfigData&)
|
||||
{
|
||||
assert(server != NULL);
|
||||
if (config->contains("classes")) {
|
||||
configurator->reconfigure(config->get("classes"));
|
||||
configurator->reconfigure(*server, config->get("classes"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,9 +207,10 @@ main(int argc, char* argv[]) {
|
||||
auth_server->setTSIGKeyRing(&isc::server_common::keyring);
|
||||
|
||||
// Start the data source configuration
|
||||
datasrc_configurator.reset(new DataSourceConfigurator(auth_server));
|
||||
datasrc_configurator.reset(new DataSourceConfigurator);
|
||||
config_session->addRemoteConfig("data_sources",
|
||||
boost::bind(datasrcConfigHandler,
|
||||
auth_server,
|
||||
datasrc_configurator.get(),
|
||||
_1, _2, _3),
|
||||
false);
|
||||
@@ -217,6 +219,7 @@ main(int argc, char* argv[]) {
|
||||
// get the default (or, current value). Further updates will work
|
||||
// the usual way.
|
||||
datasrc_configurator->reconfigure(
|
||||
*auth_server,
|
||||
config_session->getRemoteConfigValue("data_sources", "classes"));
|
||||
|
||||
// Now start asynchronous read.
|
||||
|
@@ -98,8 +98,7 @@ protected:
|
||||
// The empty string is expected value of the parameter of
|
||||
// requestSocket, not the app_name (there's no fallback, it checks
|
||||
// the empty string is passed).
|
||||
sock_requestor_(dnss_, address_store_, 53210, ""),
|
||||
datasrc_configurator_(&server)
|
||||
sock_requestor_(dnss_, address_store_, 53210, "")
|
||||
{
|
||||
server.setDNSService(dnss_);
|
||||
server.setXfrinSession(¬ify_session);
|
||||
@@ -724,7 +723,7 @@ TEST_F(AuthSrvTest, notifyWithSessionMessageError) {
|
||||
}
|
||||
|
||||
void
|
||||
updateDatabase(DataSourceConfigurator& datasrc_configurator,
|
||||
updateDatabase(AuthSrv& server, DataSourceConfigurator& datasrc_configurator,
|
||||
const char* params)
|
||||
{
|
||||
const ConstElementPtr config(Element::fromJSON("{"
|
||||
@@ -732,11 +731,11 @@ updateDatabase(DataSourceConfigurator& datasrc_configurator,
|
||||
" \"type\": \"sqlite3\","
|
||||
" \"params\": " + string(params) +
|
||||
"}]}"));
|
||||
datasrc_configurator.reconfigure(config);
|
||||
datasrc_configurator.reconfigure(server, config);
|
||||
}
|
||||
|
||||
void
|
||||
updateInMemory(DataSourceConfigurator& datasrc_configurator,
|
||||
updateInMemory(AuthSrv& server, DataSourceConfigurator& datasrc_configurator,
|
||||
const char* origin, const char* filename)
|
||||
{
|
||||
const ConstElementPtr config(Element::fromJSON("{"
|
||||
@@ -751,17 +750,17 @@ updateInMemory(DataSourceConfigurator& datasrc_configurator,
|
||||
" \"type\": \"static\","
|
||||
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
|
||||
"}]}"));
|
||||
datasrc_configurator.reconfigure(config);
|
||||
datasrc_configurator.reconfigure(server, config);
|
||||
}
|
||||
|
||||
void
|
||||
updateBuiltin(DataSourceConfigurator& datasrc_configurator) {
|
||||
updateBuiltin(AuthSrv& server, DataSourceConfigurator& datasrc_configurator) {
|
||||
const ConstElementPtr config(Element::fromJSON("{"
|
||||
"\"CH\": [{"
|
||||
" \"type\": \"static\","
|
||||
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
|
||||
"}]}"));
|
||||
datasrc_configurator.reconfigure(config);
|
||||
datasrc_configurator.reconfigure(server, config);
|
||||
}
|
||||
|
||||
// Try giving the server a TSIG signed request and see it can anwer signed as
|
||||
@@ -772,7 +771,7 @@ TEST_F(AuthSrvTest, DISABLED_TSIGSigned) { // Needs builtin
|
||||
TEST_F(AuthSrvTest, TSIGSigned) {
|
||||
#endif
|
||||
// Prepare key, the client message, etc
|
||||
updateBuiltin(datasrc_configurator_);
|
||||
updateBuiltin(server, datasrc_configurator_);
|
||||
const TSIGKey key("key:c2VjcmV0Cg==:hmac-sha1");
|
||||
TSIGContext context(key);
|
||||
UnitTestUtil::createRequestMessage(request_message, opcode, default_qid,
|
||||
@@ -820,7 +819,7 @@ TEST_F(AuthSrvTest, DISABLED_builtInQueryViaDNSServer) {
|
||||
#else
|
||||
TEST_F(AuthSrvTest, builtInQueryViaDNSServer) {
|
||||
#endif
|
||||
updateBuiltin(datasrc_configurator_);
|
||||
updateBuiltin(server, datasrc_configurator_);
|
||||
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
|
||||
default_qid, Name("VERSION.BIND."),
|
||||
RRClass::CH(), RRType::TXT());
|
||||
@@ -852,7 +851,7 @@ TEST_F(AuthSrvTest, DISABLED_builtInQuery) {
|
||||
#else
|
||||
TEST_F(AuthSrvTest, builtInQuery) {
|
||||
#endif
|
||||
updateBuiltin(datasrc_configurator_);
|
||||
updateBuiltin(server, datasrc_configurator_);
|
||||
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
|
||||
default_qid, Name("VERSION.BIND."),
|
||||
RRClass::CH(), RRType::TXT());
|
||||
@@ -873,7 +872,7 @@ TEST_F(AuthSrvTest, DISABLED_iqueryViaDNSServer) { // Needs builtin
|
||||
#else
|
||||
TEST_F(AuthSrvTest, iqueryViaDNSServer) { // Needs builtin
|
||||
#endif
|
||||
updateBuiltin(datasrc_configurator_);
|
||||
updateBuiltin(server, datasrc_configurator_);
|
||||
createDataFromFile("iquery_fromWire.wire");
|
||||
(*server.getDNSLookupProvider())(*io_message, parse_message,
|
||||
response_message,
|
||||
@@ -895,7 +894,7 @@ TEST_F(AuthSrvTest, DISABLED_updateConfig) {
|
||||
#else
|
||||
TEST_F(AuthSrvTest, updateConfig) {
|
||||
#endif
|
||||
updateDatabase(datasrc_configurator_, CONFIG_TESTDB);
|
||||
updateDatabase(server, datasrc_configurator_, CONFIG_TESTDB);
|
||||
|
||||
// query for existent data in the installed data source. The resulting
|
||||
// response should have the AA flag on, and have an RR in each answer
|
||||
@@ -913,7 +912,7 @@ TEST_F(AuthSrvTest, DISABLED_datasourceFail) {
|
||||
#else
|
||||
TEST_F(AuthSrvTest, datasourceFail) {
|
||||
#endif
|
||||
updateDatabase(datasrc_configurator_, CONFIG_TESTDB);
|
||||
updateDatabase(server, datasrc_configurator_, CONFIG_TESTDB);
|
||||
|
||||
// This query will hit a corrupted entry of the data source (the zoneload
|
||||
// tool and the data source itself naively accept it). This will result
|
||||
@@ -933,10 +932,11 @@ TEST_F(AuthSrvTest, DISABLED_updateConfigFail) {
|
||||
TEST_F(AuthSrvTest, updateConfigFail) {
|
||||
#endif
|
||||
// First, load a valid data source.
|
||||
updateDatabase(datasrc_configurator_, CONFIG_TESTDB);
|
||||
updateDatabase(server, datasrc_configurator_, CONFIG_TESTDB);
|
||||
|
||||
// Next, try to update it with a non-existent one. This should fail.
|
||||
EXPECT_THROW(updateDatabase(datasrc_configurator_, BADCONFIG_TESTDB),
|
||||
EXPECT_THROW(updateDatabase(server, datasrc_configurator_,
|
||||
BADCONFIG_TESTDB),
|
||||
isc::datasrc::DataSourceError);
|
||||
|
||||
// The original data source should still exist.
|
||||
@@ -959,7 +959,7 @@ TEST_F(AuthSrvTest, updateWithInMemoryClient) {
|
||||
" \"params\": {},"
|
||||
" \"cache-enable\": true"
|
||||
"}]}"));
|
||||
datasrc_configurator_.reconfigure(config);
|
||||
datasrc_configurator_.reconfigure(server, config);
|
||||
// after successful configuration, we should have one (with empty zoneset).
|
||||
|
||||
// The memory data source is empty, should return REFUSED rcode.
|
||||
@@ -980,7 +980,8 @@ TEST_F(AuthSrvTest, queryWithInMemoryClientNoDNSSEC) {
|
||||
// query handler class, and confirm it returns no error and a non empty
|
||||
// answer section. Detailed examination on the response content
|
||||
// for various types of queries are tested in the query tests.
|
||||
updateInMemory(datasrc_configurator_, "example.", CONFIG_INMEMORY_EXAMPLE);
|
||||
updateInMemory(server, datasrc_configurator_, "example.",
|
||||
CONFIG_INMEMORY_EXAMPLE);
|
||||
|
||||
createDataFromFile("nsec3query_nodnssec_fromWire.wire");
|
||||
server.processMessage(*io_message, *parse_message, *response_obuffer,
|
||||
@@ -999,7 +1000,8 @@ TEST_F(AuthSrvTest, queryWithInMemoryClientDNSSEC) {
|
||||
// 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.
|
||||
updateInMemory(datasrc_configurator_, "example.", CONFIG_INMEMORY_EXAMPLE);
|
||||
updateInMemory(server, datasrc_configurator_, "example.",
|
||||
CONFIG_INMEMORY_EXAMPLE);
|
||||
|
||||
createDataFromFile("nsec3query_fromWire.wire");
|
||||
server.processMessage(*io_message, *parse_message, *response_obuffer,
|
||||
@@ -1019,7 +1021,8 @@ TEST_F(AuthSrvTest,
|
||||
)
|
||||
{
|
||||
// Set up the in-memory
|
||||
updateInMemory(datasrc_configurator_, "example.", CONFIG_INMEMORY_EXAMPLE);
|
||||
updateInMemory(server, datasrc_configurator_, "example.",
|
||||
CONFIG_INMEMORY_EXAMPLE);
|
||||
|
||||
// This shouldn't affect the result of class CH query
|
||||
UnitTestUtil::createRequestMessage(request_message, Opcode::QUERY(),
|
||||
@@ -1431,7 +1434,8 @@ TEST_F(AuthSrvTest,
|
||||
)
|
||||
{
|
||||
// Set real inmem client to proxy
|
||||
updateInMemory(datasrc_configurator_, "example.", CONFIG_INMEMORY_EXAMPLE);
|
||||
updateInMemory(server, datasrc_configurator_, "example.",
|
||||
CONFIG_INMEMORY_EXAMPLE);
|
||||
{
|
||||
isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
|
||||
boost::shared_ptr<isc::datasrc::ConfigurableClientList>
|
||||
@@ -1456,17 +1460,18 @@ TEST_F(AuthSrvTest,
|
||||
// If non null rrset is given, it will be passed to the proxy so it can
|
||||
// return some faked response.
|
||||
void
|
||||
setupThrow(AuthSrv* server, DataSourceConfigurator& datasrc_configurator,
|
||||
setupThrow(AuthSrv& server, DataSourceConfigurator& datasrc_configurator,
|
||||
ThrowWhen throw_when, bool isc_exception,
|
||||
ConstRRsetPtr rrset = ConstRRsetPtr())
|
||||
{
|
||||
updateInMemory(datasrc_configurator, "example.", CONFIG_INMEMORY_EXAMPLE);
|
||||
updateInMemory(server, datasrc_configurator, "example.",
|
||||
CONFIG_INMEMORY_EXAMPLE);
|
||||
|
||||
isc::util::thread::Mutex::Locker locker(server->getClientListMutex());
|
||||
isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
|
||||
boost::shared_ptr<isc::datasrc::ConfigurableClientList>
|
||||
list(new FakeList(server->getClientList(RRClass::IN()), throw_when,
|
||||
list(new FakeList(server.getClientList(RRClass::IN()), throw_when,
|
||||
isc_exception, rrset));
|
||||
server->setClientList(RRClass::IN(), list);
|
||||
server.setClientList(RRClass::IN(), list);
|
||||
}
|
||||
|
||||
TEST_F(AuthSrvTest,
|
||||
@@ -1489,11 +1494,11 @@ TEST_F(AuthSrvTest,
|
||||
RRClass::IN(), RRType::TXT());
|
||||
for (ThrowWhen* when(throws); *when != THROW_NEVER; ++when) {
|
||||
createRequestPacket(request_message, IPPROTO_UDP);
|
||||
setupThrow(&server, datasrc_configurator_, *when, true);
|
||||
setupThrow(server, datasrc_configurator_, *when, true);
|
||||
processAndCheckSERVFAIL();
|
||||
// To be sure, check same for non-isc-exceptions
|
||||
createRequestPacket(request_message, IPPROTO_UDP);
|
||||
setupThrow(&server, datasrc_configurator_, *when, false);
|
||||
setupThrow(server, datasrc_configurator_, *when, false);
|
||||
processAndCheckSERVFAIL();
|
||||
}
|
||||
}
|
||||
@@ -1509,7 +1514,7 @@ TEST_F(AuthSrvTest,
|
||||
)
|
||||
{
|
||||
createDataFromFile("nsec3query_nodnssec_fromWire.wire");
|
||||
setupThrow(&server, datasrc_configurator_, THROW_AT_GET_CLASS, true);
|
||||
setupThrow(server, datasrc_configurator_, THROW_AT_GET_CLASS, true);
|
||||
|
||||
// getClass is not called so it should just answer
|
||||
server.processMessage(*io_message, *parse_message, *response_obuffer,
|
||||
@@ -1533,7 +1538,7 @@ TEST_F(AuthSrvTest,
|
||||
ConstRRsetPtr empty_rrset(new RRset(Name("foo.example"),
|
||||
RRClass::IN(), RRType::TXT(),
|
||||
RRTTL(0)));
|
||||
setupThrow(&server, datasrc_configurator_, THROW_NEVER, true, empty_rrset);
|
||||
setupThrow(server, datasrc_configurator_, THROW_NEVER, true, empty_rrset);
|
||||
|
||||
// Repeat the query processing two times. Due to the faked RRset,
|
||||
// toWire() should throw, and it should result in SERVFAIL.
|
||||
|
@@ -64,7 +64,6 @@ class AuthCommandTest : public ::testing::Test {
|
||||
protected:
|
||||
AuthCommandTest() :
|
||||
server_(xfrout_, ddns_forwarder_),
|
||||
datasrc_configurator_(&server_),
|
||||
rcode_(-1),
|
||||
expect_rcode_(0),
|
||||
itimer_(server_.getIOService())
|
||||
@@ -210,7 +209,7 @@ configureZones(AuthSrv& server, DataSourceConfigurator& datasrc_configurator) {
|
||||
" \"cache-enable\": true"
|
||||
"}]}"));
|
||||
|
||||
datasrc_configurator.reconfigure(config);
|
||||
datasrc_configurator.reconfigure(server, config);
|
||||
|
||||
zoneChecks(server);
|
||||
}
|
||||
@@ -273,7 +272,7 @@ TEST_F(AuthCommandTest,
|
||||
" \"cache-enable\": true,"
|
||||
" \"cache-zones\": [\"example.org\"]"
|
||||
"}]}"));
|
||||
datasrc_configurator_.reconfigure(config);
|
||||
datasrc_configurator_.reconfigure(server_, config);
|
||||
|
||||
{
|
||||
isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
|
||||
@@ -337,7 +336,7 @@ TEST_F(AuthCommandTest,
|
||||
" \"cache-enable\": true,"
|
||||
" \"cache-zones\": [\"example.com\"]"
|
||||
"}]}"));
|
||||
EXPECT_THROW(datasrc_configurator_.reconfigure(config2),
|
||||
EXPECT_THROW(datasrc_configurator_.reconfigure(server_, config2),
|
||||
ConfigurableClientList::ConfigurationError);
|
||||
|
||||
result_ = execAuthServerCommand(server_, "loadzone",
|
||||
|
@@ -66,12 +66,13 @@ typedef DataSourceConfiguratorGeneric<DatasrcConfiguratorTest,
|
||||
FakeList> Configurator;
|
||||
|
||||
void
|
||||
datasrcConfigHandler(Configurator* configurator, const std::string&,
|
||||
datasrcConfigHandler(DatasrcConfiguratorTest* fake_server,
|
||||
Configurator* configurator, const std::string&,
|
||||
isc::data::ConstElementPtr config,
|
||||
const isc::config::ConfigData&)
|
||||
{
|
||||
if (config->contains("classes")) {
|
||||
configurator->reconfigure(config->get("classes"));
|
||||
configurator->reconfigure(*fake_server, config->get("classes"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +103,6 @@ protected:
|
||||
DatasrcConfiguratorTest() :
|
||||
session(ElementPtr(new ListElement), ElementPtr(new ListElement),
|
||||
ElementPtr(new ListElement)),
|
||||
configurator_(this),
|
||||
specfile(string(TEST_OWN_DATA_DIR) + "/spec.spec")
|
||||
{
|
||||
initSession();
|
||||
@@ -129,7 +129,8 @@ protected:
|
||||
add(createAnswer(0, ElementPtr(new MapElement)));
|
||||
}
|
||||
mccs->addRemoteConfig("data_sources",
|
||||
boost::bind(datasrcConfigHandler, &configurator_,
|
||||
boost::bind(datasrcConfigHandler,
|
||||
this, &configurator_,
|
||||
_1, _2, _3), false);
|
||||
}
|
||||
void SetUp() {
|
||||
@@ -168,10 +169,11 @@ TEST_F(DatasrcConfiguratorTest, DISABLED_initialization) {
|
||||
EXPECT_TRUE(session.haveSubscription("data_sources", "*"));
|
||||
EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
|
||||
// We can't reconfigure now (not even manually)
|
||||
EXPECT_THROW(configurator_.reconfigure(ElementPtr(new MapElement())),
|
||||
EXPECT_THROW(configurator_.reconfigure(*this,
|
||||
ElementPtr(new MapElement())),
|
||||
InvalidOperation);
|
||||
// If the server param is NULL, it does not work
|
||||
EXPECT_THROW(Configurator(NULL), InvalidParameter);
|
||||
EXPECT_THROW(Configurator configurator, InvalidParameter);
|
||||
EXPECT_FALSE(session.haveSubscription("data_sources", "*")); // TBD
|
||||
// But we can initialize it again now
|
||||
EXPECT_NO_THROW(init());
|
||||
@@ -281,7 +283,7 @@ TEST_F(DatasrcConfiguratorTest, rollbackDeletion) {
|
||||
const ElementPtr
|
||||
config1(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}], "
|
||||
"\"CH\": [{\"type\": \"xxx\"}]}"));
|
||||
configurator_.reconfigure(config1);
|
||||
configurator_.reconfigure(*this, config1);
|
||||
const ElementPtr
|
||||
config2(Element::fromJSON("{\"IN\": [{\"type\": 13}]}"));
|
||||
// This would delete CH. However, the IN one fails.
|
||||
@@ -289,7 +291,7 @@ TEST_F(DatasrcConfiguratorTest, rollbackDeletion) {
|
||||
// and there's no known way to cause an exception during the
|
||||
// deletions, it is not a true rollback, but the result should
|
||||
// be the same.
|
||||
EXPECT_THROW(configurator_.reconfigure(config2), TypeError);
|
||||
EXPECT_THROW(configurator_.reconfigure(*this, config2), TypeError);
|
||||
EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
|
||||
EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf());
|
||||
}
|
||||
@@ -302,13 +304,13 @@ TEST_F(DatasrcConfiguratorTest, rollbackConfiguration) {
|
||||
const ElementPtr
|
||||
config1(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}], "
|
||||
"\"CH\": [{\"type\": \"xxx\"}]}"));
|
||||
configurator_.reconfigure(config1);
|
||||
configurator_.reconfigure(*this, config1);
|
||||
// Now, the CH happens first. But nevertheless, it should be
|
||||
// restored to the previoeus version.
|
||||
const ElementPtr
|
||||
config2(Element::fromJSON("{\"IN\": [{\"type\": 13}], "
|
||||
"\"CH\": [{\"type\": \"yyy\"}]}"));
|
||||
EXPECT_THROW(configurator_.reconfigure(config2), TypeError);
|
||||
EXPECT_THROW(configurator_.reconfigure(*this, config2), TypeError);
|
||||
EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
|
||||
EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf());
|
||||
}
|
||||
|
Reference in New Issue
Block a user