]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1418] Finished rebase, did CB
authorFrancis Dupont <fdupont@isc.org>
Wed, 18 Nov 2020 23:49:20 +0000 (00:49 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 11 Jan 2021 15:05:46 +0000 (16:05 +0100)
src/bin/admin/tests/mysql_tests.sh.in
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_9.4_to_9.5.sh.in

index ee348f0c6756d5939f2041ba27e5ca1b0705023c..a6444078c0f625d392f749914f7994721d8c355b 100644 (file)
@@ -809,6 +809,22 @@ insert into hosts(dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, ipv4_a
     count=$(echo "${OUTPUT}" | grep -Fci reservation) || true
     assert_eq 0 "${count}" "dhcp6_subnet has still reservation_mode column. (returned count %d, expected %d)"
 
+    # table: dhcp4_shared_network new cache_threshold and cache_max_age columns
+    qry="select cache_threshold, cache_max_age from dhcp4_shared_network"
+    run_statement "dhcp4_shared_network" "$qry"
+
+    # table: dhcp4_subnet new cache_threshold and cache_max_age columns
+    qry="select cache_threshold, cache_max_age from dhcp4_subnet"
+    run_statement "dhcp4_shared_network" "$qry"
+
+    # table: dhcp6_shared_network new cache_threshold and cache_max_age columns
+    qry="select cache_threshold, cache_max_age from dhcp6_shared_network"
+    run_statement "dhcp6_shared_network" "$qry"
+
+    # table: dhcp6_subnet new cache_threshold and cache_max_age columns
+    qry="select cache_threshold, cache_max_age from dhcp6_subnet"
+    run_statement "dhcp6_shared_network" "$qry"
+
     # Verify upgraded schema reports version 9.5
     version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
     assert_str_eq "9.5" "${version}" "Expected kea-admin to return %s, returned value was %s"
index c0ff04d9543f77b41ff6142d5fa989ef3a7bfd6a..4a0bfaa4db2fca1b63e03625fca8f354003eeb61 100644 (file)
@@ -326,6 +326,8 @@ public:
             MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix
             MySqlBinding::createInteger<uint8_t>(), // reservations_in_subnet
             MySqlBinding::createInteger<uint8_t>(), // reservations_out_of_pool
+            MySqlBinding::createInteger<float>(), // cache_threshold
+            MySqlBinding::createInteger<uint32_t>(), // cache_max_age
             MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
         };
 
@@ -574,7 +576,17 @@ public:
                     last_subnet->setReservationsOutOfPool(out_bindings[65]->getBool());
                 }
 
-                // server_tag at 66.
+                // cache_threshold at 66.
+                if (!out_bindings[66]->amNull()) {
+                    last_subnet->setCacheThreshold(out_bindings[66]->getFloat());
+                }
+
+                // cache_max_age at 67.
+                if (!out_bindings[67]->amNull()) {
+                    last_subnet->setCacheMaxAge(out_bindings[67]->getInteger<uint32_t>());
+                }
+
+                // server_tag at 68.
 
                 // Subnet ready. Add it to the list.
                 auto ret = subnets.insert(last_subnet);
@@ -587,10 +599,10 @@ public:
                 }
             }
 
-            // Check for new server tags at 66.
-            if (!out_bindings[66]->amNull() &&
-                (last_tag != out_bindings[66]->getString())) {
-                last_tag = out_bindings[66]->getString();
+            // Check for new server tags at 68.
+            if (!out_bindings[68]->amNull() &&
+                (last_tag != out_bindings[68]->getString())) {
+                last_tag = out_bindings[68]->getString();
                 if (!last_tag.empty() && !last_subnet->hasServerTag(ServerTag(last_tag))) {
                     last_subnet->setServerTag(last_tag);
                 }
@@ -1067,7 +1079,9 @@ public:
             MySqlBinding::condCreateString(subnet->getDdnsGeneratedPrefix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateString(subnet->getDdnsQualifyingSuffix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateBool(subnet->getReservationsInSubnet(Network::Inheritance::NONE)),
-            MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE))
+            MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)),
+            MySqlBinding::condCreateFloat(subnet->getCacheThreshold(Network::Inheritance::NONE)),
+            condCreateInteger<uint32_t>(subnet->getCacheMaxAge(Network::Inheritance::NONE))
         };
 
         MySqlTransaction transaction(conn_);
