2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-28 20:47:48 +00:00

[#3770] addressed review comments

This commit is contained in:
Razvan Becheriu 2025-07-21 18:08:25 +03:00
parent 2737bc502f
commit b11ab95eab
14 changed files with 38 additions and 49 deletions

View File

@ -1889,7 +1889,7 @@ SET @disable_audit = 0"
# Check upgrade from 29.0 to 30.0. # Check upgrade from 29.0 to 30.0.
mysql_upgrade_29_to_30_test 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 mysql_upgrade_30_to_31_test
# Let's wipe the whole database # Let's wipe the whole database
@ -3994,7 +3994,7 @@ mysql_migrate_client_class_test() {
# Verifies migration of dhcpX_options.client_classes column to not null. # Verifies migration of dhcpX_options.client_classes column to not null.
mysql_migrate_dhcpX_options_client_classes() { 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 # Let's wipe the whole database
mysql_wipe mysql_wipe
@ -4031,6 +4031,7 @@ mysql_migrate_dhcpX_options_client_classes() {
# Verify the inserted record counts. # Verify the inserted record counts.
qry="select count(*) from dhcp4_options;" qry="select count(*) from dhcp4_options;"
run_statement "#get 4_option_count before update" "$qry" 2 run_statement "#get 4_option_count before update" "$qry" 2
qry="select count(*) from dhcp6_options;" qry="select count(*) from dhcp6_options;"
run_statement "#get 6_option_count before update" "$qry" 2 run_statement "#get 6_option_count before update" "$qry" 2

View File

@ -562,7 +562,7 @@ MySqlConfigBackendImpl::getOption(const int index,
const ServerSelector& server_selector, const ServerSelector& server_selector,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes) { const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
if (server_selector.amUnassigned()) { if (server_selector.amUnassigned()) {
isc_throw(NotImplemented, "managing configuration for no particular server" isc_throw(NotImplemented, "managing configuration for no particular server"
@ -581,7 +581,7 @@ MySqlConfigBackendImpl::getOption(const int index,
} }
in_bindings.push_back(MySqlBinding::createString(space)); 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) { if (universe == Option::V4) {
in_bindings.push_back(createClientClassesForWhereClause(client_classes)); in_bindings.push_back(createClientClassesForWhereClause(client_classes));
} }

View File

@ -973,7 +973,7 @@ private:
user_context.assign(user_context_); user_context.assign(user_context_);
} }
// Convert clietn classes to string. // Convert client classes to string.
std::string client_classes; std::string client_classes;
if (client_classes_null_ == MLM_FALSE) { if (client_classes_null_ == MLM_FALSE) {
client_classes_[client_classes_length_] = '\0'; client_classes_[client_classes_length_] = '\0';

View File

@ -507,10 +507,8 @@ public:
/// @return Number of deleted options. /// @return Number of deleted options.
/// @throw NotImplemented if server selector is "unassigned". /// @throw NotImplemented if server selector is "unassigned".
virtual uint64_t virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector, deleteOption4(const db::ServerSelector& server_selector, const SubnetID& subnet_id,
const SubnetID& subnet_id, const uint16_t code, const std::string& space,
const uint16_t code,
const std::string& space,
const ClientClassesPtr client_classes = ClientClassesPtr()); const ClientClassesPtr client_classes = ClientClassesPtr());
/// @brief Deletes pool level option. /// @brief Deletes pool level option.

View File

@ -548,8 +548,7 @@ PgSqlConfigBackendImpl::getOption(const int index,
const ServerSelector& server_selector, const ServerSelector& server_selector,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
/* = ClientClassesPtr() */) {
if (server_selector.amUnassigned()) { if (server_selector.amUnassigned()) {
isc_throw(NotImplemented, "managing configuration for no particular server" isc_throw(NotImplemented, "managing configuration for no particular server"
" (unassigned) is unsupported at the moment"); " (unassigned) is unsupported at the moment");

View File

@ -645,8 +645,7 @@ public:
/// @param bindings PsqlBindArray to which the option value should be added. /// @param bindings PsqlBindArray to which the option value should be added.
/// @param client_classes ClientClasses collection containing the class names. /// @param client_classes ClientClasses collection containing the class names.
void addClientClassesForWhereClause(db::PsqlBindArray& bindings, void addClientClassesForWhereClause(db::PsqlBindArray& bindings,
const ClientClassesPtr client_classes const ClientClassesPtr client_classes = ClientClassesPtr());
= ClientClassesPtr());
/// @brief Iterates over the class names in a JSON list element at a /// @brief Iterates over the class names in a JSON list element at a
/// given column, adding each name to the given ClientClasses instance. /// given column, adding each name to the given ClientClasses instance.

View File

@ -139,8 +139,7 @@ ConfigBackendPoolDHCPv4::getOption4(const BackendSelector& backend_selector,
const ServerSelector& server_selector, const ServerSelector& server_selector,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes const ClientClassesPtr client_classes /* = ClientClassesPtr() */) const {
/* = ClientClassesPtr */) const {
OptionDescriptorPtr option; OptionDescriptorPtr option;
getPropertyPtrConst<OptionDescriptorPtr, uint16_t, const std::string&> getPropertyPtrConst<OptionDescriptorPtr, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::getOption4, backend_selector, server_selector, (&ConfigBackendDHCPv4::getOption4, backend_selector, server_selector,
@ -434,7 +433,7 @@ ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
const ServerSelector& server_selector, const ServerSelector& server_selector,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes /* = ClientClassesPtr */) { const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, uint16_t, const std::string&> return (createUpdateDeleteProperty<uint64_t, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector, (&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
@ -447,7 +446,7 @@ ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
const std::string& shared_network_name, const std::string& shared_network_name,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes /* = ClientClassesPtr */) { const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, const std::string&, uint16_t, return (createUpdateDeleteProperty<uint64_t, const std::string&, uint16_t,
const std::string&> const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector, (&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
@ -460,7 +459,7 @@ ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
const SubnetID& subnet_id, const SubnetID& subnet_id,
const uint16_t code, const uint16_t code,
const std::string& space, 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&> return (createUpdateDeleteProperty<uint64_t, const SubnetID&, uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector, (&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,
subnet_id, code, space, client_classes)); subnet_id, code, space, client_classes));
@ -473,7 +472,7 @@ ConfigBackendPoolDHCPv4::deleteOption4(const BackendSelector& backend_selector,
const asiolink::IOAddress& pool_end_address, const asiolink::IOAddress& pool_end_address,
const uint16_t code, const uint16_t code,
const std::string& space, const std::string& space,
const ClientClassesPtr client_classes /* = ClientClassesPtr */) { const ClientClassesPtr client_classes /* = ClientClassesPtr() */) {
return (createUpdateDeleteProperty<uint64_t, const IOAddress&, const IOAddress&, return (createUpdateDeleteProperty<uint64_t, const IOAddress&, const IOAddress&,
uint16_t, const std::string&> uint16_t, const std::string&>
(&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector, (&ConfigBackendDHCPv4::deleteOption4, backend_selector, server_selector,

View File

@ -1561,7 +1561,7 @@ TEST_F(CfgOptionTest, replaceWithClientClasses) {
(boost::dynamic_pointer_cast<OptionUint16>(replacement.option_))->setValue(100); (boost::dynamic_pointer_cast<OptionUint16>(replacement.option_))->setValue(100);
ASSERT_NO_THROW(cfg.replace(replacement, DHCP6_OPTION_SPACE)); 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, OptionDescriptor found_desc = cfg.get(DHCP6_OPTION_SPACE, 777,
replacement.client_classes_); replacement.client_classes_);
ASSERT_TRUE(found_desc.option_); ASSERT_TRUE(found_desc.option_);
@ -1572,7 +1572,7 @@ TEST_F(CfgOptionTest, replaceWithClientClasses) {
(boost::dynamic_pointer_cast<OptionUint16>(replacement2.option_))->setValue(300); (boost::dynamic_pointer_cast<OptionUint16>(replacement2.option_))->setValue(300);
ASSERT_NO_THROW(cfg.replace(replacement2, DHCP6_OPTION_SPACE)); 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_); found_desc = cfg.get(DHCP6_OPTION_SPACE, 777, replacement2.client_classes_);
ASSERT_TRUE(found_desc.option_); ASSERT_TRUE(found_desc.option_);
ASSERT_EQ(found_desc, replacement2); ASSERT_EQ(found_desc, replacement2);
@ -1631,7 +1631,7 @@ TEST_F(CfgOptionTest, deleteWithClientClasses) {
ASSERT_FALSE(found_desc.option_); ASSERT_FALSE(found_desc.option_);
reference_options.pop_back(); 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_)); ASSERT_NO_THROW(cfg.del(DHCP6_OPTION_SPACE, 777, reference_options[1].client_classes_));
// Make sure we can no longer find the deleted option. // Make sure we can no longer find the deleted option.

View File

@ -150,7 +150,6 @@ GenericConfigBackendDHCPv4Test::initTestSubnets() {
subnet->getCfgOption()->add(*test_options_[1], test_options_[1]->space_name_); subnet->getCfgOption()->add(*test_options_[1], test_options_[1]->space_name_);
subnet->getCfgOption()->add(*test_options_[2], test_options_[2]->space_name_); subnet->getCfgOption()->add(*test_options_[2], test_options_[2]->space_name_);
test_subnets_.push_back(subnet); test_subnets_.push_back(subnet);
// Adding another subnet with the same subnet id to test // Adding another subnet with the same subnet id to test
@ -3688,7 +3687,7 @@ GenericConfigBackendDHCPv4Test::updateClassTaggedOptions(
} }
} }
// 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)\ #define SCOPED_OPT_COMPARE(exp_opt,test_opt)\
{\ {\
std::stringstream oss;\ std::stringstream oss;\
@ -3758,7 +3757,6 @@ GenericConfigBackendDHCPv4Test::globalOption4WithClientClassesTest() {
} }
} }
void void
GenericConfigBackendDHCPv4Test::getAllOptions4WithClientClassesTest() { GenericConfigBackendDHCPv4Test::getAllOptions4WithClientClassesTest() {
// Describes an option to create. // Describes an option to create.
@ -3819,7 +3817,7 @@ GenericConfigBackendDHCPv4Test::getAllOptions4WithClientClassesTest() {
++exp_option; ++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. // Build list of options we expect to get back.
exp_options.clear(); exp_options.clear();
exp_options.push_back(ref_options[3]); exp_options.push_back(ref_options[3]);
@ -3849,7 +3847,6 @@ GenericConfigBackendDHCPv4Test::getAllOptions4WithClientClassesTest() {
} }
} }
void void
GenericConfigBackendDHCPv4Test::createUpdateDeleteSubnetOption4Test() { GenericConfigBackendDHCPv4Test::createUpdateDeleteSubnetOption4Test() {
// Insert new subnet. // Insert new subnet.
@ -4979,7 +4976,6 @@ GenericConfigBackendDHCPv4Test::sharedNetworkOption4WithClientClassesTest() {
} }
// Now make sure that we can delete the options individually. // Now make sure that we can delete the options individually.
updateClassTaggedOptions(ref_options);
for (auto const& ref_option : ref_options) { for (auto const& ref_option : ref_options) {
ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(), ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(),
network->getName(), network->getName(),
@ -5043,7 +5039,6 @@ GenericConfigBackendDHCPv4Test::subnetOption4WithClientClassesTest() {
} }
// Now make sure that we can delete the options individually. // Now make sure that we can delete the options individually.
updateClassTaggedOptions(ref_options);
for (auto const& ref_option : ref_options) { for (auto const& ref_option : ref_options) {
ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(), ASSERT_EQ(1, cbptr_->deleteOption4(ServerSelector::ANY(),
subnet->getID(), subnet->getID(),

View File

@ -469,7 +469,6 @@ TestConfigBackendDHCPv4::getGlobalParameter4(const db::ServerSelector& server_se
return (candidate); return (candidate);
} }
StampedValueCollection StampedValueCollection
TestConfigBackendDHCPv4::getAllGlobalParameters4(const db::ServerSelector& server_selector) const { TestConfigBackendDHCPv4::getAllGlobalParameters4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags(); auto tags = server_selector.getTags();
@ -1237,7 +1236,6 @@ TestConfigBackendDHCPv4::deleteOption4(const db::ServerSelector& server_selector
} }
} }
if (!found) { if (!found) {
isc_throw(BadValue, "attempted to delete option in a " isc_throw(BadValue, "attempted to delete option in a "
"shared network " << shared_network_name "shared network " << shared_network_name

View File

@ -444,8 +444,7 @@ public:
/// Defaults to an empty pointer. /// Defaults to an empty pointer.
/// @return Number of deleted options. /// @return Number of deleted options.
virtual uint64_t virtual uint64_t
deleteOption4(const db::ServerSelector& server_selector, deleteOption4(const db::ServerSelector& server_selector, const uint16_t code,
const uint16_t code,
const std::string& space, const std::string& space,
ClientClassesPtr client_classes = ClientClassesPtr()); ClientClassesPtr client_classes = ClientClassesPtr());

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC") # # Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC") #
#
# This Source Code Form is subject to the terms of the Mozilla Public # 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 # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.