]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1790] added UTs
authorRazvan Becheriu <razvan@isc.org>
Thu, 25 Jan 2024 11:35:39 +0000 (13:35 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 26 Jan 2024 12:19:54 +0000 (14:19 +0200)
src/bin/dhcp4/tests/config_backend_unittest.cc
src/bin/dhcp6/tests/config_backend_unittest.cc
src/lib/dhcpsrv/testutils/generic_backend_unittest.cc

index 82fe4545f16bbb63c481a0321479e13a4de488df..c71b48ee68a5cfc2ffa2d2eb8ef92a75c4cf26d3 100644 (file)
@@ -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
index 52fae459b5324c73cd07cc11611f7d6092c6ce76..2834c5f8716aa53061d59b6eb234008aa8b7c6b9 100644 (file)
@@ -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(
index 462dbdfa09cb8e4e29ff53cc34829ddeddfe506c..ff3f6914a300194f3da97c5dcaf50213b3ad12fb 100644 (file)
@@ -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,