2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#3710] use library index as manager id

This commit is contained in:
Razvan Becheriu
2025-03-02 14:07:55 +02:00
parent e312a1de4a
commit 68a70d27f4
19 changed files with 324 additions and 501 deletions

View File

@@ -932,6 +932,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
// Log the list of known backends.
BackendStoreFactory::logRegistered();
// Log the list of known backends.
ConfigBackendDHCPv4Mgr::instance().logRegistered();
// Moved from the commit block to add the config backend indication.
if (status_code == CONTROL_RESULT_SUCCESS && (!check_only || extra_checks)) {
try {

View File

@@ -1067,6 +1067,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
// Log the list of known backends.
BackendStoreFactory::logRegistered();
// Log the list of known backends.
ConfigBackendDHCPv6Mgr::instance().logRegistered();
// Moved from the commit block to add the config backend indication.
if (status_code == CONTROL_RESULT_SUCCESS && (!check_only || extra_checks)) {
try {

View File

@@ -19,7 +19,6 @@
#include <util/str.h>
#include <legal_log_log.h>
#include <dhcpsrv/backend_store_factory.h>
#include <rotating_file.h>
#include <subnets_user_context.h>
#include <sstream>
@@ -112,15 +111,16 @@ bool isPrefix(ConstElementPtr arguments) {
/// generate the duration text using @ref
/// isc::legal_log::BackendStore::genDurationString().
///
/// @param handle CalloutHandle which provides access to context.
/// @param os output stream to which the text is output
/// @param arguments element scope which may contain duration values
void addDuration(ostringstream& os, ConstElementPtr& arguments) {
void addDuration(CalloutHandle& handle, ostringstream& os, ConstElementPtr& arguments) {
int64_t duration = 0;
if (!getOptionalInt(arguments, "valid-lft", duration)) {
int64_t expire = 0;
if (getOptionalInt(arguments, "expire", expire)) {
duration = expire - BackendStoreFactory::instance(managerID())->now().tv_sec;
duration = expire - BackendStoreFactory::instance(handle.getCurrentLibrary())->now().tv_sec;
}
}
@@ -186,9 +186,9 @@ bool checkLoggingEnabledSubnet4(ConstElementPtr& arguments) {
/// @param name The command name.
/// @param arguments The command arguments.
/// @param response The command response.
int handleLease4Cmds(string& name, ConstElementPtr& arguments,
int handleLease4Cmds(CalloutHandle& handle, string& name, ConstElementPtr& arguments,
ConstElementPtr& /*response*/) {
if (!BackendStoreFactory::instance(managerID())) {
if (!BackendStoreFactory::instance(handle.getCurrentLibrary())) {
LOG_ERROR(legal_log_logger,
LEGAL_LOG_COMMAND_NO_LEGAL_STORE);
return (1);
@@ -231,7 +231,7 @@ int handleLease4Cmds(string& name, ConstElementPtr& arguments,
}
}
addDuration(os, arguments);
addDuration(handle, os, arguments);
addContext(os, arguments);
} else if (name == "lease4-del") {
string ip_address;
@@ -246,7 +246,7 @@ int handleLease4Cmds(string& name, ConstElementPtr& arguments,
}
}
BackendStoreFactory::instance(managerID())->writeln(os.str(), osa.str());
BackendStoreFactory::instance(handle.getCurrentLibrary())->writeln(os.str(), osa.str());
} catch (const exception& ex) {
LOG_ERROR(legal_log_logger, LEGAL_LOG_COMMAND_WRITE_ERROR)
.arg(ex.what());
@@ -283,12 +283,13 @@ bool checkLoggingEnabledSubnet6(ConstElementPtr& arguments) {
/// @brief Handle lease6 related commands.
///
/// @param handle CalloutHandle which provides access to context.
/// @param name The command name.
/// @param arguments The command arguments.
/// @param response The command response.
int handleLease6Cmds(string& name, ConstElementPtr& arguments,
int handleLease6Cmds(CalloutHandle& handle, string& name, ConstElementPtr& arguments,
ConstElementPtr& response) {
if (!BackendStoreFactory::instance(managerID())) {
if (!BackendStoreFactory::instance(handle.getCurrentLibrary())) {
LOG_ERROR(legal_log_logger,
LEGAL_LOG_COMMAND_NO_LEGAL_STORE);
return (1);
@@ -334,7 +335,7 @@ int handleLease6Cmds(string& name, ConstElementPtr& arguments,
os << ", hardware address: " << hw_address;
}
addDuration(os, arguments);
addDuration(handle, os, arguments);
addContext(os, arguments);
} else if (name == "lease6-del") {
string ip_address;
@@ -410,7 +411,7 @@ int handleLease6Cmds(string& name, ConstElementPtr& arguments,
ConstElementPtr args(copy);
ConstElementPtr resp;
string cmd_name("lease6-del");
int result = handleLease6Cmds(cmd_name, args, resp);
int result = handleLease6Cmds(handle, cmd_name, args, resp);
if (result) {
status = result;
}
@@ -448,7 +449,7 @@ int handleLease6Cmds(string& name, ConstElementPtr& arguments,
ConstElementPtr args(copy);
ConstElementPtr resp;
string cmd_name("lease6-update");
int result = handleLease6Cmds(cmd_name, args, resp);
int result = handleLease6Cmds(handle, cmd_name, args, resp);
if (result) {
status = result;
}
@@ -458,7 +459,7 @@ int handleLease6Cmds(string& name, ConstElementPtr& arguments,
return (status);
}
BackendStoreFactory::instance(managerID())->writeln(os.str(), osa.str());
BackendStoreFactory::instance(handle.getCurrentLibrary())->writeln(os.str(), osa.str());
} catch (const exception& ex) {
LOG_ERROR(legal_log_logger, LEGAL_LOG_COMMAND_WRITE_ERROR)
.arg(ex.what());
@@ -482,7 +483,7 @@ int handleLease6Cmds(string& name, ConstElementPtr& arguments,
///
/// @return 0 upon success, non-zero otherwise.
int command_processed(CalloutHandle& handle) {
if (!BackendStoreFactory::instance(managerID())) {
if (!BackendStoreFactory::instance(handle.getCurrentLibrary())) {
LOG_ERROR(legal_log_logger,
LEGAL_LOG_COMMAND_NO_LEGAL_STORE);
return (1);
@@ -515,9 +516,9 @@ int command_processed(CalloutHandle& handle) {
// in v4 or v6 universe. The easiest way to check the universe is by the
// command name.
if (name.find("lease4-") != string::npos) {
return (handleLease4Cmds(name, arguments, response));
return (handleLease4Cmds(handle, name, arguments, response));
} else if (name.find("lease6-") != string::npos) {
return (handleLease6Cmds(name, arguments, response));
return (handleLease6Cmds(handle, name, arguments, response));
}
} catch (const exception& ex) {

View File

@@ -16,7 +16,6 @@
#include <util/str.h>
#include <legal_log_log.h>
#include <dhcpsrv/backend_store_factory.h>
#include <rotating_file.h>
#include <subnets_user_context.h>
#include <sstream>
@@ -31,21 +30,22 @@ using namespace std;
/// @brief Create custom log entry for the current lease.
///
/// @param handle CalloutHandle which provides access to context.
/// @param query The query received by the server.
/// @param response The response of the server.
/// @param lease The current lease generating this log entry.
/// @param [out] value The value of the custom log entry after parser execution.
bool getCustomEntry(const Pkt4Ptr& query, const Pkt4Ptr& response,
bool getCustomEntry(CalloutHandle& handle, const Pkt4Ptr& query, const Pkt4Ptr& response,
const Lease4Ptr& /*lease*/, std::string& value) {
bool using_custom_format = false;
auto expression = BackendStoreFactory::instance(managerID())->getRequestFormatExpression();
auto expression = BackendStoreFactory::instance(handle.getCurrentLibrary())->getRequestFormatExpression();
if (expression && query) {
value = evaluateString(*expression, *query);
using_custom_format = true;
}
expression = BackendStoreFactory::instance(managerID())->getResponseFormatExpression();
expression = BackendStoreFactory::instance(handle.getCurrentLibrary())->getResponseFormatExpression();
if (expression && response) {
value += evaluateString(*expression, *response);
using_custom_format = true;
@@ -87,16 +87,18 @@ bool getCustomEntry(const Pkt4Ptr& query, const Pkt4Ptr& response,
/// circuit-id: 68:6f:77:64:79 (howdy) and remote-id: 87:f6:79:77:ef"
/// @endcode
///
/// @param handle CalloutHandle which provides access to context.
/// @param query DHCPv4 query packet for which the lease was generated
/// @param response DHCPv4 response packet
/// @param lease DHCPv4 lease for which the entry should be created
/// @param action Kind of event to log.
std::string genLease4Entry(const Pkt4Ptr& query,
std::string genLease4Entry(CalloutHandle& handle,
const Pkt4Ptr& query,
const Pkt4Ptr& response,
const Lease4Ptr& lease,
const Action& action) {
std::string value;
if (getCustomEntry(query, response, lease, value)) {
if (getCustomEntry(handle, query, response, lease, value)) {
return (value);
}
@@ -215,7 +217,7 @@ std::string genLease4Entry(const Pkt4Ptr& query,
///
/// @return returns 0 upon success, non-zero otherwise
int legalLog4Handler(CalloutHandle& handle, const Action& action) {
if (!BackendStoreFactory::instance(managerID())) {
if (!BackendStoreFactory::instance(handle.getCurrentLibrary())) {
LOG_ERROR(legal_log_logger,
LEGAL_LOG_LEASE4_NO_LEGAL_STORE);
return (1);
@@ -240,9 +242,9 @@ int legalLog4Handler(CalloutHandle& handle, const Action& action) {
ConstSubnet4Ptr subnet = cfg->getBySubnetId(lease->subnet_id_);
if (!isLoggingDisabled(subnet)) {
BackendStoreFactory::instance(managerID())->writeln(genLease4Entry(query, response,
lease, action),
lease->addr_.toText());
BackendStoreFactory::instance(handle.getCurrentLibrary())->writeln(genLease4Entry(handle, query, response,
lease, action),
lease->addr_.toText());
}
} catch (const std::exception& ex) {

View File

@@ -21,7 +21,6 @@
#include <util/str.h>
#include <legal_log_log.h>
#include <dhcpsrv/backend_store_factory.h>
#include <rotating_file.h>
#include <subnets_user_context.h>
#include <sstream>
@@ -481,11 +480,11 @@ void replaceTokensForLease(isc::dhcp::ExpressionPtr& expression,
/// @param response The response of the server.
/// @param lease The current lease generating this log entry.
/// @param [out] value The value of the custom log entry after parser execution.
bool getCustomEntry(const Pkt6Ptr& query, const Pkt6Ptr& response,
bool getCustomEntry(CalloutHandle& handle, const Pkt6Ptr& query, const Pkt6Ptr& response,
const Lease6Ptr& lease, std::string& value) {
bool using_custom_format = false;
auto expression = BackendStoreFactory::instance(managerID())->getRequestFormatExpression();
auto expression = BackendStoreFactory::instance(handle.getCurrentLibrary())->getRequestFormatExpression();
if (expression && query) {
replaceTokensForLease(expression, lease);
@@ -493,7 +492,7 @@ bool getCustomEntry(const Pkt6Ptr& query, const Pkt6Ptr& response,
using_custom_format = true;
}
expression = BackendStoreFactory::instance(managerID())->getResponseFormatExpression();
expression = BackendStoreFactory::instance(handle.getCurrentLibrary())->getResponseFormatExpression();
if (expression && response) {
replaceTokensForLease(expression, lease);
@@ -536,16 +535,18 @@ bool getCustomEntry(const Pkt6Ptr& query, const Pkt6Ptr& response,
/// and subscriber-id: 1a:2b:3c:4d:5e:6f"
/// @endcode
///
/// @param handle CalloutHandle which provides access to context.
/// @param query DHCPv6 query packet for which the lease was generated
/// @param response DHCPv6 response packet
/// @param lease DHCPv6 lease for which the entry should be created
/// @param action Kind of event to log.
std::string genLease6Entry(const Pkt6Ptr& query,
std::string genLease6Entry(CalloutHandle& handle,
const Pkt6Ptr& query,
const Pkt6Ptr& response,
const Lease6Ptr& lease,
const Action& action) {
std::string value;
if (getCustomEntry(query, response, lease, value)) {
if (getCustomEntry(handle, query, response, lease, value)) {
return (value);
}
@@ -670,7 +671,7 @@ std::string genLease6Entry(const Pkt6Ptr& query,
///
/// @return returns 0 upon success, non-zero otherwise
int legalLog6Handler(CalloutHandle& handle, const Action& action) {
if (!BackendStoreFactory::instance(managerID())) {
if (!BackendStoreFactory::instance(handle.getCurrentLibrary())) {
LOG_ERROR(legal_log_logger, LEGAL_LOG_LEASE6_NO_LEGAL_STORE);
return (1);
}
@@ -694,9 +695,9 @@ int legalLog6Handler(CalloutHandle& handle, const Action& action) {
ConstSubnet6Ptr subnet = cfg->getBySubnetId(lease->subnet_id_);
if (!isLoggingDisabled(subnet)) {
BackendStoreFactory::instance(managerID())->writeln(genLease6Entry(query, response,
lease, action),
genLease6Addr(lease));
BackendStoreFactory::instance(handle.getCurrentLibrary())->writeln(genLease6Entry(handle, query, response,
lease, action),
genLease6Addr(lease));
}
} catch (const std::exception& ex) {

View File

@@ -70,7 +70,7 @@ int load(LibraryHandle& handle) {
try {
BackendStore::parseConfig(parameters, map);
BackendStoreFactory::addBackend(map, managerID());
BackendStoreFactory::addBackend(map, handle.getLibraryIndex());
} catch (const isc::db::DbOpenErrorWithRetry& err) {
string redacted;
try {
@@ -102,7 +102,7 @@ int unload() {
// Since it's "global" Let's explicitly destroy it now rather
// than indeterminately. Note, BackendStore destructor will close
// the store.
BackendStoreFactory::instance(managerID()).reset();
BackendStoreFactory::delAllBackends();
BackendStoreFactory::unregisterBackendFactory("logfile");
} catch (const std::exception& ex) {

View File

@@ -30,16 +30,6 @@ using namespace std;
namespace isc {
namespace legal_log {
bool RotatingFile::test_mode_ = false;
isc::dhcp::ManagerID managerID() {
static boost::shared_ptr<void*> id = boost::shared_ptr<void*>(new void*);
if (RotatingFile::test_mode_) {
id.reset();
}
return (reinterpret_cast<isc::dhcp::ManagerID>(id.get()));
}
RotatingFile::RotatingFile(const DatabaseConnection::ParameterMap& parameters)
: BackendStore(parameters), time_unit_(TimeUnit::Day), count_(1), timestamp_(0) {
apply(parameters);

View File

@@ -275,29 +275,21 @@ public:
/// @return The Rotating File Store Backend.
static isc::dhcp::BackendStorePtr
factory(const isc::db::DatabaseConnection::ParameterMap& parameters);
/// @brief Test mode flag (default false).
static bool test_mode_;
};
/// @brief Initialization structure used to register and deregister RotateFile Forensic Store.
struct RotatingFileInit {
// Constructor registers
RotatingFileInit() {
RotatingFile::test_mode_ = true;
isc::dhcp::BackendStoreFactory::registerBackendFactory("logfile", RotatingFile::factory);
}
// Destructor deregisters
~RotatingFileInit() {
isc::dhcp::BackendStoreFactory::unregisterBackendFactory("logfile");
RotatingFile::test_mode_ = false;
}
};
/// @brief Return library unique ManagerID.
isc::dhcp::ManagerID managerID();
} // namespace legal_log
} // namespace isc

View File

@@ -42,7 +42,7 @@ extern bool getOptionalInt(ConstElementPtr& arguments, const string& name,
int64_t& value);
extern bool isPrefix(ConstElementPtr arguments);
extern int command_processed(CalloutHandle& handle);
extern void addDuration(ostringstream& os, ConstElementPtr& arguments);
extern void addDuration(CalloutHandle& handle, ostringstream& os, ConstElementPtr& arguments);
extern void addContext(ostringstream& os, ConstElementPtr& arguments);
}
@@ -611,13 +611,17 @@ TEST(CommandCalloutFuncs, isPrefixTest) {
// Exercises the addDuration() function
TEST_F(CalloutTest, addDurationTest) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
// Should generate duration text of 1 day based on valid-lft
ConstElementPtr arguments;
ASSERT_NO_THROW(arguments = Element::fromJSON("{ \"valid-lft\": 86400 }"));
ostringstream os;
ASSERT_NO_THROW(addDuration(os, arguments));
ASSERT_NO_THROW(addDuration(handle, os, arguments));
EXPECT_EQ(os.str(), " for 1 days 0 hrs 0 mins 0 secs");
// Clear the stream
@@ -625,7 +629,7 @@ TEST_F(CalloutTest, addDurationTest) {
// Should not generate duration text.
ASSERT_NO_THROW(arguments = Element::fromJSON("{ \"some-other\": 86400 }"));
ASSERT_NO_THROW(addDuration(os, arguments));
ASSERT_NO_THROW(addDuration(handle, os, arguments));
EXPECT_EQ(os.str(), "");
// Should have a duration of 2 days based on expire timestamp.
@@ -635,7 +639,7 @@ TEST_F(CalloutTest, addDurationTest) {
ASSERT_NO_THROW(arguments = Element::fromJSON(os.str()));
os.str("");
ASSERT_NO_THROW(addDuration(os, arguments));
ASSERT_NO_THROW(addDuration(handle, os, arguments));
EXPECT_EQ(os.str(), " for 2 days 0 hrs 0 mins 0 secs");
}
@@ -681,6 +685,7 @@ TEST_F(CalloutTest, validCommandEntries) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ConstElementPtr response = createAnswer(CONTROL_RESULT_SUCCESS, "it works!");
@@ -729,6 +734,7 @@ TEST_F(CalloutTest, responseWithErrorsLease6BulkApplyCommandEntries) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
vector<string>lines;
@@ -858,6 +864,7 @@ TEST_F(CalloutTest, disableLoggingForSubnet4) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ConstElementPtr response = createAnswer(CONTROL_RESULT_SUCCESS, "it works!");
@@ -933,6 +940,7 @@ TEST_F(CalloutTest, disableLoggingForSubnet6) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ConstElementPtr response = createAnswer(CONTROL_RESULT_SUCCESS, "it works!");
@@ -987,6 +995,7 @@ TEST_F(CalloutTest, failedCommand) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
// First we use a known good command and success to generate
// an entry (otherwise rotate file won't get created

View File

@@ -42,7 +42,8 @@ using namespace isc::dhcp;
using namespace hooks;
using namespace legal_log;
extern std::string genLease4Entry(const Pkt4Ptr& query,
extern std::string genLease4Entry(CalloutHandle& handle,
const Pkt4Ptr& query,
const Pkt4Ptr& response,
const Lease4Ptr& lease,
const Action& action);
@@ -317,33 +318,36 @@ struct CalloutTestv4 : CalloutTest {
// Verifies legal entry content for directly connected clients
TEST_F(CalloutTestv4, directClient4) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
// Verify address and duration for an assignment (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address and duration for a renewal (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a release (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(release_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, release_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a decline (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(decline_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, decline_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
@@ -352,7 +356,7 @@ TEST_F(CalloutTestv4, directClient4) {
// Verify with a client id
lease_->client_id_ = client_id_;
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54",
@@ -361,7 +365,7 @@ TEST_F(CalloutTestv4, directClient4) {
// Verify a relayed request (no RAI)
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -383,7 +387,7 @@ TEST_F(CalloutTestv4, directClient4) {
request_->addOption(rai);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -398,7 +402,7 @@ TEST_F(CalloutTestv4, directClient4) {
+ sizeof(subscriber_id))));
rai->addOption(subscriber_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -413,7 +417,7 @@ TEST_F(CalloutTestv4, directClient4) {
remote_id + sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -425,7 +429,7 @@ TEST_F(CalloutTestv4, directClient4) {
lease_->setContext(Element::fromJSON("{ \"foo\": true }"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -439,6 +443,9 @@ TEST_F(CalloutTestv4, directClient4) {
// Verifies legal entry content for directly connected clients
TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
BackendStoreFactory::instance()->setRequestFormatExpression(request_format_only_);
@@ -446,28 +453,28 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
std::string entry;
// Verify address and duration for an assignment (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address and duration for a renewal (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a release (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(release_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, release_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a decline (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(decline_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, decline_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
@@ -475,7 +482,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
// Verify address for a discover
response_->setType(DHCPOFFER);
ASSERT_NO_THROW(entry = genLease4Entry(discover_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, discover_, response_, lease_, Action::ASSIGN));
EXPECT_TRUE(entry.empty());
response_->setType(DHCPACK);
@@ -487,7 +494,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
request_->addOption(client_id_option);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54",
@@ -496,7 +503,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
// Verify a relayed request (no RAI)
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -518,7 +525,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
request_->addOption(rai);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -533,7 +540,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
+ sizeof(subscriber_id))));
rai->addOption(subscriber_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -548,7 +555,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
remote_id + sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -561,6 +568,9 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestOnly) {
// Verifies legal entry content for directly connected clients
TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
BackendStoreFactory::instance()->setRequestFormatExpression(request_format_);
@@ -569,28 +579,28 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
std::string entry;
// Verify address and duration for an assignment (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address and duration for a renewal (no client id)
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a release (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(release_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, release_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
entry);
// Verify address for a decline (no client id). No server response.
ASSERT_NO_THROW(entry = genLease4Entry(decline_, Pkt4Ptr(), lease_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease4Entry(handle, decline_, Pkt4Ptr(), lease_, Action::RELEASE));
EXPECT_EQ("Address: 192.2.1.100 has been released"
" from a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e",
@@ -598,7 +608,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
// Verify address for a discover
response_->setType(DHCPOFFER);
ASSERT_NO_THROW(entry = genLease4Entry(discover_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, discover_, response_, lease_, Action::ASSIGN));
EXPECT_TRUE(entry.empty());
response_->setType(DHCPACK);
@@ -611,7 +621,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
request_->addOption(client_id_option);
response_->addOption(client_id_option);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54",
@@ -621,7 +631,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
response_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -644,7 +654,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
request_->addOption(rai);
response_->addOption(rai);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -659,7 +669,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
+ sizeof(subscriber_id))));
rai->addOption(subscriber_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -674,7 +684,7 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
remote_id + sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -688,6 +698,9 @@ TEST_F(CalloutTestv4, directClient4CustomLoggingFormatRequestAndResponse) {
// Verifies legal entry content for relayed clients
// Checks with and without RAI and its suboptions
TEST_F(CalloutTestv4, relayedClient4) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
@@ -695,7 +708,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
// Verify a relayed request without client id or RAI
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e"
@@ -705,7 +718,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
// Verify a relayed request with client id, but no RAI
lease_->client_id_ = client_id_;
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -720,7 +733,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
request_->addOption(rai);
// Verify a relayed request with RAI but has neither circuit id or remote id
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -736,7 +749,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
// Verify a relayed request with RAI with only circuit id
rai->addOption(circuit_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -752,7 +765,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
+ sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -764,7 +777,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
// Verify a relayed request with RAI with only remote id
rai->delOption(RAI_OPTION_AGENT_CIRCUIT_ID);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -773,7 +786,7 @@ TEST_F(CalloutTestv4, relayedClient4) {
entry);
lease_->setContext(Element::fromJSON("{ \"bar\": false }"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -786,6 +799,9 @@ TEST_F(CalloutTestv4, relayedClient4) {
// Verifies legal entry content for relayed clients
// Checks with and without RAI and its suboptions
TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
BackendStoreFactory::instance()->setRequestFormatExpression(request_format_only_);
@@ -795,7 +811,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
// Verify a relayed request without client id or RAI
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e"
@@ -810,7 +826,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
request_->addOption(client_id_option);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -825,7 +841,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
request_->addOption(rai);
// Verify a relayed request with RAI but has neither circuit id or remote id
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -841,7 +857,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
// Verify a relayed request with RAI with only circuit id
rai->addOption(circuit_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -857,7 +873,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
+ sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -869,7 +885,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
// Verify a relayed request with RAI with only remote id
rai->delOption(RAI_OPTION_AGENT_CIRCUIT_ID);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -881,6 +897,9 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestOnly) {
// Verifies legal entry content for relayed clients
// Checks with and without RAI and its suboptions
TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
BackendStoreFactory::instance()->setRequestFormatExpression(request_format_);
@@ -892,7 +911,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
response_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e"
@@ -908,7 +927,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
request_->addOption(client_id_option);
response_->addOption(client_id_option);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -924,7 +943,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
response_->addOption(rai);
// Verify a relayed request with RAI but has neither circuit id or remote id
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -940,7 +959,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
// Verify a relayed request with RAI with only circuit id
rai->addOption(circuit_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -956,7 +975,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
+ sizeof(remote_id))));
rai->addOption(remote_id_opt);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -968,7 +987,7 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
// Verify a relayed request with RAI with only remote id
rai->delOption(RAI_OPTION_AGENT_CIRCUIT_ID);
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 6735 seconds"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: 17:34:e2:ff:09:92:54"
@@ -979,6 +998,9 @@ TEST_F(CalloutTestv4, relayedClient4CustomLoggingFormatRequestAndResponse) {
// Verifies printable items
TEST_F(CalloutTestv4, printable4) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
request_->setGiaddr(isc::asiolink::IOAddress("192.2.16.33"));
@@ -1018,7 +1040,7 @@ TEST_F(CalloutTestv4, printable4) {
std::string entry;
// Verify a relayed request with RAI.
ASSERT_NO_THROW(entry = genLease4Entry(request_, response_, lease_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease4Entry(handle, request_, response_, lease_, Action::ASSIGN));
EXPECT_EQ("Address: 192.2.1.100 has been assigned for 1 hrs 52 mins 15 secs"
" to a device with hardware address:"
" hwtype=1 08:00:2b:02:3f:4e, client-id: "
@@ -1034,6 +1056,7 @@ TEST_F(CalloutTestv4, printable4) {
TEST_F(CalloutTestv4, noRotatingFileTest4) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
handle.setArgument("lease4", lease_);
handle.setArgument("query4", request_);
@@ -1050,6 +1073,7 @@ TEST_F(CalloutTestv4, pkt4_receive) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(discover_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet4Ptr subnet2345(new Subnet4(IOAddress("192.2.2.0"), 24, 30, 40, 50, SubnetID(2345)));
@@ -1153,6 +1177,7 @@ TEST_F(CalloutTestv4, leases4_committed) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet4Ptr subnet2345(new Subnet4(IOAddress("192.2.2.0"), 24, 30, 40, 50, SubnetID(2345)));
@@ -1267,6 +1292,7 @@ TEST_F(CalloutTestv4, lease4_renew) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet4Ptr subnet2345(new Subnet4(IOAddress("192.2.2.0"), 24, 30, 40, 50, SubnetID(2345)));
@@ -1380,6 +1406,7 @@ TEST_F(CalloutTestv4, customRequestLoggingFormat_lease4_renew) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt4.msgtype == 5, concat('Assigned address: ', addrtotext(pkt4.yiaddr)), '')";
@@ -1430,6 +1457,7 @@ TEST_F(CalloutTestv4, lease4_release) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(release_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet4Ptr subnet2345(new Subnet4(IOAddress("192.2.2.0"), 24, 30, 40, 50, SubnetID(2345)));
@@ -1508,6 +1536,7 @@ TEST_F(CalloutTestv4, customRequestLoggingFormat_lease4_release) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(release_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt4.msgtype == 7, concat('Released address: ', addrtotext(pkt4.ciaddr)), '')";
@@ -1545,6 +1574,7 @@ TEST_F(CalloutTestv4, lease4_decline) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet4Ptr subnet2345(new Subnet4(IOAddress("192.2.2.0"), 24, 30, 40, 50, SubnetID(2345)));
@@ -1623,6 +1653,7 @@ TEST_F(CalloutTestv4, customRequestLoggingFormat_lease4_decline) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt4.msgtype == 4, concat('Declined address: ', addrtotext(option[50].hex)), '')";
@@ -1659,6 +1690,7 @@ TEST_F(CalloutTestv4, customRequestLoggingFormatMultipleLines) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt4.msgtype == 4, 'first line' + 0x0a + 'second line', '')";

View File

@@ -43,7 +43,8 @@ using namespace dhcp;
extern std::string hwaddrSourceToString(uint32_t source);
extern std::string genLease6Entry(const Pkt6Ptr& query,
extern std::string genLease6Entry(CalloutHandle& handle,
const Pkt6Ptr& query,
const Pkt6Ptr& response,
const Lease6Ptr& lease,
const Action& action);
@@ -412,36 +413,39 @@ TEST(Lease6FuncTest, hwaddrSourceToString ) {
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6NA) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_na_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_na_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a decline
ASSERT_NO_THROW(entry = genLease6Entry(decline_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, decline_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
@@ -450,7 +454,7 @@ TEST_F(CalloutTestv6, directClient6NA) {
// possible value for hardware source as the function which converts it
// is tested explicitly.
lease_na_->hwaddr_ = hwaddr_;
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54 and hardware"
" address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket)",
@@ -458,7 +462,7 @@ TEST_F(CalloutTestv6, directClient6NA) {
// Add user context.
lease_na_->setContext(Element::fromJSON("{ \"foo\": true }"));
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54 and hardware"
" address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket),"
@@ -468,6 +472,9 @@ TEST_F(CalloutTestv6, directClient6NA) {
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6NACustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -477,42 +484,45 @@ TEST_F(CalloutTestv6, directClient6NACustomLoggingFormatRequestOnly) {
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_na_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_na_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a decline
ASSERT_NO_THROW(entry = genLease6Entry(decline_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, decline_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a solicit
ASSERT_NO_THROW(entry = genLease6Entry(solicit_na_, response_na_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, solicit_na_, response_na_, lease_na_, Action::RELEASE));
EXPECT_TRUE(entry.empty());
}
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6NACustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -523,43 +533,46 @@ TEST_F(CalloutTestv6, directClient6NACustomLoggingFormatRequestAndResponse) {
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_na_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_na_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a decline
ASSERT_NO_THROW(entry = genLease6Entry(decline_, response_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, decline_, response_, lease_na_, Action::RELEASE));
EXPECT_EQ("Address: 2001:db8:1:: has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a solicit
response_na_->setType(DHCPV6_ADVERTISE);
ASSERT_NO_THROW(entry = genLease6Entry(solicit_na_, response_na_, lease_na_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, solicit_na_, response_na_, lease_na_, Action::RELEASE));
EXPECT_TRUE(entry.empty());
}
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6NA) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
@@ -573,7 +586,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
request_na_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -595,7 +608,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
request_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -617,7 +630,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
request_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -634,7 +647,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
request_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -653,7 +666,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
request_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -664,7 +677,7 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
// Verify user context
lease_na_->setContext(Element::fromJSON("{ \"bar\": false }"));
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -677,6 +690,9 @@ TEST_F(CalloutTestv6, relayedClient6NA) {
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -694,7 +710,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
request_na_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -716,7 +732,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
request_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -738,7 +754,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
request_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -755,7 +771,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
request_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -774,7 +790,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
request_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -786,6 +802,9 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestOnly) {
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -805,7 +824,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
request_na_->addRelayInfo(relay1);
response_na_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -830,7 +849,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
response_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -855,7 +874,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
response_na_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -875,7 +894,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
response_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -897,7 +916,7 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
response_na_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -909,30 +928,33 @@ TEST_F(CalloutTestv6, relayedClient6NACustomLoggingFormatRequestAndResponse) {
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6PD) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_pd_, response_, lease_pd_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_pd_, response_, lease_pd_, Action::RELEASE));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
@@ -941,7 +963,7 @@ TEST_F(CalloutTestv6, directClient6PD) {
// possible value for hardware source as the function which converts it
// is tested explicitly.
lease_pd_->hwaddr_ = hwaddr_;
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54 and hardware"
" address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket)",
@@ -949,7 +971,7 @@ TEST_F(CalloutTestv6, directClient6PD) {
// Add user context.
lease_pd_->setContext(Element::fromJSON("{ \"foo\": true }"));
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54 and hardware"
" address: hwtype=1 08:00:2b:02:3f:4e (from Raw Socket),"
@@ -959,6 +981,9 @@ TEST_F(CalloutTestv6, directClient6PD) {
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6PDCustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -968,36 +993,39 @@ TEST_F(CalloutTestv6, directClient6PDCustomLoggingFormatRequestOnly) {
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_pd_, response_, lease_pd_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_pd_, response_, lease_pd_, Action::RELEASE));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a solicit
ASSERT_NO_THROW(entry = genLease6Entry(solicit_pd_, response_pd_, lease_pd_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, solicit_pd_, response_pd_, lease_pd_, Action::RELEASE));
EXPECT_TRUE(entry.empty());
}
// Verifies DHCPv6 entries for directly connected clients
TEST_F(CalloutTestv6, directClient6PDCustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -1008,37 +1036,40 @@ TEST_F(CalloutTestv6, directClient6PDCustomLoggingFormatRequestAndResponse) {
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a renewal
ASSERT_NO_THROW(entry = genLease6Entry(renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, renew_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address and duration for a rebind
ASSERT_NO_THROW(entry = genLease6Entry(rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, rebind_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a release
ASSERT_NO_THROW(entry = genLease6Entry(release_pd_, response_, lease_pd_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, release_pd_, response_, lease_pd_, Action::RELEASE));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been released"
" from a device with DUID: 17:34:e2:ff:09:92:54",
entry);
// Verify address for a solicit
response_pd_->setType(DHCPV6_ADVERTISE);
ASSERT_NO_THROW(entry = genLease6Entry(solicit_pd_, response_pd_, lease_pd_, Action::RELEASE));
ASSERT_NO_THROW(entry = genLease6Entry(handle, solicit_pd_, response_pd_, lease_pd_, Action::RELEASE));
EXPECT_TRUE(entry.empty());
}
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6PD) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
std::string entry;
@@ -1052,7 +1083,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
request_pd_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1074,7 +1105,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
request_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1096,7 +1127,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
request_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1113,7 +1144,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
request_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1132,7 +1163,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
request_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1143,7 +1174,7 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
// Verify user context
lease_pd_->setContext(Element::fromJSON("{ \"bar\": false }"));
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1156,6 +1187,9 @@ TEST_F(CalloutTestv6, relayedClient6PD) {
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -1173,7 +1207,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
request_pd_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1195,7 +1229,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
request_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1217,7 +1251,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
request_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1234,7 +1268,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
request_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1253,7 +1287,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
request_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1265,6 +1299,9 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestOnly) {
// Verifies DHCPv6 entries for relayed clients
TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
CfgMgr::instance().setFamily(AF_INET6);
@@ -1284,7 +1321,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
request_pd_->addRelayInfo(relay1);
response_pd_->addRelayInfo(relay1);
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1309,7 +1346,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
response_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1334,7 +1371,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
response_pd_->addRelayInfo(relay1);
// Verify relay info with REMOTE_ID and SUBSCRIBER_ID
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1354,7 +1391,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
response_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1376,7 +1413,7 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
response_pd_->addRelayInfo(relay1);
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_pd_, response_pd_, lease_pd_, Action::ASSIGN));
EXPECT_EQ("Prefix: 2001:db8:1::/64 has been assigned for 713 seconds"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1388,6 +1425,9 @@ TEST_F(CalloutTestv6, relayedClient6PDCustomLoggingFormatRequestAndResponse) {
// Verifies printable id handling
TEST_F(CalloutTestv6, printable6) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
ASSERT_NO_THROW(BackendStoreFactory::instance().reset(new TestableRotatingFile(time_)));
Pkt6::RelayInfo relay1;
@@ -1418,7 +1458,7 @@ TEST_F(CalloutTestv6, printable6) {
std::string entry;
// Verify address and duration for an assignment
ASSERT_NO_THROW(entry = genLease6Entry(request_na_, response_na_, lease_na_, Action::ASSIGN));
ASSERT_NO_THROW(entry = genLease6Entry(handle, request_na_, response_na_, lease_na_, Action::ASSIGN));
EXPECT_EQ("Address: 2001:db8:1:: has been assigned for 0 hrs 11 mins 53 secs"
" to a device with DUID: 17:34:e2:ff:09:92:54"
" connected via relay at address: fe80::abcd"
@@ -1434,6 +1474,7 @@ TEST_F(CalloutTestv6, printable6) {
TEST_F(CalloutTestv6, noRotatingFileTest6) {
// Make a callout handle
CalloutHandle handle(getCalloutManager());
handle.setCurrentLibrary(0);
handle.setArgument("lease6", lease_na_);
handle.setArgument("query6", request_na_);
@@ -1450,6 +1491,7 @@ TEST_F(CalloutTestv6, pkt6_receive) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(solicit_na_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -1559,6 +1601,7 @@ TEST_F(CalloutTestv6, leases6_committed) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_na_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -1677,6 +1720,7 @@ TEST_F(CalloutTestv6, lease6_renew) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(renew_na_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -1797,6 +1841,7 @@ TEST_F(CalloutTestv6, customRequestLoggingFormat_lease6_renew) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(renew_na_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt6.msgtype == 5, concat('Assigned address: ', addrtotext(substring(option[3].option[5].hex, 0, 16))), '')";
@@ -1850,6 +1895,7 @@ TEST_F(CalloutTestv6, lease6_rebind) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(rebind_na_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -1970,6 +2016,7 @@ TEST_F(CalloutTestv6, customRequestLoggingFormat_lease6_rebind) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(rebind_na_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt6.msgtype == 6, concat('Assigned address: ', addrtotext(substring(option[3].option[5].hex, 0, 16))), '')";
@@ -2023,6 +2070,7 @@ TEST_F(CalloutTestv6, lease6_release) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(release_na_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -2129,6 +2177,7 @@ TEST_F(CalloutTestv6, customRequestLoggingFormat_lease6_release) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(release_na_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt6.msgtype == 8, concat('Released address: ', addrtotext(substring(option[3].option[5].hex, 0, 16))), '')";
@@ -2176,6 +2225,7 @@ TEST_F(CalloutTestv6, lease6_decline) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
// Create a subnet with user context disabling legal logging.
Subnet6Ptr subnet2345(new Subnet6(IOAddress("2001:db8:2::"), 64, 30, 40, 50, 60,
@@ -2282,6 +2332,7 @@ TEST_F(CalloutTestv6, customRequestLoggingFormat_lease6_decline) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt6.msgtype == 9, concat('Declined address: ', addrtotext(substring(option[3].option[5].hex, 0, 16))), '')";
@@ -2328,6 +2379,7 @@ TEST_F(CalloutTestv6, customRequestLoggingFormatMultipleLines) {
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(decline_);
handle->setCurrentLibrary(0);
std::string format = "ifelse(pkt6.msgtype == 9, 'first line' + 0x0a + 'second line', '')";
@@ -2372,6 +2424,7 @@ TEST_F(CalloutTestv6, multipleAddressesAndPrefixesCustomLoggingFormatRequestOnly
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_na_);
handle->setCurrentLibrary(0);
CfgMgr::instance().setFamily(AF_INET6);
@@ -2543,6 +2596,7 @@ TEST_F(CalloutTestv6, multipleAddressesAndPrefixesCustomLoggingFormatRequestAndR
// Make a callout handle
CalloutHandlePtr handle = getCalloutHandle(request_na_);
handle->setCurrentLibrary(0);
CfgMgr::instance().setFamily(AF_INET6);

View File

@@ -1,321 +0,0 @@
// Copyright (C) 2016-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef TEST_UTILS_H
#define TEST_UTILS_H
#include <exceptions/exceptions.h>
#include <dhcpsrv/cfgmgr.h>
#include <hooks/callout_manager.h>
#include <dhcpsrv/backend_store.h>
#include <util/reconnect_ctl.h>
#include <gtest/gtest.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <time.h>
#include <errno.h>
#include <cstdio>
#include <locale>
#include <fstream>
#include <sys/stat.h>
using namespace isc;
using namespace hooks;
using namespace dhcp;
namespace isc {
namespace dhcp {
static isc::asiolink::IOServicePtr local_io_service = isc::asiolink::IOServicePtr(new isc::asiolink::IOService());
/// @brief Helper class to execute a SQL tool and get results
class runSQL {
public:
/// @brief Constructor
runSQL() {
reset();
}
/// @brief Destructor
virtual ~runSQL() = default;
/// @brief Reset everything
void reset() {
command_ = "";
query_ = "";
result_ = 0;
output_.clear();
}
/// @brief Get command
/// @return the command
const std::string& getCommand() const {
return (command_);
}
/// @brief Set command
/// @param the command
void setCommand(const std::string& command) {
command_ = command;
}
/// @brief Get query
/// @return the query
const std::string& getQuery() const {
return (query_);
}
/// @brief Set query
/// @param the query
void setQuery(const std::string& query) {
query_ = query;
}
/// @brief Get result
/// @return the exit code
int getResult() const {
return (result_);
}
/// @brief Get raw output
/// @return the unprocessed output
std::vector<std::string> getRawOutput() {
return (output_);
}
/// @brief Process output
/// @param output reference to the string vector to fill with output
/// @return true if processing was successful
virtual bool getOutput(std::vector<std::string>& output) = 0;
/// @brief Execute
/// @throw std::system_error according to boost documentation
void execute() {
// Reading stream
FILE* istream;
size_t buffer_size = 1024;
char buffer[buffer_size + 1];
// Child process
std::string cmd = command_ + "\"" + query_ + "\"";
istream = popen(cmd.c_str(), "r");
// Check errors
if (!istream) {
result_ = -1;
return;
} else {
result_ = ferror(istream);
if (result_) {
return;
}
}
// Read output
while (!feof(istream) && fgets(buffer, buffer_size, istream)) {
output_.push_back(std::string(buffer));
}
// Wait for children to terminate and get its exit code
result_ = pclose(istream);
}
private:
// @brief command
std::string command_;
// @brief query
std::string query_;
// @brief exit code aka result
int result_;
// @brief output
std::vector<std::string> output_;
};
/// @brief Test fixture for testing database backend connection recovery.
class LegalLogDbLostCallbackTest : public ::testing::Test {
public:
/// @brief Constructor.
LegalLogDbLostCallbackTest()
: db_lost_callback_called_(0), db_recovered_callback_called_(0),
db_failed_callback_called_(0),
io_service_(local_io_service) {
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
isc::db::DatabaseConnection::setIOService(io_service_);
BackendStoreFactory::setIOService(io_service_);
isc::dhcp::TimerMgr::instance()->setIOService(io_service_);
BackendStoreFactory::delAllBackends();
}
/// @brief Destructor.
virtual ~LegalLogDbLostCallbackTest() {
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
isc::db::DatabaseConnection::setIOService(isc::asiolink::IOServicePtr());
BackendStoreFactory::setIOService(isc::asiolink::IOServicePtr());
isc::dhcp::TimerMgr::instance()->unregisterTimers();
BackendStoreFactory::delAllBackends();
}
/// @brief Prepares the class for a test.
///
/// Invoked by gtest prior test entry, we create the
/// appropriate schema and create a basic DB manager to
/// wipe out any prior instance
virtual void SetUp() = 0;
/// @brief Pre-text exit clean up
///
/// Invoked by gtest upon test exit, we destroy the schema
/// we created.
virtual void TearDown() = 0;
/// @brief Method which returns the back end specific connection
/// string
virtual std::string validConnectString() = 0;
/// @brief Method which returns invalid back end specific connection
/// string
virtual std::string invalidConnectString() = 0;
/// @brief Verifies the Backend Store behavior if DB connection can not be
/// established but succeeds on retry
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies that connectivity is unavailable
/// and then recovered on retry:
/// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked
virtual void testRetryOpenDbLostAndRecoveredCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection can not be
/// established but fails on retry
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies that connectivity is unavailable
/// and then fails again on retry:
/// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked
virtual void testRetryOpenDbLostAndFailedCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection can not be
/// established but succeeds on retry
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies that connectivity is unavailable
/// and then recovered on retry:
/// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked after two reconnect
/// attempts (once failing and second triggered by timer)
virtual void testRetryOpenDbLostAndRecoveredAfterTimeoutCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection can not be
/// established but fails on retry
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies that connectivity is unavailable
/// and then fails again on retry:
/// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked after two reconnect
/// attempts (once failing and second triggered by timer)
virtual void testRetryOpenDbLostAndFailedAfterTimeoutCallback() = 0;
/// @brief Verifies open failures do NOT invoke db lost callback
///
/// The db lost callback should only be invoked after successfully
/// opening the DB and then subsequently losing it. Failing to
/// open should be handled directly by the application layer.
virtual void testNoCallbackOnOpenFailure() = 0;
/// @brief Verifies the Backend Store behavior if DB connection is lost
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies connectivity by issuing a known
/// valid query. Next it simulates connectivity lost by identifying and
/// closing the socket connection to the Backend Store. It then reissues the
/// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked
virtual void testDbLostAndRecoveredCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection is lost
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies connectivity by issuing a known
/// valid query. Next it simulates connectivity lost by identifying and
/// closing the socket connection to the Backend Store. It then reissues the
/// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked
virtual void testDbLostAndFailedCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection is lost
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies connectivity by issuing a known
/// valid query. Next it simulates connectivity lost by identifying and
/// closing the socket connection to the Backend Store. It then reissues the
/// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked after two reconnect
/// attempts (once failing and second triggered by timer)
virtual void testDbLostAndRecoveredAfterTimeoutCallback() = 0;
/// @brief Verifies the Backend Store behavior if DB connection is lost
///
/// This function creates a Backend Store with a back end that supports
/// connectivity lost callback. It verifies connectivity by issuing a known
/// valid query. Next it simulates connectivity lost by identifying and
/// closing the socket connection to the Backend Store. It then reissues the
/// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked after two reconnect
/// attempts (once failing and second triggered by timer)
virtual void testDbLostAndFailedAfterTimeoutCallback() = 0;
/// @brief Callback function registered with the Backend Store
bool db_lost_callback(util::ReconnectCtlPtr /* not_used */) {
return (++db_lost_callback_called_);
}
/// @brief Flag used to detect calls to db_lost_callback function
uint32_t db_lost_callback_called_;
/// @brief Callback function registered with the Backend Store
bool db_recovered_callback(util::ReconnectCtlPtr /* not_used */) {
return (++db_recovered_callback_called_);
}
/// @brief Flag used to detect calls to db_recovered_callback function
uint32_t db_recovered_callback_called_;
/// @brief Callback function registered with the Backend Store
bool db_failed_callback(util::ReconnectCtlPtr /* not_used */) {
return (++db_failed_callback_called_);
}
/// @brief Flag used to detect calls to db_failed_callback function
uint32_t db_failed_callback_called_;
/// The IOService object, used for all ASIO operations.
isc::asiolink::IOServicePtr io_service_;
};
} // namespace dhcp
} // namespace isc
#endif // TEST_UTILS_H

View File

@@ -10,6 +10,8 @@
#include <config_backend/base_config_backend.h>
#include <database/database_connection.h>
#include <database/backend_selector.h>
#include <database/db_log.h>
#include <database/db_messages.h>
#include <exceptions/exceptions.h>
#include <boost/shared_ptr.hpp>
#include <functional>
@@ -213,6 +215,25 @@ public:
return (pool_);
}
/// @brief Logs out all registered backends.
///
/// We need a dedicated method for this, because we sometimes can't log
/// the backend type when doing early initialization for backends
/// initialized statically.
void logRegistered() {
std::stringstream txt;
for (auto const& x : factories_) {
if (!txt.str().empty()) {
txt << " ";
}
txt << x.first;
}
LOG_INFO(isc::db::database_logger, isc::db::CONFIG_BACKENDS_REGISTERED)
.arg(txt.str());
}
protected:
/// @brief A map holding registered backend factory functions.

View File

@@ -7,6 +7,7 @@
namespace isc {
namespace db {
extern const isc::log::MessageID CONFIG_BACKENDS_REGISTERED = "CONFIG_BACKENDS_REGISTERED";
extern const isc::log::MessageID DATABASE_INVALID_ACCESS = "DATABASE_INVALID_ACCESS";
extern const isc::log::MessageID DATABASE_MYSQL_COMMIT = "DATABASE_MYSQL_COMMIT";
extern const isc::log::MessageID DATABASE_MYSQL_FATAL_ERROR = "DATABASE_MYSQL_FATAL_ERROR";
@@ -32,6 +33,7 @@ extern const isc::log::MessageID DATABASE_TO_JSON_UNKNOWN_TYPE_ERROR = "DATABASE
namespace {
const char* values[] = {
"CONFIG_BACKENDS_REGISTERED", "the following config backend types are available: %1",
"DATABASE_INVALID_ACCESS", "invalid database access string: %1",
"DATABASE_MYSQL_COMMIT", "committing to MySQL database",
"DATABASE_MYSQL_FATAL_ERROR", "Unrecoverable MySQL error occurred: %1 for <%2>, reason: %3 (error code: %4).",

View File

@@ -8,6 +8,7 @@
namespace isc {
namespace db {
extern const isc::log::MessageID CONFIG_BACKENDS_REGISTERED;
extern const isc::log::MessageID DATABASE_INVALID_ACCESS;
extern const isc::log::MessageID DATABASE_MYSQL_COMMIT;
extern const isc::log::MessageID DATABASE_MYSQL_FATAL_ERROR;

View File

@@ -6,6 +6,10 @@
$NAMESPACE isc::db
% CONFIG_BACKENDS_REGISTERED the following config backend types are available: %1
This informational message lists all possible config backends that could
be used in config-database[s].
% DATABASE_INVALID_ACCESS invalid database access string: %1
This is logged when an attempt has been made to parse a database access string
and the attempt ended in error. The access string in question - which

View File

@@ -208,6 +208,29 @@ public:
/// @return a vector with parameter entry names.
std::vector<std::string> getParameterNames();
/// @brief Get library index
///
/// @return Current library index.
int getLibraryIndex() const {
return (index_);
}
/// @brief Set library index
///
/// Sets the current library index. This has the following valid values:
///
/// - -1: invalidate current index.
/// - 0: pre-user library callout.
/// - 1 - numlib: user-library callout (where "numlib" is the number of
/// libraries loaded in the system, this figure being passed to this
/// object at construction time).
/// - INT_MAX: post-user library callout.
///
/// @param library_index New library index.
void setLibraryIndex(int library_index) {
index_ = library_index;
}
private:
/// @brief Copy constructor
///

View File

@@ -211,18 +211,24 @@ LibraryManager::runLoad() {
// afterwards.
int status = -1;
int old_index = manager_->getLibraryHandle().getLibraryIndex();
try {
manager_->setLibraryIndex(index_);
manager_->getLibraryHandle().setLibraryIndex(index_);
status = (*pc.loadPtr())(manager_->getLibraryHandle());
} catch (const isc::Exception& ex) {
LOG_ERROR(hooks_logger, HOOKS_LOAD_FRAMEWORK_EXCEPTION)
.arg(library_name_).arg(ex.what());
manager_->getLibraryHandle().setLibraryIndex(old_index);
return (false);
} catch (...) {
LOG_ERROR(hooks_logger, HOOKS_LOAD_EXCEPTION).arg(library_name_);
manager_->getLibraryHandle().setLibraryIndex(old_index);
return (false);
}
manager_->getLibraryHandle().setLibraryIndex(old_index);
if (status != 0) {
LOG_ERROR(hooks_logger, HOOKS_LOAD_ERROR).arg(library_name_)
.arg(status);