]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[397-cb-implement-mysqlconfigbackenddhcpv6] checkpoint before rebase
authorFrancis Dupont <fdupont@isc.org>
Thu, 11 Apr 2019 17:21:09 +0000 (19:21 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 18 Apr 2019 13:52:51 +0000 (15:52 +0200)
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc

index 863bdb332ecd26ff1c39c04843c6cf9c7f55fff0..9ccbc91d02ce45c915520573def7c5de72143869 100644 (file)
@@ -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<uint8_t>(static_cast<uint8_t>
                                                                    (hr_mode.get()));
@@ -906,22 +906,22 @@ public:
         MySqlBindingCollection in_bindings = {
             MySqlBinding::createInteger<uint32_t>(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<uint64_t>();
                 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<uint8_t>(static_cast<uint8_t>
                                                                    (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_);
index aacec305a34ceffc439d2a2f2a279e84b5c61f4c..2bf3ccbe7535dc933ab234a39889f221066f57fb 100644 (file)
@@ -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);
     }
 
     {