@@ -1315,6 +1329,8 @@ public:
             MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix
             MySqlBinding::createInteger<uint8_t>(), // reservations_in_subnet
             MySqlBinding::createInteger<uint8_t>(), // reservations_out_of_pool
+            MySqlBinding::createInteger<float>(), // cache_threshold
+            MySqlBinding::createInteger<uint32_t>(), // cache_max_age
             MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
         };
 
@@ -1511,7 +1527,17 @@ public:
                     last_network->setReservationsOutOfPool(out_bindings[41]->getBool());
                 }
 
-                // server_tag at 42.
+                // cache_threshold at 42.
+                if (!out_bindings[42]->amNull()) {
+                    last_network->setCacheThreshold(out_bindings[42]->getFloat());
+                }
+
+                // cache_max_age at 43.
+                if (!out_bindings[43]->amNull()) {
+                    last_network->setCacheMaxAge(out_bindings[43]->getInteger<uint32_t>());
+                }
+
+                // server_tag at 44.
 
                 // Add the shared network.
                 auto ret = shared_networks.push_back(last_network);
@@ -1525,9 +1551,9 @@ public:
             }
 
             // Check for new server tags.
-            if (!out_bindings[42]->amNull() &&
-                (last_tag != out_bindings[42]->getString())) {
-                last_tag = out_bindings[42]->getString();
+            if (!out_bindings[44]->amNull() &&
+                (last_tag != out_bindings[44]->getString())) {
+                last_tag = out_bindings[44]->getString();
                 if (!last_tag.empty() && !last_network->hasServerTag(ServerTag(last_tag))) {
                     last_network->setServerTag(last_tag);
                 }
@@ -1682,7 +1708,9 @@ public:
             MySqlBinding::condCreateString(shared_network->getDdnsGeneratedPrefix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateString(shared_network->getDdnsQualifyingSuffix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateBool(shared_network->getReservationsInSubnet(Network::Inheritance::NONE)),
-            MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE))
+            MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)),
+            MySqlBinding::condCreateFloat(shared_network->getCacheThreshold(Network::Inheritance::NONE)),
+            condCreateInteger<uint32_t>(shared_network->getCacheMaxAge(Network::Inheritance::NONE))
         };
 
         MySqlTransaction transaction(conn_);
@@ -2626,9 +2654,11 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix,"
       "  ddns_qualifying_suffix,"
       "  reservations_in_subnet,"
-      "  reservations_out_of_pool"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
-      "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
+      "  reservations_out_of_pool,"
+      "  cache_threshold,"
+      "  cache_max_age"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
+      " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the subnet with a server.
     { MySqlConfigBackendDHCPv4Impl::INSERT_SUBNET4_SERVER,
@@ -2671,8 +2701,10 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix,"
       "  ddns_qualifying_suffix,"
       "  reservations_in_subnet,"
-      "  reservations_out_of_pool"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
+      "  reservations_out_of_pool,"
+      "  cache_threshold,"
+      "  cache_max_age"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
       " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the shared network with a server.
@@ -2746,7 +2778,9 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix = ?,"
       "  ddns_qualifying_suffix = ?,"
       "  reservations_in_subnet = ?,"
-      "  reservations_out_of_pool = ? "
+      "  reservations_out_of_pool = ?,"
+      "  cache_threshold = ?,"
+      "  cache_max_age = ? "
       "WHERE subnet_id = ? OR subnet_prefix = ?" },
 
     // Update existing shared network.
