From: Razvan Becheriu Date: Thu, 25 Jan 2024 11:35:39 +0000 (+0200) Subject: [#1790] added UTs X-Git-Tag: Kea-2.5.5~12 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=48a4661d3608deb6aaddd109d1427ff342160937;p=thirdparty%2Fkea.git [#1790] added UTs --- diff --git a/src/bin/dhcp4/tests/config_backend_unittest.cc b/src/bin/dhcp4/tests/config_backend_unittest.cc index 82fe4545f1..c71b48ee68 100644 --- a/src/bin/dhcp4/tests/config_backend_unittest.cc +++ b/src/bin/dhcp4/tests/config_backend_unittest.cc @@ -192,6 +192,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) { StampedValuePtr calc_tee_times(new StampedValue("calculate-tee-times", Element::create(bool(false)))); StampedValuePtr t2_percent(new StampedValue("t2-percent", Element::create(0.75))); StampedValuePtr renew_timer(new StampedValue("renew-timer", Element::create(500))); + StampedValuePtr mt_enabled(new StampedValue("multi-threading/enable-multi-threading", Element::create(true))); + StampedValuePtr mt_pool_size(new StampedValue("multi-threading/thread-pool-size", Element::create(256))); // Let's add all of the globals to the second backend. This will verify // we find them there. @@ -200,6 +202,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) { db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), calc_tee_times); db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), t2_percent); db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), renew_timer); + db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), mt_enabled); + db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), mt_pool_size); // Should parse and merge without error. ASSERT_NO_FATAL_FAILURE(configure(base_config, CONTROL_RESULT_SUCCESS, "")); @@ -227,6 +231,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) { ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, calc_tee_times)); ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, t2_percent)); ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, renew_timer)); + ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_enabled)); + ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_pool_size)); } // This test verifies that externally configured option definitions diff --git a/src/bin/dhcp6/tests/config_backend_unittest.cc b/src/bin/dhcp6/tests/config_backend_unittest.cc index 52fae459b5..2834c5f871 100644 --- a/src/bin/dhcp6/tests/config_backend_unittest.cc +++ b/src/bin/dhcp6/tests/config_backend_unittest.cc @@ -192,12 +192,16 @@ TEST_F(Dhcp6CBTest, mergeGlobals) { StampedValuePtr server_tag(new StampedValue("server-tag", "second-server")); StampedValuePtr decline_period(new StampedValue("decline-probation-period", Element::create(86400))); StampedValuePtr renew_timer(new StampedValue("renew-timer", Element::create(500))); + StampedValuePtr mt_enabled(new StampedValue("multi-threading/enable-multi-threading", Element::create(true))); + StampedValuePtr mt_pool_size(new StampedValue("multi-threading/thread-pool-size", Element::create(256))); // Let's add all of the globals to the second backend. This will verify // we find them there. db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), server_tag); db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), decline_period); db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), renew_timer); + db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), mt_enabled); + db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), mt_pool_size); // Should parse and merge without error. ASSERT_NO_FATAL_FAILURE(configure(base_config, CONTROL_RESULT_SUCCESS, "")); @@ -219,6 +223,8 @@ TEST_F(Dhcp6CBTest, mergeGlobals) { // Verify that the implicit globals from the backend are there. ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, server_tag)); ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, renew_timer)); + ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_enabled)); + ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_pool_size)); } // This test verifies that externally configured option definitions @@ -319,7 +325,6 @@ TEST_F(Dhcp6CBTest, mergeOptions) { " } \n" "} \n"; - OptionDescriptorPtr opt; // Add solmax-rt to the first backend. opt.reset(new OptionDescriptor( diff --git a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc index 462dbdfa09..ff3f6914a3 100644 --- a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc @@ -115,9 +115,25 @@ GenericBackendTest::checkConfiguredGlobal(const SrvConfigPtr& srv_cfg, const std::string &name, ConstElementPtr exp_value) { ConstCfgGlobalsPtr globals = srv_cfg->getConfiguredGlobals(); - ConstElementPtr found_global = globals->get(name); + std::string name_elem = name; + std::string sub_elem; + auto pos = name_elem.find('/'); + if (pos != std::string::npos) { + sub_elem = name_elem.substr(pos + 1); + name_elem = name_elem.substr(0, pos); + } + + ConstElementPtr found_global = globals->get(name_elem); ASSERT_TRUE(found_global) << "expected global: " - << name << " not found"; + << name_elem << " not found"; + + if (!sub_elem.empty()) { + ASSERT_EQ(Element::map, found_global->getType()) + << "expected global: " << name_elem << " has wrong type"; + found_global = found_global->get(sub_elem); + ASSERT_TRUE(found_global) << "expected global: " + << name << " not found"; + } ASSERT_EQ(exp_value->getType(), found_global->getType()) << "expected global: " << name << " has wrong type"; @@ -132,7 +148,6 @@ GenericBackendTest::checkConfiguredGlobal(const SrvConfigPtr& srv_cfg, checkConfiguredGlobal(srv_cfg, exp_global->getName(), exp_global->getElementValue()); } - void GenericBackendTest::testNewAuditEntry(const std::string& exp_object_type, const AuditEntry::ModificationType& exp_modification_type,