Skip to content

Commit 48a4661

Browse files
author
Razvan Becheriu
committed
[#1790] added UTs
1 parent e6d1fd5 commit 48a4661

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/bin/dhcp4/tests/config_backend_unittest.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) {
192192
StampedValuePtr calc_tee_times(new StampedValue("calculate-tee-times", Element::create(bool(false))));
193193
StampedValuePtr t2_percent(new StampedValue("t2-percent", Element::create(0.75)));
194194
StampedValuePtr renew_timer(new StampedValue("renew-timer", Element::create(500)));
195+
StampedValuePtr mt_enabled(new StampedValue("multi-threading/enable-multi-threading", Element::create(true)));
196+
StampedValuePtr mt_pool_size(new StampedValue("multi-threading/thread-pool-size", Element::create(256)));
195197

196198
// Let's add all of the globals to the second backend. This will verify
197199
// we find them there.
@@ -200,6 +202,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) {
200202
db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), calc_tee_times);
201203
db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), t2_percent);
202204
db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), renew_timer);
205+
db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), mt_enabled);
206+
db2_->createUpdateGlobalParameter4(ServerSelector::ALL(), mt_pool_size);
203207

204208
// Should parse and merge without error.
205209
ASSERT_NO_FATAL_FAILURE(configure(base_config, CONTROL_RESULT_SUCCESS, ""));
@@ -227,6 +231,8 @@ TEST_F(Dhcp4CBTest, mergeGlobals) {
227231
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, calc_tee_times));
228232
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, t2_percent));
229233
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, renew_timer));
234+
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_enabled));
235+
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_pool_size));
230236
}
231237

232238
// This test verifies that externally configured option definitions

src/bin/dhcp6/tests/config_backend_unittest.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,16 @@ TEST_F(Dhcp6CBTest, mergeGlobals) {
192192
StampedValuePtr server_tag(new StampedValue("server-tag", "second-server"));
193193
StampedValuePtr decline_period(new StampedValue("decline-probation-period", Element::create(86400)));
194194
StampedValuePtr renew_timer(new StampedValue("renew-timer", Element::create(500)));
195+
StampedValuePtr mt_enabled(new StampedValue("multi-threading/enable-multi-threading", Element::create(true)));
196+
StampedValuePtr mt_pool_size(new StampedValue("multi-threading/thread-pool-size", Element::create(256)));
195197

196198
// Let's add all of the globals to the second backend. This will verify
197199
// we find them there.
198200
db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), server_tag);
199201
db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), decline_period);
200202
db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), renew_timer);
203+
db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), mt_enabled);
204+
db2_->createUpdateGlobalParameter6(ServerSelector::ALL(), mt_pool_size);
201205

202206
// Should parse and merge without error.
203207
ASSERT_NO_FATAL_FAILURE(configure(base_config, CONTROL_RESULT_SUCCESS, ""));
@@ -219,6 +223,8 @@ TEST_F(Dhcp6CBTest, mergeGlobals) {
219223
// Verify that the implicit globals from the backend are there.
220224
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, server_tag));
221225
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, renew_timer));
226+
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_enabled));
227+
ASSERT_NO_FATAL_FAILURE(checkConfiguredGlobal(staging_cfg, mt_pool_size));
222228
}
223229

224230
// This test verifies that externally configured option definitions
@@ -319,7 +325,6 @@ TEST_F(Dhcp6CBTest, mergeOptions) {
319325
" } \n"
320326
"} \n";
321327

322-
323328
OptionDescriptorPtr opt;
324329
// Add solmax-rt to the first backend.
325330
opt.reset(new OptionDescriptor(

src/lib/dhcpsrv/testutils/generic_backend_unittest.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,25 @@ GenericBackendTest::checkConfiguredGlobal(const SrvConfigPtr& srv_cfg,
115115
const std::string &name,
116116
ConstElementPtr exp_value) {
117117
ConstCfgGlobalsPtr globals = srv_cfg->getConfiguredGlobals();
118-
ConstElementPtr found_global = globals->get(name);
118+
std::string name_elem = name;
119+
std::string sub_elem;
120+
auto pos = name_elem.find('/');
121+
if (pos != std::string::npos) {
122+
sub_elem = name_elem.substr(pos + 1);
123+
name_elem = name_elem.substr(0, pos);
124+
}
125+
126+
ConstElementPtr found_global = globals->get(name_elem);
119127
ASSERT_TRUE(found_global) << "expected global: "
120-
<< name << " not found";
128+
<< name_elem << " not found";
129+
130+
if (!sub_elem.empty()) {
131+
ASSERT_EQ(Element::map, found_global->getType())
132+
<< "expected global: " << name_elem << " has wrong type";
133+
found_global = found_global->get(sub_elem);
134+
ASSERT_TRUE(found_global) << "expected global: "
135+
<< name << " not found";
136+
}
121137

122138
ASSERT_EQ(exp_value->getType(), found_global->getType())
123139
<< "expected global: " << name << " has wrong type";
@@ -132,7 +148,6 @@ GenericBackendTest::checkConfiguredGlobal(const SrvConfigPtr& srv_cfg,
132148
checkConfiguredGlobal(srv_cfg, exp_global->getName(), exp_global->getElementValue());
133149
}
134150

135-
136151
void
137152
GenericBackendTest::testNewAuditEntry(const std::string& exp_object_type,
138153
const AuditEntry::ModificationType& exp_modification_type,

0 commit comments

Comments
 (0)