@@ -2780,7 +2814,9 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix = ?,"
       "  ddns_qualifying_suffix = ?,"
       "  reservations_in_subnet = ?,"
-      "  reservations_out_of_pool = ? "
+      "  reservations_out_of_pool = ?,"
+      "  cache_threshold = ?,"
+      "  cache_max_age = ? "
       "WHERE name = ?" },
 
     // Update existing option definition.
index c11f6728c9ccb49a50eef75a3844c5c93cbe5cb8..f87a2018f12488e80bc3e89c291577d13df274d4 100644 (file)
@@ -360,6 +360,8 @@ public:
             MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix
             MySqlBinding::createInteger<uint8_t>(), // reservations_in_subnet
             MySqlBinding::createInteger<uint8_t>(), // reservations_out_of_pool
+            MySqlBinding::createInteger<float>(), // cache_threshold
+            MySqlBinding::createInteger<uint32_t>(), // cache_max_age
             MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
         };
 
@@ -598,7 +600,17 @@ public:
                     last_subnet->setReservationsOutOfPool(out_bindings[88]->getBool());
                 }
 
-                // server_tag (89 / last)
+                // cache_threshold (89)
+                if (!out_bindings[89]->amNull()) {
+                    last_subnet->setCacheThreshold(out_bindings[89]->getFloat());
+                }
+
+                // cache_max_age (90)
+                if (!out_bindings[90]->amNull()) {
+                    last_subnet->setCacheMaxAge(out_bindings[90]->getInteger<uint32_t>());
+                }
+
+                // server_tag (91 / last)
 
                 // Subnet ready. Add it to the list.
                 auto ret = subnets.insert(last_subnet);
@@ -612,9 +624,9 @@ public:
             }
 
             // Check for new server tags.
-            if (!out_bindings[89]->amNull() &&
-                (last_tag != out_bindings[89]->getString())) {
-                last_tag = out_bindings[89]->getString();
+            if (!out_bindings[91]->amNull() &&
+                (last_tag != out_bindings[91]->getString())) {
+                last_tag = out_bindings[91]->getString();
                 if (!last_tag.empty() && !last_subnet->hasServerTag(ServerTag(last_tag))) {
                     last_subnet->setServerTag(last_tag);
                 }
@@ -1316,7 +1328,9 @@ public:
             MySqlBinding::condCreateString(subnet->getDdnsGeneratedPrefix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateString(subnet->getDdnsQualifyingSuffix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateBool(subnet->getReservationsInSubnet(Network::Inheritance::NONE)),
-            MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE))
+            MySqlBinding::condCreateBool(subnet->getReservationsOutOfPool(Network::Inheritance::NONE)),
+            MySqlBinding::condCreateFloat(subnet->getCacheThreshold(Network::Inheritance::NONE)),
+            condCreateInteger<uint32_t>(subnet->getCacheMaxAge(Network::Inheritance::NONE))
         };
 
         MySqlTransaction transaction(conn_);
@@ -1640,6 +1654,8 @@ public:
             MySqlBinding::createString(DNS_NAME_BUF_LENGTH), // ddns_qualifying_suffix
             MySqlBinding::createInteger<uint8_t>(), // reservations_in_subnet
             MySqlBinding::createInteger<uint8_t>(), // reservations_out_of_pool
+            MySqlBinding::createInteger<float>(), // cache_threshold
+            MySqlBinding::createInteger<uint32_t>(), // cache_max_age
             MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
         };
 
@@ -1836,7 +1852,17 @@ public:
                     last_network->setReservationsOutOfPool(out_bindings[42]->getBool());
                 }
 
-                // server_tag at 43.
+                // cache_threshold at 43.
+                if (!out_bindings[43]->amNull()) {
+                    last_network->setCacheThreshold(out_bindings[43]->getFloat());
+                }
+
+                // cache_max_age at 44.
+                if (!out_bindings[44]->amNull()) {
+                    last_network->setCacheMaxAge(out_bindings[44]->getInteger<uint32_t>());
+                }
+
+                // server_tag at 45.
 
                 // Add the shared network.
                 auto ret = shared_networks.push_back(last_network);
