From: Francis Dupont Date: Thu, 11 Apr 2019 17:21:09 +0000 (+0200) Subject: [397-cb-implement-mysqlconfigbackenddhcpv6] checkpoint before rebase X-Git-Tag: Kea-1.6.0-beta~244 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e94c3d27b2f48b9c4de3fe5443cdb79a049eb48;p=thirdparty%2Fkea.git [397-cb-implement-mysqlconfigbackenddhcpv6] checkpoint before rebase --- diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 863bdb332e..9ccbc91d02 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -867,7 +867,7 @@ public: // Create binding for host reservation mode. MySqlBindingPtr hr_mode_binding; - auto hr_mode = subnet->getHostReservationMode(); + auto hr_mode = subnet->getHostReservationMode(Network::Inheritance::NONE); if (!hr_mode.unspecified()) { hr_mode_binding = MySqlBinding::createInteger(static_cast (hr_mode.get())); @@ -906,22 +906,22 @@ public: MySqlBindingCollection in_bindings = { MySqlBinding::createInteger(subnet->getID()), MySqlBinding::createString(subnet->toText()), - MySqlBinding::condCreateString(subnet->getClientClass()), - MySqlBinding::condCreateString(subnet->getIface()), + MySqlBinding::condCreateString(subnet->getClientClass(Network::Inheritance::NONE)), + MySqlBinding::condCreateString(subnet->getIface(Network::Inheritance::NONE)), MySqlBinding::createTimestamp(subnet->getModificationTime()), - createBinding(subnet->getPreferred()), - MySqlBinding::condCreateBool(subnet->getRapidCommit()), - createBinding(subnet->getT2()), + createBinding(subnet->getPreferred(Network::Inheritance::NONE)), + MySqlBinding::condCreateBool(subnet->getRapidCommit(Network::Inheritance::NONE)), + createBinding(subnet->getT2(Network::Inheritance::NONE)), createInputRelayBinding(subnet), - createBinding(subnet->getT1()), + createBinding(subnet->getT1(Network::Inheritance::NONE)), createInputRequiredClassesBinding(subnet), hr_mode_binding, shared_network_binding, createInputContextBinding(subnet), - createBinding(subnet->getValid()), - MySqlBinding::condCreateBool(subnet->getCalculateTeeTimes()), - MySqlBinding::condCreateFloat(subnet->getT1Percent()), - MySqlBinding::condCreateFloat(subnet->getT2Percent()) + createBinding(subnet->getValid(Network::Inheritance::NONE)), + MySqlBinding::condCreateBool(subnet->getCalculateTeeTimes(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(subnet->getT1Percent(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(subnet->getT2Percent(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); @@ -1206,6 +1206,7 @@ public: last_network_id = out_bindings[0]->getInteger(); last_network.reset(new SharedNetwork6(out_bindings[1]->getString())); + last_network->setId(last_network_id); // client_class if (!out_bindings[2]->amNull()) { @@ -1405,7 +1406,7 @@ public: // Create binding for host reservation mode. MySqlBindingPtr hr_mode_binding; - auto hr_mode = shared_network->getHostReservationMode(); + auto hr_mode = shared_network->getHostReservationMode(Network::Inheritance::NONE); if (!hr_mode.unspecified()) { hr_mode_binding = MySqlBinding::createInteger(static_cast (hr_mode.get())); @@ -1415,21 +1416,21 @@ public: MySqlBindingCollection in_bindings = { MySqlBinding::createString(shared_network->getName()), - MySqlBinding::condCreateString(shared_network->getClientClass()), - MySqlBinding::condCreateString(shared_network->getIface()), + MySqlBinding::condCreateString(shared_network->getClientClass(Network::Inheritance::NONE)), + MySqlBinding::condCreateString(shared_network->getIface(Network::Inheritance::NONE)), MySqlBinding::createTimestamp(shared_network->getModificationTime()), - createBinding(shared_network->getPreferred()), - MySqlBinding::condCreateBool(shared_network->getRapidCommit()), - createBinding(shared_network->getT2()), + createBinding(shared_network->getPreferred(Network::Inheritance::NONE)), + MySqlBinding::condCreateBool(shared_network->getRapidCommit(Network::Inheritance::NONE)), + createBinding(shared_network->getT2(Network::Inheritance::NONE)), createInputRelayBinding(shared_network), - createBinding(shared_network->getT1()), + createBinding(shared_network->getT1(Network::Inheritance::NONE)), createInputRequiredClassesBinding(shared_network), hr_mode_binding, createInputContextBinding(shared_network), - createBinding(shared_network->getValid()), - MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes()), - MySqlBinding::condCreateFloat(shared_network->getT1Percent()), - MySqlBinding::condCreateFloat(shared_network->getT2Percent()) + createBinding(shared_network->getValid(Network::Inheritance::NONE)), + MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(shared_network->getT1Percent(Network::Inheritance::NONE)), + MySqlBinding::condCreateFloat(shared_network->getT2Percent(Network::Inheritance::NONE)) }; MySqlTransaction transaction(conn_); diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc index aacec305a3..2bf3ccbe75 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc @@ -702,8 +702,17 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getSubnet6) { // Test that the information about unspecified optional parameters gets // propagated to the database. TEST_F(MySqlConfigBackendDHCPv6Test, getSubnet6WithOptionalUnspecified) { - // Insert new subnet. + // Create a subnet and wrap it within a shared network. It is important + // to have the shared network to verify that the subnet doesn't inherit + // the values of the shared network but stores the NULL values in the + // for those parameters that are unspecified on the subnet level. Subnet6Ptr subnet = test_subnets_[2]; + SharedNetwork6Ptr shared_network = test_networks_[0]; + shared_network->add(subnet); + + // Need to add the shared network to the database because otherwise + // the subnet foreign key would fail. + cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), shared_network); cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet); // Fetch this subnet by subnet identifier. @@ -1009,6 +1018,8 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getSharedNetwork6) { test_networks_[0]->getName()); ASSERT_TRUE(returned_network); + EXPECT_GT(returned_network->getId(), 0); + // The easiest way to verify whether the returned shared network matches the // inserted shared network is to convert both to text. EXPECT_EQ(shared_network->toElement()->str(), @@ -1274,6 +1285,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getOptionDef6) { test_option_defs_[0]->getCode(), test_option_defs_[0]->getOptionSpaceName()); ASSERT_TRUE(returned_option_def); + EXPECT_GT(returned_option_def->getId(), 0); EXPECT_TRUE(returned_option_def->equals(*option_def)); @@ -1541,6 +1553,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getAllOptions6) { auto option0 = index.find(test_options_[0]->option_->getType()); ASSERT_FALSE(option0 == index.end()); testOptionsEquivalent(*test_options_[0], *option0); + EXPECT_GT(option0->getId(), 0); } { @@ -1548,6 +1561,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getAllOptions6) { auto option1 = index.find(test_options_[1]->option_->getType()); ASSERT_FALSE(option1 == index.end()); testOptionsEquivalent(*test_options_[1], *option1); + EXPECT_GT(option1->getId(), 0); } { @@ -1555,6 +1569,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getAllOptions6) { auto option5 = index.find(test_options_[5]->option_->getType()); ASSERT_FALSE(option5 == index.end()); testOptionsEquivalent(*test_options_[5], *option5); + EXPECT_GT(option5->getId(), 0); } } @@ -1632,6 +1647,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeleteSubnetOption6) { { SCOPED_TRACE("verify returned option"); testOptionsEquivalent(*opt_posix_timezone, returned_opt_posix_timezone); + EXPECT_GT(returned_opt_posix_timezone.getId(), 0); } { @@ -1735,6 +1751,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeletePoolOption6) { { SCOPED_TRACE("verify returned pool option"); testOptionsEquivalent(*opt_posix_timezone, returned_opt_posix_timezone); + EXPECT_GT(returned_opt_posix_timezone.getId(), 0); } { @@ -1860,6 +1877,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeletePdPoolOption6) { { SCOPED_TRACE("verify returned pool option"); testOptionsEquivalent(*opt_posix_timezone, returned_opt_posix_timezone); + EXPECT_GT(returned_opt_posix_timezone.getId(), 0); } { @@ -1978,6 +1996,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeleteSharedNetworkOption6) { { SCOPED_TRACE("verify returned option"); testOptionsEquivalent(*opt_posix_timezone, returned_opt_posix_timezone); + EXPECT_GT(returned_opt_posix_timezone.getId(), 0); } {