# Check upgrade from 29.0 to 30.0.
mysql_upgrade_29_to_30_test
- # Check upgrade from 29.0 to 30.0.
+ # Check upgrade from 30.0 to 31.0.
mysql_upgrade_30_to_31_test
# Let's wipe the whole database
# Verifies migration of dhcpX_options.client_classes column to not null.
mysql_migrate_dhcpX_options_client_classes() {
- test_start "mysql.mysql_migrate_dhcp4_options_client_classes"
+ test_start "mysql.mysql_migrate_dhcpX_options_client_classes"
# Let's wipe the whole database
mysql_wipe
# Verify the inserted record counts.
qry="select count(*) from dhcp4_options;"
run_statement "#get 4_option_count before update" "$qry" 2
+
qry="select count(*) from dhcp6_options;"
run_statement "#get 6_option_count before update" "$qry" 2
{ MySqlConfigBackendDHCPv4Impl::DELETE_OPTION4_SHARED_NETWORK,
MYSQL_DELETE_OPTION_NO_TAG(dhcp4,
WHERE (o.scope_id = 4 AND o.shared_network_name = ? AND o.code = ? AND o.space = ?
- AND o.client_classes LIKE ?))
+ AND o.client_classes LIKE ?))
},
// Delete options belonging to a subnet.
const ServerSelector& server_selector,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
if (server_selector.amUnassigned()) {
isc_throw(NotImplemented, "managing configuration for no particular server"
}
in_bindings.push_back(MySqlBinding::createString(space));
- /// @todo Remove the if when v6 is ready for this.
+ /// @todo TKM Remove the if when v6 is ready.
if (universe == Option::V4) {
in_bindings.push_back(createClientClassesForWhereClause(client_classes));
}
user_context.assign(user_context_);
}
- // Convert clietn classes to string.
+ // Convert client classes to string.
std::string client_classes;
if (client_classes_null_ == MLM_FALSE) {
client_classes_[client_classes_length_] = '\0';
/// @return Number of deleted options.
/// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t
- deleteOption4(const db::ServerSelector& server_selector,
- const SubnetID& subnet_id,
- const uint16_t code,
- const std::string& space,
+ deleteOption4(const db::ServerSelector& server_selector, const SubnetID& subnet_id,
+ const uint16_t code, const std::string& space,
const ClientClassesPtr client_classes = ClientClassesPtr());
/// @brief Deletes pool level option.
const ServerSelector& server_selector,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes
- /* = ClientClassesPtr() */) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
if (server_selector.amUnassigned()) {
isc_throw(NotImplemented, "managing configuration for no particular server"
" (unassigned) is unsupported at the moment");
/// @param bindings PsqlBindArray to which the option value should be added.
/// @param client_classes ClientClasses collection containing the class names.
void addClientClassesForWhereClause(db::PsqlBindArray& bindings,
- const ClientClassesPtr client_classes
- = ClientClassesPtr());
+ const ClientClassesPtr client_classes = ClientClassesPtr());
/// @brief Iterates over the class names in a JSON list element at a
/// given column, adding each name to the given ClientClasses instance.
if (od_itr == idx6.end()) {
isc_throw(isc::BadValue, "cannot replace option: "
<< option_space << ":" << desc.option_->getType()
- << " , client-classes: " << desc.client_classes_.toText()
+ << ", client-classes: " << desc.client_classes_.toText()
<< ", it does not exist");
}
}
// Indicate we replaced the definition.
- return(true);
+ return (true);
}
void
idx6.erase(range.first, range.second);
}
- return(count);
+ return (count);
}
size_t
const ServerSelector& server_selector,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes
- /* = ClientClassesPtr */) const {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) const {
OptionDescriptorPtr option;
getPropertyPtrConst<OptionDescriptorPtr, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::getOption4, backend_selector, server_selector,
const ServerSelector& server_selector,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes /* = ClientClassesPtr */) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
const std::string& shared_network_name,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes /* = ClientClassesPtr */) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, const std::string&, uint16_t,
const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
const SubnetID& subnet_id,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes /* = ClientClassesPtr */) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, const SubnetID&, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
subnet_id, code, space, client_classes));
const asiolink::IOAddress& pool_end_address,
const uint16_t code,
const std::string& space,
- const ClientClassesPtr client_classes /* = ClientClassesPtr */) {
+ const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, const IOAddress&, const IOAddress&,
uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
OptionDescriptorList list_options = cfg.getList(DHCP6_OPTION_SPACE, 777);
ASSERT_EQ(options->size(), reference_options.size());
auto reference_rdesc = reference_options.rbegin();
- for (auto &returned_desc : list_options ){
+ for (auto &returned_desc : list_options) {
ASSERT_EQ(*reference_rdesc, returned_desc);
++reference_rdesc;
}
// Verify that CfgOption::get() with client classes returns
// each one correctly.
- for (auto &reference_desc : reference_options ){
+ for (auto &reference_desc : reference_options) {
OptionDescriptor found_desc = cfg.get(DHCP6_OPTION_SPACE, 777,
- reference_desc.client_classes_);
+ reference_desc.client_classes_);
ASSERT_TRUE(found_desc.option_);
ASSERT_EQ(found_desc, reference_desc);
}
(boost::dynamic_pointer_cast<OptionUint16>(replacement.option_))->setValue(100);
ASSERT_NO_THROW(cfg.replace(replacement, DHCP6_OPTION_SPACE));
- // Make sure we can the updated option.
+ // Make sure we can get the updated option.
OptionDescriptor found_desc = cfg.get(DHCP6_OPTION_SPACE, 777,
replacement.client_classes_);
ASSERT_TRUE(found_desc.option_);
(boost::dynamic_pointer_cast<OptionUint16>(replacement2.option_))->setValue(300);
ASSERT_NO_THROW(cfg.replace(replacement2, DHCP6_OPTION_SPACE));
- // Make sure we can the updated option.
+ // Make sure we can get the updated option.
found_desc = cfg.get(DHCP6_OPTION_SPACE, 777, replacement2.client_classes_);
ASSERT_TRUE(found_desc.option_);
ASSERT_EQ(found_desc, replacement2);
ASSERT_FALSE(found_desc.option_);
reference_options.pop_back();
- // Delete the secon reference option.
+ // Delete the second reference option.
ASSERT_NO_THROW(cfg.del(DHCP6_OPTION_SPACE, 777, reference_options[1].client_classes_));
// Make sure we can no longer find the deleted option.
subnet->getCfgOption()->add(*test_options_[1], test_options_[1]->space_name_);
subnet->getCfgOption()->add(*test_options_[2], test_options_[2]->space_name_);
-
test_subnets_.push_back(subnet);
// Adding another subnet with the same subnet id to test
};
std::list<OptionDescriptorPtr> tagged_options;
- for ( auto const& opt_to_make : opts_to_make) {
+ for (auto const& opt_to_make : opts_to_make) {
OptionDescriptor desc = createOption<OptionString>(Option::V4, opt_to_make.code_,
true, false, false, opt_to_make.value_);
desc.space_name_ = DHCP4_OPTION_SPACE;
void
GenericConfigBackendDHCPv4Test::updateClassTaggedOptions(
std::list<OptionDescriptorPtr>& options) {
- for ( auto& desc : options) {
+ for (auto& desc : options) {
OptionStringPtr opt = boost::dynamic_pointer_cast<OptionString>(desc->option_);
ASSERT_TRUE(opt);
std::string new_value(opt->getValue() + std::string(".") + opt->getValue());
}
}
-// Macro the make SCOPED_TRACE around equivalance functon more compact and helpful.
+// Macro the make SCOPED_TRACE around equivalance function more compact and helpful.
#define SCOPED_OPT_COMPARE(exp_opt,test_opt)\
{\
std::stringstream oss;\
}
}
-
void
GenericConfigBackendDHCPv4Test::getAllOptions4WithClientClassesTest() {
// Describes an option to create.
// Add all of the global options.
std::vector<OptionDescriptorPtr> ref_options;
- for ( auto const& opt_to_make : opts_to_make) {
+ for (auto const& opt_to_make : opts_to_make) {
OptionDescriptor desc = createOption<OptionInt<uint32_t>>(Option::V4, opt_to_make.code_,
- true, false, false, opt_to_make.value_);
+ true, false, false, opt_to_make.value_);
desc.space_name_ = DHCP4_OPTION_SPACE;
if (!opt_to_make.cclass_.empty()) {
desc.addClientClass(opt_to_make.cclass_);
++exp_option;
}
- // Try to fetch the collection of global options for the server1.
+ // Try to fetch the collection of global options for the server2.
// Build list of options we expect to get back.
exp_options.clear();
exp_options.push_back(ref_options[3]);
}
}
-
void
GenericConfigBackendDHCPv4Test::createUpdateDeleteSubnetOption4Test() {
// Insert new subnet.
// Make a network with options.
SharedNetwork4Ptr network(new SharedNetwork4("net1"));
auto ref_options = makeClassTaggedOptions();
- for ( auto const& ref_option : ref_options) {
+ for (auto const& ref_option : ref_options) {
network->getCfgOption()->add(*ref_option, ref_option->space_name_);
}
}
// Now make sure that we can delete the options individually.
- updateClassTaggedOptions(ref_options);
for (auto const& ref_option : ref_options) {
ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(),
network->getName(),
Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24,
30, 40, 60, 1024));
auto ref_options = makeClassTaggedOptions();
- for ( auto const& ref_option : ref_options) {
+ for (auto const& ref_option : ref_options) {
subnet->getCfgOption()->add(*ref_option, ref_option->space_name_);
}
}
// Now make sure that we can delete the options individually.
- updateClassTaggedOptions(ref_options);
for (auto const& ref_option : ref_options) {
ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(),
subnet->getID(),
// Add the options to the pool.
auto ref_options = makeClassTaggedOptions();
- for ( auto const& ref_option : ref_options) {
+ for (auto const& ref_option : ref_options) {
pool->getCfgOption()->add(*ref_option, ref_option->space_name_);
}
// Make sure that CfgOption->get() with client_classes finds each ref option.
for (auto const& ref_option : ref_options) {
auto cfg_option = returned_pool->getCfgOption()->get(DHCP4_OPTION_SPACE,
- ref_option->option_->getType(),
- ref_option->client_classes_);
+ ref_option->option_->getType(),
+ ref_option->client_classes_);
SCOPED_OPT_COMPARE((*ref_option), cfg_option);
}
return (candidate);
}
-
StampedValueCollection
TestConfigBackendDHCPv4::getAllGlobalParameters4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
}
}
-
if (!found) {
isc_throw(BadValue, "attempted to delete option in a "
"shared network " << shared_network_name
/// Defaults to an empty pointer.
/// @return Number of deleted options.
virtual uint64_t
- deleteOption4(const db::ServerSelector& server_selector,
- const uint16_t code,
+ deleteOption4(const db::ServerSelector& server_selector, const uint16_t code,
const std::string& space,
ClientClassesPtr client_classes = ClientClassesPtr());
#!/bin/sh
# Copyright (C) 2025 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/.