@@ -1861,9 +1887,9 @@ public:
             }
 
             // Check for new server tags.
-            if (!out_bindings[43]->amNull() &&
-                (last_tag != out_bindings[43]->getString())) {
-                last_tag = out_bindings[43]->getString();
+            if (!out_bindings[45]->amNull() &&
+                (last_tag != out_bindings[45]->getString())) {
+                last_tag = out_bindings[45]->getString();
                 if (!last_tag.empty() && !last_network->hasServerTag(ServerTag(last_tag))) {
                     last_network->setServerTag(last_tag);
                 }
@@ -2018,7 +2044,9 @@ public:
             MySqlBinding::condCreateString(shared_network->getDdnsGeneratedPrefix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateString(shared_network->getDdnsQualifyingSuffix(Network::Inheritance::NONE)),
             MySqlBinding::condCreateBool(shared_network->getReservationsInSubnet(Network::Inheritance::NONE)),
-            MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE))
+            MySqlBinding::condCreateBool(shared_network->getReservationsOutOfPool(Network::Inheritance::NONE)),
+            MySqlBinding::condCreateFloat(shared_network->getCacheThreshold(Network::Inheritance::NONE)),
+            condCreateInteger<uint32_t>(shared_network->getCacheMaxAge(Network::Inheritance::NONE))
         };
 
         MySqlTransaction transaction(conn_);
@@ -3087,8 +3115,10 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix,"
       "  ddns_qualifying_suffix,"
       "  reservations_in_subnet,"
-      "  reservations_out_of_pool"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
+      "  reservations_out_of_pool,"
+      "  cache_threshold,"
+      "  cache_max_age"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
       " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the subnet with a server.
@@ -3137,8 +3167,10 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix,"
       "  ddns_qualifying_suffix,"
       "  reservations_in_subnet,"
-      "  reservations_out_of_pool"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
+      "  reservations_out_of_pool,"
+      "  cache_threshold,"
+      "  cache_max_age"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
       " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the shared network with a server.
@@ -3209,7 +3241,9 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix = ?,"
       "  ddns_qualifying_suffix = ?,"
       "  reservations_in_subnet = ?,"
-      "  reservations_out_of_pool = ? "
+      "  reservations_out_of_pool = ?,"
+      "  cache_threshold = ?,"
+      "  cache_max_age = ? "
       "WHERE subnet_id = ? OR subnet_prefix = ?" },
 
     // Update existing shared network.
