Commit f7a9b5d0 authored by Francis Dupont's avatar Francis Dupont
Browse files

[#1247] Updated databaseConfigApply

parent 86b56f81
......@@ -340,7 +340,7 @@ TEST_F(AuditEntryCollectionTest, getByObjectId) {
const auto& object_id_idx = audit_entries_.get<AuditEntryObjectIdTag>();
// Search for object id 10.
auto range = object_id_idx.equal_range(10);
auto range = object_id_idx.equal_range(10);
ASSERT_EQ(1, std::distance(range.first, range.second));
EXPECT_TRUE(includes("dhcp4_subnet", 10, range.first, range.second));
......
......@@ -141,7 +141,11 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
SrvConfigPtr external_cfg = CfgMgr::instance().createExternalCfg();
// First let's fetch the globals and add them to external config.
if (!globals_fetched && fetchConfigElement(audit_entries, "dhcp4_global_parameter")) {
AuditEntryCollection updated_entries;
if (!globals_fetched && !audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp4_global_parameter");
}
if (!globals_fetched && (audit_entries.empty() || !updated_entries.empty())) {
data::StampedValueCollection globals;
globals = getMgr().getPool()->getModifiedGlobalParameters4(backend_selector, server_selector,
lb_modification_time);
......@@ -149,31 +153,49 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
}
// Now we fetch the option definitions and add them.
if (fetchConfigElement(audit_entries, "dhcp4_option_def")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp4_option_def");
}
if (audit_entries.empty() || !updated_entries.empty()) {
OptionDefContainer option_defs =
getMgr().getPool()->getModifiedOptionDefs4(backend_selector, server_selector,
lb_modification_time);
for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
continue;
}
external_cfg->getCfgOptionDef()->add((*option_def), (*option_def)->getOptionSpaceName());
}
}
// Next fetch the options. They are returned as a container of OptionDescriptors.
if (fetchConfigElement(audit_entries, "dhcp4_options")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp4_options");
}
if (audit_entries.empty() || !updated_entries.empty()) {
OptionContainer options = getMgr().getPool()->getModifiedOptions4(backend_selector,
server_selector,
lb_modification_time);
for (auto option = options.begin(); option != options.end(); ++option) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
continue;
}
external_cfg->getCfgOption()->add((*option), (*option).space_name_);
}
}
// Now fetch the shared networks.
if (fetchConfigElement(audit_entries, "dhcp4_shared_network")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp4_shared_network");
}
if (audit_entries.empty() || !updated_entries.empty()) {
SharedNetwork4Collection networks =
getMgr().getPool()->getModifiedSharedNetworks4(backend_selector, server_selector,
lb_modification_time);
for (auto network = networks.begin(); network != networks.end(); ++network) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*network)->getId())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a shared network we need to set a callback function
// for each network to allow for fetching global parameters.
......@@ -185,11 +207,17 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
}
// Next we fetch subnets.
if (fetchConfigElement(audit_entries, "dhcp4_subnet")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp4_subnet");
}
if (audit_entries.empty() || !updated_entries.empty()) {
Subnet4Collection subnets = getMgr().getPool()->getModifiedSubnets4(backend_selector,
server_selector,
lb_modification_time);
for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*subnet)->getID())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a subnet we need to set a callback function for each
// subnet to allow for fetching global parameters.
......@@ -202,7 +230,6 @@ CBControlDHCPv4::databaseConfigApply(const BackendSelector& backend_selector,
if (audit_entries.empty()) {
CfgMgr::instance().mergeIntoStagingCfg(external_cfg->getSequence());
} else {
CfgMgr::instance().mergeIntoCurrentCfg(external_cfg->getSequence());
}
......
......@@ -140,7 +140,11 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
SrvConfigPtr external_cfg = CfgMgr::instance().createExternalCfg();
// First let's fetch the globals and add them to external config.
if (!globals_fetched && fetchConfigElement(audit_entries, "dhcp6_global_parameter")) {
AuditEntryCollection updated_entries;
if (!globals_fetched && !audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp6_global_parameter");
}
if (!globals_fetched && (audit_entries.empty() || !updated_entries.empty())) {
data::StampedValueCollection globals;
globals = getMgr().getPool()->getModifiedGlobalParameters6(backend_selector, server_selector,
lb_modification_time);
......@@ -148,31 +152,49 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
}
// Now we fetch the option definitions and add them.
if (fetchConfigElement(audit_entries, "dhcp6_option_def")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp6_option_def");
}
if (audit_entries.empty() || !updated_entries.empty()) {
OptionDefContainer option_defs =
getMgr().getPool()->getModifiedOptionDefs6(backend_selector, server_selector,
lb_modification_time);
for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option_def)->getId())) {
continue;
}
external_cfg->getCfgOptionDef()->add((*option_def), (*option_def)->getOptionSpaceName());
}
}
// Next fetch the options. They are returned as a container of OptionDescriptors.
if (fetchConfigElement(audit_entries, "dhcp6_options")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp6_options");
}
if (audit_entries.empty() || !updated_entries.empty()) {
OptionContainer options = getMgr().getPool()->getModifiedOptions6(backend_selector,
server_selector,
lb_modification_time);
for (auto option = options.begin(); option != options.end(); ++option) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*option).getId())) {
continue;
}
external_cfg->getCfgOption()->add((*option), (*option).space_name_);
}
}
// Now fetch the shared networks.
if (fetchConfigElement(audit_entries, "dhcp6_shared_network")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp6_shared_network");
}
if (audit_entries.empty() || !updated_entries.empty()) {
SharedNetwork6Collection networks =
getMgr().getPool()->getModifiedSharedNetworks6(backend_selector, server_selector,
lb_modification_time);
for (auto network = networks.begin(); network != networks.end(); ++network) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*network)->getId())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a shared network we need to set a callback function
// for each network to allow for fetching global parameters.
......@@ -184,11 +206,17 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
}
// Next we fetch subnets.
if (fetchConfigElement(audit_entries, "dhcp6_subnet")) {
if (!audit_entries.empty()) {
updated_entries = fetchConfigElement(audit_entries, "dhcp6_subnet");
}
if (audit_entries.empty() || !updated_entries.empty()) {
Subnet6Collection subnets = getMgr().getPool()->getModifiedSubnets6(backend_selector,
server_selector,
lb_modification_time);
for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) {
if (!audit_entries.empty() && !hasObjectId(updated_entries, (*subnet)->getID())) {
continue;
}
// In order to take advantage of the dynamic inheritance of global
// parameters to a subnet we need to set a callback function for each
// subnet to allow for fetching global parameters.
......@@ -201,7 +229,6 @@ CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector
if (audit_entries.empty()) {
CfgMgr::instance().mergeIntoStagingCfg(external_cfg->getSequence());
} else {
CfgMgr::instance().mergeIntoCurrentCfg(external_cfg->getSequence());
}
......
......@@ -40,7 +40,8 @@ public:
/// @brief Constructor.
CBControlDHCPTest()
: timestamp_(), object_timestamp_(), audit_entries_() {
: timestamp_(), object_timestamp_(), audit_entries_(),
modification_id_(2345) {
CfgMgr::instance().clear();
initTimestamps();
callback_name_ = std::string("");
......@@ -67,10 +68,14 @@ public:
///
/// @param object_type Object type to be associated with the audit
/// entry.
void addCreateAuditEntry(const std::string& object_type) {
AuditEntryPtr entry(new AuditEntry(object_type, 1234,
/// @param object_id Identifier of the object to be associated with
/// the audit entry.
void addCreateAuditEntry(const std::string& object_type,
const uint64_t object_id) {
AuditEntryPtr entry(new AuditEntry(object_type, object_id,
AuditEntry::ModificationType::CREATE,
2345, "some log message"));
++modification_id_,
"some log message"));
audit_entries_.insert(entry);
}
......@@ -86,7 +91,8 @@ public:
const uint64_t object_id) {
AuditEntryPtr entry(new AuditEntry(object_type, object_id,
AuditEntry::ModificationType::DELETE,
1234, "some log message"));
++modification_id_,
"some log message"));
audit_entries_.insert(entry);
}
......@@ -139,7 +145,7 @@ public:
/// object types.
///
/// @param object_type Object type.
bool fetchConfigElement(const std::string& object_type) const {
bool hasConfigElement(const std::string& object_type) const {
if (!audit_entries_.empty()) {
const auto& index = audit_entries_.get<AuditEntryObjectTypeTag>();
auto range = index.equal_range(object_type);
......@@ -203,6 +209,9 @@ public:
/// @brief Collection of audit entries used in the unit tests.
AuditEntryCollection audit_entries_;
/// @brief Modification id counter.
uint64_t modification_id_;
/// @brief Callback name.
static std::string callback_name_;
......@@ -453,7 +462,7 @@ public:
// If there is an audit entry for global parameter and the parameter
// modification time is later than last audit entry time it should
// be merged.
if (fetchConfigElement("dhcp4_global_parameter") &&
if (hasConfigElement("dhcp4_global_parameter") &&
(getTimestamp("dhcp4_global_parameter") > lb_modification_time)) {
checkConfiguredGlobal(srv_cfg, "foo", Element::create("bar"));
......@@ -466,7 +475,7 @@ public:
// modification time is later than last audit entry time it should
// be merged.
auto found_def = srv_cfg->getCfgOptionDef()->get("isc", "one");
if (fetchConfigElement("dhcp4_option_def") &&
if (hasConfigElement("dhcp4_option_def") &&
getTimestamp("dhcp4_option_def") > lb_modification_time) {
ASSERT_TRUE(found_def);
EXPECT_EQ(101, found_def->getCode());
......@@ -481,7 +490,7 @@ public:
// be merged.
auto options = srv_cfg->getCfgOption();
auto found_opt = options->get("dhcp4", DHO_HOST_NAME);
if (fetchConfigElement("dhcp4_options") &&
if (hasConfigElement("dhcp4_options") &&
(getTimestamp("dhcp4_options") > lb_modification_time)) {
ASSERT_TRUE(found_opt.option_);
EXPECT_EQ("new.example.com", found_opt.option_->toString());
......@@ -495,7 +504,7 @@ public:
// be merged.
auto networks = srv_cfg->getCfgSharedNetworks4();
auto found_network = networks->getByName("one");
if (fetchConfigElement("dhcp4_shared_network") &&
if (hasConfigElement("dhcp4_shared_network") &&
(getTimestamp("dhcp4_shared_network") > lb_modification_time)) {
ASSERT_TRUE(found_network);
EXPECT_TRUE(found_network->hasFetchGlobalsFn());
......@@ -508,7 +517,7 @@ public:
// time is later than last audit entry time it should be merged.
auto subnets = srv_cfg->getCfgSubnets4();
auto found_subnet = subnets->getSubnet(1);
if (fetchConfigElement("dhcp4_subnet") &&
if (hasConfigElement("dhcp4_subnet") &&
(getTimestamp("dhcp4_subnet") > lb_modification_time)) {
ASSERT_TRUE(found_subnet);
EXPECT_TRUE(found_subnet->hasFetchGlobalsFn());
......@@ -648,11 +657,16 @@ public:
// types are merged into the current configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyAll) {
addCreateAuditEntry("dhcp4_global_parameter");
addCreateAuditEntry("dhcp4_option_def");
addCreateAuditEntry("dhcp4_options");
addCreateAuditEntry("dhcp4_shared_network");
addCreateAuditEntry("dhcp4_subnet");
addCreateAuditEntry("dhcp4_global_parameter", 1);
addCreateAuditEntry("dhcp4_global_parameter", 2);
addCreateAuditEntry("dhcp4_option_def", 1);
addCreateAuditEntry("dhcp4_option_def", 2);
addCreateAuditEntry("dhcp4_options", 1);
addCreateAuditEntry("dhcp4_options", 2);
addCreateAuditEntry("dhcp4_shared_network", 1);
addCreateAuditEntry("dhcp4_shared_network", 2);
addCreateAuditEntry("dhcp4_subnet", 1);
addCreateAuditEntry("dhcp4_subnet", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -689,7 +703,8 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteNonExisting) {
// This test verifies that only a global parameter is merged into
// the current configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyGlobal) {
addCreateAuditEntry("dhcp4_global_parameter");
addCreateAuditEntry("dhcp4_global_parameter", 1);
addCreateAuditEntry("dhcp4_global_parameter", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -706,14 +721,16 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteGlobal) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyGlobalNotFetched) {
addCreateAuditEntry("dhcp4_global_parameter");
addCreateAuditEntry("dhcp4_global_parameter", 1);
addCreateAuditEntry("dhcp4_global_parameter", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only an option definition is merged into
// the current configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyOptionDef) {
addCreateAuditEntry("dhcp4_option_def");
addCreateAuditEntry("dhcp4_option_def", 1);
addCreateAuditEntry("dhcp4_option_def", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -731,14 +748,16 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteOptionDef) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyOptionDefNotFetched) {
addCreateAuditEntry("dhcp4_option_def");
addCreateAuditEntry("dhcp4_option_def", 1);
addCreateAuditEntry("dhcp4_option_def", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a DHCPv4 option is merged into the
// current configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyOption) {
addCreateAuditEntry("dhcp4_options");
addCreateAuditEntry("dhcp4_options", 1);
addCreateAuditEntry("dhcp4_options", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -755,14 +774,16 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteOption) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv4Test, databaseConfigApplyOptionNotFetched) {
addCreateAuditEntry("dhcp4_options");
addCreateAuditEntry("dhcp4_options", 1);
addCreateAuditEntry("dhcp4_options", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a shared network is merged into the
// current configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplySharedNetwork) {
addCreateAuditEntry("dhcp4_shared_network");
addCreateAuditEntry("dhcp4_shared_network", 1);
addCreateAuditEntry("dhcp4_shared_network", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -779,15 +800,18 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteSharedNetwork) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv4Test, databaseConfigApplySharedNetworkNotFetched) {
addCreateAuditEntry("dhcp4_shared_network");
addCreateAuditEntry("dhcp4_shared_network", 1);
addCreateAuditEntry("dhcp4_shared_network", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a subnet is merged into the current
// configuration.
TEST_F(CBControlDHCPv4Test, databaseConfigApplySubnet) {
addCreateAuditEntry("dhcp4_shared_network");
addCreateAuditEntry("dhcp4_subnet");
addCreateAuditEntry("dhcp4_shared_network", 1);
addCreateAuditEntry("dhcp4_shared_network", 2);
addCreateAuditEntry("dhcp4_subnet", 1);
addCreateAuditEntry("dhcp4_subnet", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -803,7 +827,8 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyDeleteSubnet) {
// when the modification time is earlier than the last fetched audit
// entry.
TEST_F(CBControlDHCPv4Test, databaseConfigApplySubnetNotFetched) {
addCreateAuditEntry("dhcp4_subnet");
addCreateAuditEntry("dhcp4_subnet", 1);
addCreateAuditEntry("dhcp4_subnet", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
......@@ -818,11 +843,16 @@ TEST_F(CBControlDHCPv4Test, databaseConfigApplyHook) {
"cb4_updated", cb4_updated_callout));
// Create audit entries.
addCreateAuditEntry("dhcp4_global_parameter");
addCreateAuditEntry("dhcp4_option_def");
addCreateAuditEntry("dhcp4_options");
addCreateAuditEntry("dhcp4_shared_network");
addCreateAuditEntry("dhcp4_subnet");
addCreateAuditEntry("dhcp4_global_parameter", 1);
addCreateAuditEntry("dhcp4_global_parameter", 2);
addCreateAuditEntry("dhcp4_option_def", 1);
addCreateAuditEntry("dhcp4_option_def", 2);
addCreateAuditEntry("dhcp4_options", 1);
addCreateAuditEntry("dhcp4_options", 2);
addCreateAuditEntry("dhcp4_shared_network", 1);
addCreateAuditEntry("dhcp4_shared_network", 2);
addCreateAuditEntry("dhcp4_subnet", 1);
addCreateAuditEntry("dhcp4_subnet", 2);
// Run the test.
testDatabaseConfigApply(getTimestamp(-5));
......@@ -1078,7 +1108,7 @@ public:
// If there is an audit entry for global parameter and the parameter
// modification time is later than last audit entry time it should
// be merged.
if (fetchConfigElement("dhcp6_global_parameter") &&
if (hasConfigElement("dhcp6_global_parameter") &&
(getTimestamp("dhcp6_global_parameter") > lb_modification_time)) {
checkConfiguredGlobal(srv_cfg, "foo", Element::create("bar"));
......@@ -1091,7 +1121,7 @@ public:
// modification time is later than last audit entry time it should
// be merged.
auto found_def = srv_cfg->getCfgOptionDef()->get("isc", "one");
if (fetchConfigElement("dhcp6_option_def") &&
if (hasConfigElement("dhcp6_option_def") &&
getTimestamp("dhcp6_option_def") > lb_modification_time) {
ASSERT_TRUE(found_def);
EXPECT_EQ(101, found_def->getCode());
......@@ -1106,7 +1136,7 @@ public:
// be merged.
auto options = srv_cfg->getCfgOption();
auto found_opt = options->get("dhcp6", D6O_BOOTFILE_URL);
if (fetchConfigElement("dhcp6_options") &&
if (hasConfigElement("dhcp6_options") &&
(getTimestamp("dhcp6_options") > lb_modification_time)) {
ASSERT_TRUE(found_opt.option_);
EXPECT_EQ("some.bootfile", found_opt.option_->toString());
......@@ -1120,7 +1150,7 @@ public:
// be merged.
auto networks = srv_cfg->getCfgSharedNetworks6();
auto found_network = networks->getByName("one");
if (fetchConfigElement("dhcp6_shared_network") &&
if (hasConfigElement("dhcp6_shared_network") &&
(getTimestamp("dhcp6_shared_network") > lb_modification_time)) {
ASSERT_TRUE(found_network);
EXPECT_TRUE(found_network->hasFetchGlobalsFn());
......@@ -1133,7 +1163,7 @@ public:
// time is later than last audit entry time it should be merged.
auto subnets = srv_cfg->getCfgSubnets6();
auto found_subnet = subnets->getSubnet(1);
if (fetchConfigElement("dhcp6_subnet") &&
if (hasConfigElement("dhcp6_subnet") &&
(getTimestamp("dhcp6_subnet") > lb_modification_time)) {
ASSERT_TRUE(found_subnet);
EXPECT_TRUE(found_subnet->hasFetchGlobalsFn());
......@@ -1272,11 +1302,16 @@ public:
// types are merged into the current configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyAll) {
addCreateAuditEntry("dhcp6_global_parameter");
addCreateAuditEntry("dhcp6_option_def");
addCreateAuditEntry("dhcp6_options");
addCreateAuditEntry("dhcp6_shared_network");
addCreateAuditEntry("dhcp6_subnet");
addCreateAuditEntry("dhcp6_global_parameter", 1);
addCreateAuditEntry("dhcp6_global_parameter", 2);
addCreateAuditEntry("dhcp6_option_def", 1);
addCreateAuditEntry("dhcp6_option_def", 2);
addCreateAuditEntry("dhcp6_options", 1);
addCreateAuditEntry("dhcp6_options", 2);
addCreateAuditEntry("dhcp6_shared_network", 1);
addCreateAuditEntry("dhcp6_shared_network", 2);
addCreateAuditEntry("dhcp6_subnet", 1);
addCreateAuditEntry("dhcp6_subnet", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1313,7 +1348,8 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteNonExisting) {
// This test verifies that only a global parameter is merged into
// the current configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyGlobal) {
addCreateAuditEntry("dhcp6_global_parameter");
addCreateAuditEntry("dhcp6_global_parameter", 1);
addCreateAuditEntry("dhcp6_global_parameter", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1330,14 +1366,16 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteGlobal) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyGlobalNotFetched) {
addCreateAuditEntry("dhcp6_global_parameter");
addCreateAuditEntry("dhcp6_global_parameter", 1);
addCreateAuditEntry("dhcp6_global_parameter", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only an option definition is merged into
// the current configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyOptionDef) {
addCreateAuditEntry("dhcp6_option_def");
addCreateAuditEntry("dhcp6_option_def", 1);
addCreateAuditEntry("dhcp6_option_def", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1355,14 +1393,16 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteOptionDef) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyOptionDefNotFetched) {
addCreateAuditEntry("dhcp6_option_def");
addCreateAuditEntry("dhcp6_option_def", 1);
addCreateAuditEntry("dhcp6_option_def", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a DHCPv6 option is merged into the
// current configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyOption) {
addCreateAuditEntry("dhcp6_options");
addCreateAuditEntry("dhcp6_options", 1);
addCreateAuditEntry("dhcp6_options", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1379,14 +1419,16 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteOption) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv6Test, databaseConfigApplyOptionNotFetched) {
addCreateAuditEntry("dhcp6_options");
addCreateAuditEntry("dhcp6_options", 1);
addCreateAuditEntry("dhcp6_options", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a shared network is merged into the
// current configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplySharedNetwork) {
addCreateAuditEntry("dhcp6_shared_network");
addCreateAuditEntry("dhcp6_shared_network", 1);
addCreateAuditEntry("dhcp6_shared_network", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1403,15 +1445,18 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteSharedNetwork) {
// database when the modification time is earlier than the last
// fetched audit entry.
TEST_F(CBControlDHCPv6Test, databaseConfigApplySharedNetworkNotFetched) {
addCreateAuditEntry("dhcp6_shared_network");
addCreateAuditEntry("dhcp6_shared_network", 1);
addCreateAuditEntry("dhcp6_shared_network", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
// This test verifies that only a subnet is merged into the current
// configuration.
TEST_F(CBControlDHCPv6Test, databaseConfigApplySubnet) {
addCreateAuditEntry("dhcp6_shared_network");
addCreateAuditEntry("dhcp6_subnet");
addCreateAuditEntry("dhcp6_shared_network", 1);
addCreateAuditEntry("dhcp6_shared_network", 2);
addCreateAuditEntry("dhcp6_subnet", 1);
addCreateAuditEntry("dhcp6_subnet", 2);
testDatabaseConfigApply(getTimestamp(-5));
}
......@@ -1427,7 +1472,8 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyDeleteSubnet) {
// when the modification time is earlier than the last fetched audit
// entry.
TEST_F(CBControlDHCPv6Test, databaseConfigApplySubnetNotFetched) {
addCreateAuditEntry("dhcp6_subnet");
addCreateAuditEntry("dhcp6_subnet", 1);
addCreateAuditEntry("dhcp6_subnet", 2);
testDatabaseConfigApply(getTimestamp(-3));
}
......@@ -1442,11 +1488,16 @@ TEST_F(CBControlDHCPv6Test, databaseConfigApplyHook) {
"cb6_updated", cb6_updated_callout));
// Create audit entries.
addCreateAuditEntry("dhcp6_global_parameter");
addCreateAuditEntry("dhcp6_option_def");
addCreateAuditEntry("dhcp6_options");
addCreateAuditEntry("dhcp6_shared_network");
addCreateAuditEntry("dhcp6_subnet");
addCreateAuditEntry("dhcp6_global_parameter", 1);
addCreateAuditEntry("dhcp6_global_parameter", 2);
addCreateAuditEntry("dhcp6_option_def", 1);
addCreateAuditEntry("dhcp6_option_def", 2);
addCreateAuditEntry("dhcp6_options", 1);
addCreateAuditEntry("dhcp6_options", 2);
addCreateAuditEntry("dhcp6_shared_network", 1);