2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 21:18:02 +00:00

[5357] Added test for multiple shared-networks

This commit is contained in:
Tomek Mrugalski 2017-09-13 10:52:57 +02:00
parent 86e2aac444
commit ac3a069271
2 changed files with 56 additions and 9 deletions

View File

@ -5207,11 +5207,12 @@ TEST_F(Dhcp4ParserTest, sharedNetworks3subnets) {
// This test checks if parameters are derived properly: // This test checks if parameters are derived properly:
// - global to shared network // - global to shared network
// - shared network to subnet // - shared network to subnet
// Also, it tests that more than one shared network can be defined.
TEST_F(Dhcp4ParserTest, sharedNetworksDerive) { TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
string config = "{\n" string config = "{\n"
"\"valid-lifetime\": 4, \n"
"\"rebind-timer\": 2, \n"
"\"renew-timer\": 1, \n" "\"renew-timer\": 1, \n"
"\"rebind-timer\": 2, \n"
"\"valid-lifetime\": 4, \n"
"\"shared-networks\": [ {\n" "\"shared-networks\": [ {\n"
" \"name\": \"foo\"\n," " \"name\": \"foo\"\n,"
" \"renew-timer\": 10,\n" " \"renew-timer\": 10,\n"
@ -5226,6 +5227,17 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
" \"renew-timer\": 100\n" " \"renew-timer\": 100\n"
" }\n" " }\n"
" ]\n" " ]\n"
" },\n"
"{ // second shared-network starts here\n"
" \"name\": \"bar\",\n"
" \"subnet4\": [\n"
" {\n"
" \"subnet\": \"192.0.3.0/24\",\n"
" \"pools\": [ { \"pool\": \"192.0.3.1-192.0.3.10\" } ]\n"
" }\n"
" ]\n"
" } ]\n" " } ]\n"
"} \n"; "} \n";
@ -5235,15 +5247,16 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
CfgSharedNetworks4Ptr cfg_net = CfgMgr::instance().getStagingCfg() CfgSharedNetworks4Ptr cfg_net = CfgMgr::instance().getStagingCfg()
->getCfgSharedNetworks4(); ->getCfgSharedNetworks4();
// There is expected one shared subnet. // Two shared networks are expected.
ASSERT_TRUE(cfg_net); ASSERT_TRUE(cfg_net);
const SharedNetwork4Collection* nets = cfg_net->getAll(); const SharedNetwork4Collection* nets = cfg_net->getAll();
ASSERT_TRUE(nets); ASSERT_TRUE(nets);
ASSERT_EQ(1, nets->size()); ASSERT_EQ(2, nets->size());
SharedNetwork4Ptr net = *(nets->begin()); SharedNetwork4Ptr net = nets->at(0);
ASSERT_TRUE(net); ASSERT_TRUE(net);
// The first shared network has two subnets.
const Subnet4Collection * subs = net->getAllSubnets(); const Subnet4Collection * subs = net->getAllSubnets();
ASSERT_TRUE(subs); ASSERT_TRUE(subs);
EXPECT_EQ(2, subs->size()); EXPECT_EQ(2, subs->size());
@ -5259,6 +5272,18 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
// from global scope to shared-network level and later again to // from global scope to shared-network level and later again to
// subnet4 level. // subnet4 level.
checkSubnet(*subs, "192.0.2.0/24", 100, 2, 4); checkSubnet(*subs, "192.0.2.0/24", 100, 2, 4);
// Ok, now check the second shared subnet.
net = nets->at(1);
ASSERT_TRUE(net);
subs = net->getAllSubnets();
ASSERT_TRUE(subs);
EXPECT_EQ(1, subs->size());
// This subnet should derive its renew-timer from global scope.
checkSubnet(*subs, "192.0.3.0/24", 1, 2, 4);
} }

View File

@ -5556,6 +5556,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworks3subnets) {
// This test checks if parameters are derived properly: // This test checks if parameters are derived properly:
// - global to shared network // - global to shared network
// - shared network to subnet // - shared network to subnet
// Also, it tests that more than one shared network can be defined.
TEST_F(Dhcp6ParserTest, sharedNetworksDerive) { TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
string config = "{\n" string config = "{\n"
"\"renew-timer\": 1, \n" "\"renew-timer\": 1, \n"
@ -5576,7 +5577,16 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
" \"renew-timer\": 100\n" " \"renew-timer\": 100\n"
" }\n" " }\n"
" ]\n" " ]\n"
" } ]\n" " },\n"
"{ // second shared-network starts here\n"
" \"name\": \"bar\",\n"
" \"subnet6\": [\n"
" {\n"
" \"subnet\": \"2001:db3::/48\",\n"
" \"pools\": [ { \"pool\": \"2001:db3::/64\" } ]\n"
" }\n"
" ]\n"
"} ]\n"
"} \n"; "} \n";
configure(config, CONTROL_RESULT_SUCCESS, ""); configure(config, CONTROL_RESULT_SUCCESS, "");
@ -5585,13 +5595,14 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
CfgSharedNetworks6Ptr cfg_net = CfgMgr::instance().getStagingCfg() CfgSharedNetworks6Ptr cfg_net = CfgMgr::instance().getStagingCfg()
->getCfgSharedNetworks6(); ->getCfgSharedNetworks6();
// There is expected one shared subnet. // Two shared networks are expeced.
ASSERT_TRUE(cfg_net); ASSERT_TRUE(cfg_net);
const SharedNetwork6Collection* nets = cfg_net->getAll(); const SharedNetwork6Collection* nets = cfg_net->getAll();
ASSERT_TRUE(nets); ASSERT_TRUE(nets);
ASSERT_EQ(1, nets->size()); ASSERT_EQ(2, nets->size());
SharedNetwork6Ptr net = *(nets->begin()); // Let's check the first one.
SharedNetwork6Ptr net = nets->at(0);
ASSERT_TRUE(net); ASSERT_TRUE(net);
const Subnet6Collection * subs = net->getAllSubnets(); const Subnet6Collection * subs = net->getAllSubnets();
@ -5609,6 +5620,17 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
// from global scope to shared-network level and later again to // from global scope to shared-network level and later again to
// subnet6 level. // subnet6 level.
checkSubnet(*subs, "2001:db2::/48", 100, 2, 3, 4); checkSubnet(*subs, "2001:db2::/48", 100, 2, 3, 4);
// Ok, now check the second shared subnet.
net = nets->at(1);
ASSERT_TRUE(net);
subs = net->getAllSubnets();
ASSERT_TRUE(subs);
EXPECT_EQ(1, subs->size());
// This subnet should derive its renew-timer from global scope.
checkSubnet(*subs, "2001:db3::/48", 1, 2, 3, 4);
} }
}; };