@@ -3243,7 +3277,9 @@ TaggedStatementArray tagged_statements = { {
       "  ddns_generated_prefix = ?,"
       "  ddns_qualifying_suffix = ?,"
       "  reservations_in_subnet = ?,"
-      "  reservations_out_of_pool = ? "
+      "  reservations_out_of_pool = ?,"
+      "  cache_threshold = ?,"
+      "  cache_max_age = ? "
       "WHERE name = ?" },
 
     // Update existing option definition.
index 59d6bee9416ebc738f16ebae8c796e353e841e91..f07000d756a8c4e9e26692e101a11d02bdd351e1 100644 (file)
@@ -114,6 +114,21 @@ public:
     /// @brief Destructor.
     virtual ~MySqlConfigBackendImpl();
 
+    /// @brief Creates MySQL binding from an integer.
+    ///
+    /// @tparam T Numeric type corresponding to the binding type, e.g.
+    /// @c uint8_t, @c uint16_t etc.
+    /// @param value Optional integet of type T.
+    /// @return Pointer to a null binding if the value is "unspecified" or
+    /// a pointer to a binding representing integer value.
+    template<typename T>
+    static db::MySqlBindingPtr condCreateInteger(const util::Optional<T>& value) {
+        if (value.unspecified()) {
+            return (db::MySqlBinding::createNull());
+        }
+        return (db::MySqlBinding::createInteger(value));
+    }
+
     /// @brief Creates MySQL binding from a @c Triplet.
     ///
     /// @param triplet Triplet value from which the binding should be created.
index 01d7ca1708bab82a225cad3929c46d05da0b53e0..15a76c205f78e4204863dc0b3a6abac42ffa5a48 100644 (file)
@@ -117,6 +117,8 @@ namespace {
     "  s.ddns_qualifying_suffix," \
     "  s.reservations_in_subnet," \
     "  s.reservations_out_of_pool," \
+    "  s.cache_threshold," \
+    "  s.cache_max_age," \
     "  srv.tag " \
     "FROM dhcp4_subnet AS s " \
     server_join \
@@ -244,6 +246,8 @@ namespace {
     "  s.ddns_qualifying_suffix," \
     "  s.reservations_in_subnet," \
     "  s.reservations_out_of_pool," \
+    "  s.cache_threshold," \
+    "  s.cache_max_age," \
     "  srv.tag " \
     "FROM dhcp6_subnet AS s " \
     server_join \
@@ -451,6 +455,8 @@ namespace {
     "  n.ddns_qualifying_suffix," \
     "  n.reservations_in_subnet," \
     "  n.reservations_out_of_pool," \
+    "  n.cache_threshold," \
+    "  n.cache_max_age," \
     "  s.tag " \
     "FROM dhcp4_shared_network AS n " \
     server_join \
@@ -530,6 +536,8 @@ namespace {
     "  n.ddns_qualifying_suffix," \
     "  n.reservations_in_subnet," \
     "  n.reservations_out_of_pool," \
+    "  n.cache_threshold," \
+    "  n.cache_max_age," \
     "  s.tag " \
     "FROM dhcp6_shared_network AS n " \
     server_join \
index 11997b1cfc49d0d0f911cc7a74eb8652a941673a..6bcec65e4fc1541d8d8b2d565882dbf02384a2b2 100644 (file)
@@ -1403,7 +1403,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
             }
 
             // Got a lease for a reservation in this IA.
-            return(true);
+            return;
         }
     }
 
index 156d8e13d96925d065618f8fea384e17ae1f6929..13c3e80c0b3685a32c8d49d81ba9b251521cf07c 100644 (file)
@@ -4054,8 +4054,8 @@ TEST_F(AllocEngine4Test, discoverCacheBadThreshold4) {
     uint32_t valid = 500;
     subnet_->setValid(valid);
 
-    // Set the threshold to 25%.
-    subnet_->setCacheThreshold(.25);
+    // Set the threshold to 10%.
+    subnet_->setCacheThreshold(.10);
 
     IOAddress addr("192.0.2.105");
     time_t now = time(NULL) - 100; // Allocated 100 seconds ago.
@@ -4211,8 +4211,8 @@ TEST_F(AllocEngine4Test, discoverCacheRevDDNS4) {
     uint32_t valid = 500;
     subnet_->setValid(valid);
 
-    // Set the threshold to 10%.
-    subnet_->setCacheThreshold(.1);
+    // Set the threshold to 25%.
+    subnet_->setCacheThreshold(.25);
 
     // Set the max age to 200.
     subnet_->setCacheMaxAge(200);
index 4ae41d9dc8cdefec730986a90cfb9d5efc4869b4..118c058279a37ed8d29834a35774afaf2ae95fc0 100644 (file)
@@ -3728,14 +3728,8 @@ TEST_F(AllocEngine6Test, mixedHostReservedAddress) {
     EXPECT_EQ("2001:db8:1::1c", lease->addr_.toText());
 
     // We're going to rollback the clock a little so we can verify a renewal.
-    // We verify the "time" change in case the lease returned to us
-    // by expectOneLease ever becomes a copy and not what is in the lease mgr.
     --lease->cltt_;
-    lease->updateCurrentExpirationTime();
-    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
-                                                               lease->addr_);
-    ASSERT_TRUE(from_mgr);
-    EXPECT_EQ(from_mgr->cltt_, lease->cltt_);
+    EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease));
 
     // This is what the client will send in his renew message.
     AllocEngine::HintContainer hints;
@@ -3794,14 +3788,8 @@ TEST_F(AllocEngine6Test, mixedHostReservedPrefix) {
     EXPECT_EQ("2001:db8:1:2::", lease->addr_.toText());
 
     // We're going to rollback the clock a little so we can verify a renewal.
-    // We verify the "time" change in case the lease returned to us
-    // by expectOneLease ever becomes a copy and not what is in the lease mgr.
     --lease->cltt_;
-    lease->updateCurrentExpirationTime();
-    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
-                                                               lease->addr_);
-    ASSERT_TRUE(from_mgr);
-    EXPECT_EQ(from_mgr->cltt_, lease->cltt_);
+    EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease));
 
     // This is what the client will send in his renew message.
     AllocEngine::HintContainer hints;
