summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6/tests
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2020-04-27 20:22:09 +0200
committerRazvan Becheriu <razvan@isc.org>2020-04-30 12:53:48 +0200
commit90a422cc9281b7cb8782c2c1fd5f556b018c82f0 (patch)
treeb1a85b9762bf45beb05aef6cc0d447e1dcc1f23f /src/bin/dhcp6/tests
parent[#1188] added unittests (diff)
downloadkea-90a422cc9281b7cb8782c2c1fd5f556b018c82f0.tar.xz
kea-90a422cc9281b7cb8782c2c1fd5f556b018c82f0.zip
[#1188] enable multi-threading mode on config parse and added unittests
Diffstat (limited to 'src/bin/dhcp6/tests')
-rw-r--r--src/bin/dhcp6/tests/config_parser_unittest.cc84
1 files changed, 80 insertions, 4 deletions
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index a0c79bb8a2..4c998d6bb8 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -4213,7 +4213,8 @@ TEST_F(Dhcp6ParserTest, DISABLED_stdOptionDataEncapsulate) {
// Helper function to return a configuration containing an arbitrary number
// of hooks libraries.
std::string
-buildHooksLibrariesConfig(const std::vector<std::string>& libraries) {
+buildHooksLibrariesConfig(const std::vector<std::string>& libraries,
+ bool multi_threading) {
const string lbrace("{");
const string rbrace("}");
const string liblabel("\"library\": ");
@@ -4258,8 +4259,17 @@ buildHooksLibrariesConfig(const std::vector<std::string>& libraries) {
" \"code\": 111,"
" \"type\": \"ipv4-address\","
" \"space\": \"vendor-opts-space\""
- " } ]"
- "}");
+ " } ]");
+
+ if (multi_threading) {
+ config += string(
+ ","
+ "\"multi-threading\": {"
+ " \"enable-multi-threading\": true"
+ "}");
+ }
+
+ config += string("}");
return (config);
}
@@ -4276,7 +4286,7 @@ buildHooksLibrariesConfig(const char* library1 = NULL,
libraries.push_back(string(library2));
}
}
- return (buildHooksLibrariesConfig(libraries));
+ return (buildHooksLibrariesConfig(libraries, false));
}
// The goal of this test is to verify the configuration of hooks libraries if
@@ -4345,9 +4355,75 @@ TEST_F(Dhcp6ParserTest, LibrariesSpecified) {
// Expect the hooks system to say that none are loaded.
libraries = HooksManager::getLibraryNames();
EXPECT_TRUE(libraries.empty());
+}
+
+// Verify the configuration of hooks libraries which are not compatible with
+// multi threading is rejected.
+TEST_F(Dhcp6ParserTest, IncompatibleLibrary1Specified) {
+ // Marker files should not be present.
+ EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
+ EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
+
+ std::vector<std::string> libraries;
+ libraries.push_back(string(CALLOUT_LIBRARY_2));
+
+ // Set up the configuration with two libraries and load them.
+ string config = buildHooksLibrariesConfig(libraries, true);
+ ConstElementPtr json;
+ ASSERT_NO_THROW(json = parseDHCP6(config));
+ ConstElementPtr status;
+ ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
+
+ // The status object must not be NULL
+ ASSERT_TRUE(status);
+
+ // Returned value should not be 0
+ comment_ = parseAnswer(rcode_, status);
+ EXPECT_NE(0, rcode_);
+ // Expect the library to be rejected by the server (no load marker file, no
+ // unload marker file).
+ EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
+ EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
+
+ // Expect the hooks system to say that none are loaded.
+ libraries = HooksManager::getLibraryNames();
+ EXPECT_TRUE(libraries.empty());
}
+// Verify the configuration of hooks libraries which are not compatible with
+// multi threading is rejected.
+TEST_F(Dhcp6ParserTest, IncompatibleLibrary2Specified) {
+ // Marker files should not be present.
+ EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
+ EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
+
+ std::vector<std::string> libraries;
+ libraries.push_back(string(CALLOUT_LIBRARY_3));
+
+ // Set up the configuration with two libraries and load them.
+ string config = buildHooksLibrariesConfig(libraries, true);
+ ConstElementPtr json;
+ ASSERT_NO_THROW(json = parseDHCP6(config));
+ ConstElementPtr status;
+ ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
+
+ // The status object must not be NULL
+ ASSERT_TRUE(status);
+
+ // Returned value should not be 0
+ comment_ = parseAnswer(rcode_, status);
+ EXPECT_NE(0, rcode_);
+
+ // Expect the library to be rejected by the server (no load marker file, no
+ // unload marker file).
+ EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
+ EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
+
+ // Expect the hooks system to say that none are loaded.
+ libraries = HooksManager::getLibraryNames();
+ EXPECT_TRUE(libraries.empty());
+}
// This test verifies that it is possible to select subset of interfaces on
// which server should listen.
TEST_F(Dhcp6ParserTest, selectedInterfaces) {