@@ -3872,14 +3860,8 @@ TEST_F(AllocEngine6Test, bothHostReservedAddress) {
     EXPECT_EQ("2001:db8:1::1c", lease->addr_.toText());
 
     // We're going to rollback the clock a little so we can verify a renewal.
-    // We verify the "time" change in case the lease returned to us
-    // by expectOneLease ever becomes a copy and not what is in the lease mgr.
     --lease->cltt_;
-    lease->updateCurrentExpirationTime();
-    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
-                                                               lease->addr_);
-    ASSERT_TRUE(from_mgr);
-    EXPECT_EQ(from_mgr->cltt_, lease->cltt_);
+    EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease));
 
     // This is what the client will send in his renew message.
     AllocEngine::HintContainer hints;
@@ -3947,14 +3929,8 @@ TEST_F(AllocEngine6Test, bothHostReservedPrefix) {
     EXPECT_EQ("2001:db8:1:2::", lease->addr_.toText());
 
     // We're going to rollback the clock a little so we can verify a renewal.
-    // We verify the "time" change in case the lease returned to us
-    // by expectOneLease ever becomes a copy and not what is in the lease mgr.
     --lease->cltt_;
-    lease->updateCurrentExpirationTime();
-    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
-                                                               lease->addr_);
-    ASSERT_TRUE(from_mgr);
-    EXPECT_EQ(from_mgr->cltt_, lease->cltt_);
+    EXPECT_NO_THROW(LeaseMgrFactory::instance().updateLease6(lease));
 
     // This is what the client will send in his renew message.
     AllocEngine::HintContainer hints;
index 07183708108f50b04888bc7bae4a909635552718..5ff88e91f9538fb8977cc217ad2a3ae5ff3732cd 100644 (file)
@@ -3054,6 +3054,23 @@ ALTER TABLE dhcp4_shared_network DROP COLUMN reservation_mode;
 ALTER TABLE dhcp6_subnet DROP COLUMN reservation_mode;
 ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode;
 
+# Add new lease cache parameters.
+ALTER TABLE dhcp4_subnet
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp4_shared_network
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp6_subnet
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp6_shared_network
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
 # Update the schema version number
 UPDATE schema_version
 SET version = '9', minor = '5';
index fb5a7d72c22d0f0ecd8cd2b9e848c2cf40101708..3fce7b9bf005e79813cd1a064d00c26a22af0972 100644 (file)
@@ -161,6 +161,23 @@ ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode;
 # Enable audit in this session
 SET @disable_audit = 0;
 
+# Add new lease cache parameters.
+ALTER TABLE dhcp4_subnet
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp4_shared_network
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp6_subnet
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
+ALTER TABLE dhcp6_shared_network
+    ADD COLUMN cache_threshold FLOAT DEFAULT NULL,
+    ADD COLUMN cache_max_age INT(10) DEFAULT NULL;
+
 # Update the schema version number
 UPDATE schema_version
 SET version = '9', minor = '5';