]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3239] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Thu, 4 Sep 2025 04:14:11 +0000 (07:14 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 5 Sep 2025 14:05:14 +0000 (14:05 +0000)
ChangeLog
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds4_unittest.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds6_unittest.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds_unittest.h
src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc

index 840e8bedc6c2e75b488b0f070f38cde9296114a3..f7ed25a58e18efa6ad2787347dc5828d8b1b0bf7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2393.  [func]          razvan
+       Added global counters for 'assigned-addresses',
+       'assigned-nas' and 'assigned-pds'. The 'stat-lease4-get'
+       and 'stat-lease6-get' now properly return
+       'assigned-addresses' and 'assigned-nas' containing also
+       the 'declined-addresses' address count.
+       (Gitlab #3239, #3925)
+
 2392.  [func]          razvan
        Reject 'config-set' and 'config-reload' commands when lease
        file cleanup process is running.
index 0564bff4a6ca92e76d24533831a36c923b5f40fa..99a050a778d1083bbcf058b2994c5544614ef0b3 100644 (file)
@@ -7331,8 +7331,8 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | This statistic is expected to grow |
    |                                                    |                | every time the server transmits a  |
    |                                                    |                | packet. In general, it should      |
-   |                                                    |                | roughly match ``pkt4-received``, as|
-   |                                                    |                | most incoming packets cause the    |
+   |                                                    |                | roughly match ``pkt4-received``,   |
+   |                                                    |                | as most incoming packets cause the |
    |                                                    |                | server to respond. There are       |
    |                                                    |                | exceptions (e.g. DHCPRELEASE), so  |
    |                                                    |                | do not worry if it is less than    |
@@ -7379,9 +7379,9 @@ The DHCPv4 server supports the following statistics:
    | pkt4-receive-drop                                  | integer        | Number of incoming packets that    |
    |                                                    |                | were dropped. The exact reason for |
    |                                                    |                | dropping packets is logged, but    |
-   |                                                    |                | the most common reasons may be that|
-   |                                                    |                | an unacceptable packet type was    |
-   |                                                    |                | received, direct responses are     |
+   |                                                    |                | the most common reasons may be     |
+   |                                                    |                | that an unacceptable packet type   |
+   |                                                    |                | was received, direct responses are |
    |                                                    |                | forbidden, or the server ID sent   |
    |                                                    |                | by the client does not match the   |
    |                                                    |                | server's server ID.                |
@@ -7419,13 +7419,14 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | reconfiguration event.             |
    +----------------------------------------------------+----------------+------------------------------------+
    | assigned-addresses                                 | integer        | Number of assigned addresses. It   |
-   |                                                    |                | increases every time a new lease is|
-   |                                                    |                | allocated (as a result of receiving|
-   |                                                    |                | a DHCPREQUEST message) and         |
-   |                                                    |                | decreases every time a lease is    |
-   |                                                    |                | released (a DHCPRELEASE message is |
-   |                                                    |                | received) or expires and is reset  |
-   |                                                    |                | during a reconfiguration event.    |
+   |                                                    |                | increases every time a new lease   |
+   |                                                    |                | is allocated (as a result of       |
+   |                                                    |                | receiving a DHCPREQUEST message)   |
+   |                                                    |                | and decreases every time a lease   |
+   |                                                    |                | is released (a DHCPRELEASE message |
+   |                                                    |                | is received) or expires, and is    |
+   |                                                    |                | reset during a reconfiguration     |
+   |                                                    |                | event.                             |
    +----------------------------------------------------+----------------+------------------------------------+
    | cumulative-assigned-addresses                      | integer        | Cumulative number of addresses     |
    |                                                    |                | that have been assigned since      |
@@ -7569,37 +7570,38 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | recovered. Unlike                  |
    |                                                    |                | ``declined-addresses``, this       |
    |                                                    |                | statistic never decreases. It can  |
-   |                                                    |                | be used as a long-term indicator of|
-   |                                                    |                | how many actual valid declines were|
-   |                                                    |                | processed and recovered from. This |
-   |                                                    |                | is a global statistic that covers  |
-   |                                                    |                | all subnets.                       |
+   |                                                    |                | be used as a long-term indicator   |
+   |                                                    |                | of how many actual valid declines  |
+   |                                                    |                | were processed and recovered from. |
+   |                                                    |                | This is a global statistic that    |
+   |                                                    |                | covers all subnets.                |
    +----------------------------------------------------+----------------+------------------------------------+
    | subnet[id].reclaimed-declined-addresses            | integer        | Number of IPv4 addresses that were |
    |                                                    |                | declined, but have now been        |
    |                                                    |                | recovered. Unlike                  |
    |                                                    |                | ``declined-addresses``, this       |
    |                                                    |                | statistic never decreases. It can  |
-   |                                                    |                | be used as a long-term indicator of|
-   |                                                    |                | how many actual valid declines were|
-   |                                                    |                | processed and recovered from. The  |
-   |                                                    |                | *id* is the subnet ID of a given   |
-   |                                                    |                | subnet. This statistic is exposed  |
-   |                                                    |                | for each subnet separately.        |
+   |                                                    |                | be used as a long-term indicator   |
+   |                                                    |                | of how many actual valid declines  |
+   |                                                    |                | were processed and recovered from. |
+   |                                                    |                | The *id* is the subnet ID of a     |
+   |                                                    |                | given subnet. This statistic is    |
+   |                                                    |                | exposed for each subnet            |
+   |                                                    |                | separately.                        |
    +----------------------------------------------------+----------------+------------------------------------+
    | subnet[id].pool[pid].reclaimed-declined-addresses  | integer        | Number of IPv4 addresses that were |
    |                                                    |                | declined, but have now been        |
    |                                                    |                | recovered. Unlike                  |
    |                                                    |                | ``declined-addresses``, this       |
    |                                                    |                | statistic never decreases. It can  |
-   |                                                    |                | be used as a long-term indicator of|
-   |                                                    |                | how many actual valid declines were|
-   |                                                    |                | processed and recovered from. The  |
-   |                                                    |                | *id* is the subnet ID of a given   |
-   |                                                    |                | subnet. The *pid* is the pool ID   |
-   |                                                    |                | of the pool. This statistic is     |
-   |                                                    |                | exposed for each subnet pool       |
-   |                                                    |                | separately.                        |
+   |                                                    |                | be used as a long-term indicator   |
+   |                                                    |                | of how many actual valid declines  |
+   |                                                    |                | were processed and recovered from. |
+   |                                                    |                | The *id* is the subnet ID of a     |
+   |                                                    |                | given subnet. The *pid* is the     |
+   |                                                    |                | pool ID of the pool. This          |
+   |                                                    |                | statistic is exposed for each      |
+   |                                                    |                | subnet pool separately.            |
    +----------------------------------------------------+----------------+------------------------------------+
    | pkt4-lease-query-received                          | integer        | Number of IPv4 DHCPLEASEQUERY      |
    |                                                    |                | packets received. (Only exists if  |
@@ -7625,8 +7627,8 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | failures for a particular client.  |
    |                                                    |                | This consists of the number of     |
    |                                                    |                | lease allocation attempts that the |
-   |                                                    |                | server made before giving up, if it|
-   |                                                    |                | was unable to use any of the       |
+   |                                                    |                | server made before giving up, if   |
+   |                                                    |                | it was unable to use any of the    |
    |                                                    |                | address pools. This is a global    |
    |                                                    |                | statistic that covers all subnets. |
    +----------------------------------------------------+----------------+------------------------------------+
@@ -7634,8 +7636,8 @@ The DHCPv4 server supports the following statistics:
    |                                                    |                | failures for a particular client.  |
    |                                                    |                | This consists of the number of     |
    |                                                    |                | lease allocation attempts that the |
-   |                                                    |                | server made before giving up, if it|
-   |                                                    |                | was unable to use any of the       |
+   |                                                    |                | server made before giving up, if   |
+   |                                                    |                | it was unable to use any of the    |
    |                                                    |                | address pools. The *id* is the     |
    |                                                    |                | subnet ID of a given subnet. This  |
    |                                                    |                | statistic is exposed for each      |
index 04f2c9bf16996a88972898638fd3f0f41c28c44c..1430581864ada47bec4cd620236e0d9a79f05f5c 100644 (file)
@@ -6943,13 +6943,14 @@ The DHCPv6 server supports the following statistics:
    | pkt6-receive-drop                                 | integer        | Number of incoming packets that    |
    |                                                   |                | were dropped. The exact reason for |
    |                                                   |                | dropping packets is logged, but    |
-   |                                                   |                | the most common reasons may be that|
-   |                                                   |                | an unacceptable or not-supported   |
-   |                                                   |                | packet type is received, direct    |
-   |                                                   |                | responses are forbidden, the       |
-   |                                                   |                | server ID sent by the client does  |
-   |                                                   |                | not match the server's server ID,  |
-   |                                                   |                | or the packet is malformed.        |
+   |                                                   |                | the most common reasons may be     |
+   |                                                   |                | that an unacceptable or            |
+   |                                                   |                | not-supported packet type is       |
+   |                                                   |                | received, direct responses are     |
+   |                                                   |                | forbidden, the server ID sent by   |
+   |                                                   |                | the client does not match the      |
+   |                                                   |                | server's server ID, or the packet  |
+   |                                                   |                | is malformed.                      |
    +---------------------------------------------------+----------------+------------------------------------+
    | pkt6-parse-failed                                 | integer        | Number of incoming packets that    |
    |                                                   |                | could not be parsed. A non-zero    |
@@ -7032,8 +7033,8 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | longer needed. Note that many      |
    |                                                   |                | devices, especially wireless, do   |
    |                                                   |                | not send RELEASE packets either    |
-   |                                                   |                | because of design choices or due to|
-   |                                                   |                | the client moving out of range.    |
+   |                                                   |                | because of design choices or due   |
+   |                                                   |                | to the client moving out of range. |
    +---------------------------------------------------+----------------+------------------------------------+
    | pkt6-decline-received                             | integer        | Number of DECLINE packets          |
    |                                                   |                | received. This statistic is        |
@@ -7114,13 +7115,13 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | This statistic is expected to grow |
    |                                                   |                | every time the server transmits a  |
    |                                                   |                | packet. In general, it should      |
-   |                                                   |                | roughly match ``pkt6-received``, as|
-   |                                                   |                | most incoming packets cause the    |
+   |                                                   |                | roughly match ``pkt6-received``,   |
+   |                                                   |                | as most incoming packets cause the |
    |                                                   |                | server to respond. There are       |
-   |                                                   |                | exceptions (e.g. a server receiving|
-   |                                                   |                | a REQUEST with server ID matching  |
-   |                                                   |                | another server), so do not worry   |
-   |                                                   |                | if it is less than                 |
+   |                                                   |                | exceptions (e.g. a server          |
+   |                                                   |                | receiving a REQUEST with server ID |
+   |                                                   |                | matching another server), so do    |
+   |                                                   |                | not worry if it is less than       |
    |                                                   |                | ``pkt6-received``.                 |
    +---------------------------------------------------+----------------+------------------------------------+
    | pkt6-advertise-sent                               | integer        | Number of ADVERTISE packets sent.  |
@@ -7189,13 +7190,14 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | reconfiguration event.             |
    +---------------------------------------------------+----------------+------------------------------------+
    | assigned-nas                                      | integer        | Number of NA addresses that are    |
-   |                                                   |                | assigned. It increases every time a|
-   |                                                   |                | new lease is allocated (as a result|
-   |                                                   |                | of receiving a REQUEST message) and|
-   |                                                   |                | decreases every time a lease is    |
-   |                                                   |                | released (a RELEASE message is     |
-   |                                                   |                | received) or expires and is reset  |
-   |                                                   |                | during a reconfiguration event.    |
+   |                                                   |                | assigned. It increases every time  |
+   |                                                   |                | a new lease is allocated (as a     |
+   |                                                   |                | result of receiving a REQUEST      |
+   |                                                   |                | message) and decreases every time  |
+   |                                                   |                | a lease is released (a RELEASE     |
+   |                                                   |                | message is received) or expires,   |
+   |                                                   |                | and is reset during a              |
+   |                                                   |                | reconfiguration event.             |
    +---------------------------------------------------+----------------+------------------------------------+
    | cumulative-assigned-nas                           | integer        | Cumulative number of NA addresses  |
    |                                                   |                | that have been assigned since      |
@@ -7264,8 +7266,8 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | words, this is the count of all    |
    |                                                   |                | prefixes in all configured pools.  |
    |                                                   |                | This statistic changes only during |
-   |                                                   |                | configuration changes. Note that it|
-   |                                                   |                | does not take into account any     |
+   |                                                   |                | configuration changes. Note that   |
+   |                                                   |                | it does not take into account any  |
    |                                                   |                | prefixes that may be reserved due  |
    |                                                   |                | to host reservation. The *id* is   |
    |                                                   |                | the subnet ID of a given subnet.   |
@@ -7291,13 +7293,14 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | reconfiguration event.             |
    +---------------------------------------------------+----------------+------------------------------------+
    | assigned-pds                                      | integer        | Number of PD prefixes that are     |
-   |                                                   |                | assigned. It increases every time a|
-   |                                                   |                | new lease is allocated (as a result|
-   |                                                   |                | of receiving a REQUEST message) and|
-   |                                                   |                | decreases every time a lease is    |
-   |                                                   |                | released (a RELEASE message is     |
-   |                                                   |                | received) or expires and is reset  |
-   |                                                   |                | during a reconfiguration event.    |
+   |                                                   |                | assigned. It increases every time  |
+   |                                                   |                | a new lease is allocated (as a     |
+   |                                                   |                | result of receiving a REQUEST      |
+   |                                                   |                | message) and decreases every time  |
+   |                                                   |                | a lease is released (a RELEASE     |
+   |                                                   |                | message is received) or expires,   |
+   |                                                   |                | and is reset during a              |
+   |                                                   |                | reconfiguration event.             |
    +---------------------------------------------------+----------------+------------------------------------+
    | cumulative-assigned-pds                           | integer        | Cumulative number of PD prefixes   |
    |                                                   |                | that have been assigned since      |
@@ -7461,44 +7464,45 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | recovered. Unlike                  |
    |                                                   |                | ``declined-addresses``, this       |
    |                                                   |                | statistic never decreases. It can  |
-   |                                                   |                | be used as a long-term indicator of|
-   |                                                   |                | how many actual valid declines were|
-   |                                                   |                | processed and recovered from. This |
-   |                                                   |                | is a global statistic that covers  |
-   |                                                   |                | all subnets.                       |
+   |                                                   |                | be used as a long-term indicator   |
+   |                                                   |                | of how many actual valid declines  |
+   |                                                   |                | were processed and recovered from. |
+   |                                                   |                | This is a global statistic that    |
+   |                                                   |                | covers all subnets.                |
    +---------------------------------------------------+----------------+------------------------------------+
    | subnet[id].reclaimed-declined-addresses           | integer        | Number of IPv6 addresses that were |
    |                                                   |                | declined, but have now been        |
    |                                                   |                | recovered. Unlike                  |
    |                                                   |                | ``declined-addresses``, this       |
    |                                                   |                | statistic never decreases. It can  |
-   |                                                   |                | be used as a long-term indicator of|
-   |                                                   |                | how many actual valid declines were|
-   |                                                   |                | processed and recovered from. The  |
-   |                                                   |                | *id* is the subnet ID of a given   |
-   |                                                   |                | subnet. This statistic is exposed  |
-   |                                                   |                | for each subnet separately.        |
+   |                                                   |                | be used as a long-term indicator   |
+   |                                                   |                | of how many actual valid declines  |
+   |                                                   |                | were processed and recovered from. |
+   |                                                   |                | The *id* is the subnet ID of a     |
+   |                                                   |                | given subnet. This statistic is    |
+   |                                                   |                | exposed for each subnet            |
+   |                                                   |                | separately.                        |
    +---------------------------------------------------+----------------+------------------------------------+
    | subnet[id].pool[pid].reclaimed-declined-addresses | integer        | Number of IPv6 addresses that were |
    |                                                   |                | declined, but have now been        |
    |                                                   |                | recovered. Unlike                  |
    |                                                   |                | ``declined-addresses``, this       |
    |                                                   |                | statistic never decreases. It can  |
-   |                                                   |                | be used as a long-term indicator of|
-   |                                                   |                | how many actual valid declines were|
-   |                                                   |                | processed and recovered from. The  |
-   |                                                   |                | *id* is the subnet ID of a given   |
-   |                                                   |                | subnet. The *pid* is the pool ID   |
-   |                                                   |                | of the pool. This statistic is     |
-   |                                                   |                | exposed for each subnet pool       |
-   |                                                   |                | separately.                        |
+   |                                                   |                | be used as a long-term indicator   |
+   |                                                   |                | of how many actual valid declines  |
+   |                                                   |                | were processed and recovered from. |
+   |                                                   |                | The *id* is the subnet ID of a     |
+   |                                                   |                | given subnet. The *pid* is the     |
+   |                                                   |                | pool ID of the pool. This          |
+   |                                                   |                | statistic is exposed for each      |
+   |                                                   |                | subnet pool separately.            |
    +---------------------------------------------------+----------------+------------------------------------+
    | v6-allocation-fail                                | integer        | Number of total address allocation |
    |                                                   |                | failures for a particular client.  |
    |                                                   |                | This consists of the number of     |
    |                                                   |                | lease allocation attempts that the |
-   |                                                   |                | server made before giving up, if it|
-   |                                                   |                | was unable to use any of the       |
+   |                                                   |                | server made before giving up, if   |
+   |                                                   |                | it was unable to use any of the    |
    |                                                   |                | address pools. This is a global    |
    |                                                   |                | statistic that covers all subnets. |
    +---------------------------------------------------+----------------+------------------------------------+
@@ -7506,8 +7510,8 @@ The DHCPv6 server supports the following statistics:
    |                                                   |                | failures for a particular client.  |
    |                                                   |                | This consists of the number of     |
    |                                                   |                | lease allocation attempts that the |
-   |                                                   |                | server made before giving up, if it|
-   |                                                   |                | was unable to use any of the       |
+   |                                                   |                | server made before giving up, if   |
+   |                                                   |                | it was unable to use any of the    |
    |                                                   |                | address pools. The *id* is the     |
    |                                                   |                | subnet ID of a given subnet. This  |
    |                                                   |                | statistic is exposed for each      |
index 68ad2a144fc787399711d327e6d8f0517a004f36..af52ec4001e8cc4e62a10e32771c8d5d0c33d4eb 100644 (file)
@@ -2482,7 +2482,7 @@ LeaseCmdsImpl::lease6WipeHandler(CalloutHandle& handle) {
             int64_t previous_assigned_pd = 0;
 
             if (assigned_pd_observation) {
-                previous_assigned_na = assigned_pd_observation->getInteger().first;
+                previous_assigned_pd = assigned_pd_observation->getInteger().first;
             }
 
             auto declined_observation = StatsMgr::instance().getObservation(
index f0c324318b69c849bedcf2fe39bbc3e447560c68..fcf729ba8fc9e6f96cd538c4d0f3d7accdc6d4c7 100644 (file)
@@ -136,13 +136,21 @@ public:
     /// @assigned The expected value of assigned addresses in subnet.
     /// @declined The expected value of declined addresses in subnet.
     void checkLease4Stats(isc::dhcp::SubnetID id, int32_t assigned, int32_t declined) {
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "assigned-addresses"))->getInteger().first, assigned);
+        if (id == SUBNET_ID_GLOBAL) {
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    "assigned-addresses")->getInteger().first, assigned);
 
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "declined-addresses"))->getInteger().first, declined);
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    "declined-addresses")->getInteger().first, declined);
+        } else {
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "assigned-addresses"))->getInteger().first, assigned);
+
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "declined-addresses"))->getInteger().first, declined);
+        }
     }
 
     /// @brief Check that lease4-add with missing parameters will fail.
@@ -636,6 +644,8 @@ void Lease4CmdsTest::testLease4Add() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -653,6 +663,8 @@ void Lease4CmdsTest::testLease4Add() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -681,6 +693,8 @@ void Lease4CmdsTest::testLease4AddDeclinedLeases() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -699,6 +713,8 @@ void Lease4CmdsTest::testLease4AddDeclinedLeases() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 1);
+
     checkLease4Stats(44, 1, 1);
 
     checkLease4Stats(88, 0, 0);
@@ -727,6 +743,8 @@ void Lease4CmdsTest::testLease4AddReleasedLeases() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -745,6 +763,8 @@ void Lease4CmdsTest::testLease4AddReleasedLeases() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -773,6 +793,8 @@ void Lease4CmdsTest::testLease4AddExisting() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -790,6 +812,8 @@ void Lease4CmdsTest::testLease4AddExisting() {
     string exp_rsp = "IPv4 lease already exists.";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -799,6 +823,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissing() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -816,6 +842,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissing() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -830,6 +858,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissingDeclinedLeases() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -848,6 +878,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissingDeclinedLeases() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 1);
+
     checkLease4Stats(44, 1, 1);
 
     checkLease4Stats(88, 0, 0);
@@ -862,6 +894,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissingBadAddr() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -880,6 +914,8 @@ void Lease4CmdsTest::testLease4AddSubnetIdMissingBadAddr() {
                      "address 192.0.55.1";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -893,6 +929,8 @@ void Lease4CmdsTest::testLease4AddNegativeExpireTime() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -910,6 +948,8 @@ void Lease4CmdsTest::testLease4AddNegativeExpireTime() {
     string exp_rsp = "expiration time must be positive for address 192.0.2.202";
     testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -923,6 +963,8 @@ void Lease4CmdsTest::testLease4AddNegativeCltt() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -942,6 +984,8 @@ void Lease4CmdsTest::testLease4AddNegativeCltt() {
         "address 192.0.2.202";
     testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -955,6 +999,8 @@ void Lease4CmdsTest::testLease4AddFullAddr() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -980,6 +1026,8 @@ void Lease4CmdsTest::testLease4AddFullAddr() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -1006,6 +1054,8 @@ void Lease4CmdsTest::testLease4AddComment() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -1024,6 +1074,8 @@ void Lease4CmdsTest::testLease4AddComment() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -1043,6 +1095,8 @@ void Lease4CmdsTest::testLease4AddExtendedInfo() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -1077,6 +1131,8 @@ void Lease4CmdsTest::testLease4AddExtendedInfo() {
     string exp_rsp = "Lease for address 192.0.2.202, subnet-id 44 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2141,6 +2197,8 @@ void Lease4CmdsTest::testLease4UpdateNoLease() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2161,6 +2219,8 @@ void Lease4CmdsTest::testLease4UpdateNoLease() {
         "database, in both cases a retry might succeed";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2170,6 +2230,8 @@ void Lease4CmdsTest::testLease4Update() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2189,6 +2251,8 @@ void Lease4CmdsTest::testLease4Update() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2209,6 +2273,8 @@ void Lease4CmdsTest::testLease4UpdateDeclinedLeases() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true, true);
 
+    checkLease4Stats(0, 4, 4);
+
     checkLease4Stats(44, 2, 2);
 
     checkLease4Stats(88, 2, 2);
@@ -2228,6 +2294,8 @@ void Lease4CmdsTest::testLease4UpdateDeclinedLeases() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 3);
+
     checkLease4Stats(44, 2, 1);
 
     checkLease4Stats(88, 2, 2);
@@ -2248,6 +2316,8 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetId() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2265,6 +2335,8 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetId() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2287,6 +2359,8 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetIdDeclinedLeases() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true, true);
 
+    checkLease4Stats(0, 4, 4);
+
     checkLease4Stats(44, 2, 2);
 
     checkLease4Stats(88, 2, 2);
@@ -2304,6 +2378,8 @@ void Lease4CmdsTest::testLease4UpdateNoSubnetIdDeclinedLeases() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 3);
+
     checkLease4Stats(44, 2, 1);
 
     checkLease4Stats(88, 2, 2);
@@ -2326,6 +2402,8 @@ void Lease4CmdsTest::testLease4UpdateForceCreate() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2345,6 +2423,8 @@ void Lease4CmdsTest::testLease4UpdateForceCreate() {
     string exp_rsp = "IPv4 lease added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2364,6 +2444,8 @@ void Lease4CmdsTest::testLease4UpdateForceCreateNoSubnetId() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2382,6 +2464,8 @@ void Lease4CmdsTest::testLease4UpdateForceCreateNoSubnetId() {
     string exp_rsp = "IPv4 lease added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 1, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2404,6 +2488,8 @@ void Lease4CmdsTest::testLease4UpdateDoNotForceCreate() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2425,6 +2511,8 @@ void Lease4CmdsTest::testLease4UpdateDoNotForceCreate() {
         "database, in both cases a retry might succeed";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2434,6 +2522,8 @@ void Lease4CmdsTest::testLease4UpdateComment() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2453,6 +2543,8 @@ void Lease4CmdsTest::testLease4UpdateComment() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2479,6 +2571,8 @@ void Lease4CmdsTest::testLease4UpdateExtendedInfo() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2513,6 +2607,8 @@ void Lease4CmdsTest::testLease4UpdateExtendedInfo() {
     string exp_rsp = "IPv4 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2627,6 +2723,8 @@ void Lease4CmdsTest::testLease4DelByAddrNotFound() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2646,6 +2744,8 @@ void Lease4CmdsTest::testLease4DelByAddrNotFound() {
     // just didn't found the lease.
     ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2655,6 +2755,8 @@ void Lease4CmdsTest::testLease4DelByAddr() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2672,6 +2774,8 @@ void Lease4CmdsTest::testLease4DelByAddr() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 3, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2684,6 +2788,8 @@ void Lease4CmdsTest::testLease4DelByAddrDeclinedLeases() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true, true);
 
+    checkLease4Stats(0, 4, 4);
+
     checkLease4Stats(44, 2, 2);
 
     checkLease4Stats(88, 2, 2);
@@ -2701,6 +2807,8 @@ void Lease4CmdsTest::testLease4DelByAddrDeclinedLeases() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 3, 3);
+
     checkLease4Stats(44, 1, 1);
 
     checkLease4Stats(88, 2, 2);
@@ -2713,6 +2821,8 @@ void Lease4CmdsTest::testLease4DelByAddrBadParam() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2728,6 +2838,8 @@ void Lease4CmdsTest::testLease4DelByAddrBadParam() {
     string exp_rsp = "Invalid IPv4 address specified: 2001:db8:1::1";
     testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2748,6 +2860,8 @@ void Lease4CmdsTest::testLease4DelByHWAddrNotFound() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2765,6 +2879,8 @@ void Lease4CmdsTest::testLease4DelByHWAddrNotFound() {
     string exp_rsp = "IPv4 lease not found.";
     ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2777,6 +2893,8 @@ void Lease4CmdsTest::testLease4DelByHWAddr() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2796,6 +2914,8 @@ void Lease4CmdsTest::testLease4DelByHWAddr() {
     // The status expected is success. The lease should be deleted.
     ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 3, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2808,6 +2928,8 @@ void Lease4CmdsTest::testLease4DelByClientIdNotFound() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2825,6 +2947,8 @@ void Lease4CmdsTest::testLease4DelByClientIdNotFound() {
     string exp_rsp = "IPv4 lease not found.";
     ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2837,6 +2961,8 @@ void Lease4CmdsTest::testLease4DelByClientId() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2856,6 +2982,8 @@ void Lease4CmdsTest::testLease4DelByClientId() {
     // The status expected is success. The lease should be deleted.
     ConstElementPtr rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 3, 0);
+
     checkLease4Stats(44, 1, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2868,6 +2996,8 @@ void Lease4CmdsTest::testLease4Wipe() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2885,6 +3015,8 @@ void Lease4CmdsTest::testLease4Wipe() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 2, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2902,6 +3034,8 @@ void Lease4CmdsTest::testLease4WipeAll() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2919,6 +3053,8 @@ void Lease4CmdsTest::testLease4WipeAll() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2936,6 +3072,8 @@ void Lease4CmdsTest::testLease4WipeAllNoArgs() {
     // Initialize lease manager (false = v4, true = add leases)
     initLeaseMgr(false, true);
 
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     checkLease4Stats(88, 2, 0);
@@ -2950,6 +3088,8 @@ void Lease4CmdsTest::testLease4WipeAllNoArgs() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2967,6 +3107,8 @@ void Lease4CmdsTest::testLease4WipeNoLeases() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2982,6 +3124,8 @@ void Lease4CmdsTest::testLease4WipeNoLeases() {
     string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44";
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -2991,6 +3135,8 @@ void Lease4CmdsTest::testLease4WipeNoLeasesAll() {
     // Initialize lease manager (false = v4, false = don't add leases)
     initLeaseMgr(false, false);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -3006,6 +3152,8 @@ void Lease4CmdsTest::testLease4WipeNoLeasesAll() {
     string exp_rsp = "Deleted 0 IPv4 lease(s) from subnet(s) 44 88";
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     checkLease4Stats(88, 0, 0);
@@ -3390,6 +3538,8 @@ void Lease4CmdsTest::testLease4ConflictingAdd() {
     ASSERT_FALSE(lease);
 
     // Verify stats show no leases.
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 
     // Lock the address.
@@ -3416,6 +3566,8 @@ void Lease4CmdsTest::testLease4ConflictingAdd() {
     ASSERT_FALSE(lease);
 
     // Stats should not have changed.
+    checkLease4Stats(0, 0, 0);
+
     checkLease4Stats(44, 0, 0);
 }
 
@@ -3426,6 +3578,8 @@ void Lease4CmdsTest::testLease4ConflictingUpdate() {
     initLeaseMgr(false, true);
 
     // Verify stats show no leases.
+    checkLease4Stats(0, 4, 0);
+
     checkLease4Stats(44, 2, 0);
 
     // Make sure the lease exists.
@@ -3460,6 +3614,11 @@ void Lease4CmdsTest::testLease4ConflictingUpdate() {
 
     // Lease should not have been changed.
     EXPECT_EQ(original_lease, *lease);
+
+    // Stats should not have changed.
+    checkLease4Stats(0, 4, 0);
+
+    checkLease4Stats(44, 2, 0);
 }
 
 void Lease4CmdsTest::testLease4Write() {
index cbcd6a3fc29be8318a0db082a2b8c388c71a8be0..c29308a022e543b23bba35ae73556bc518baaad0 100644 (file)
@@ -139,21 +139,34 @@ public:
     void checkLease6Stats(isc::dhcp::SubnetID id, int32_t assigned_nas,
                           int32_t declined, int32_t assigned_pds,
                           int32_t registered_nas) {
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "assigned-nas"))->getInteger().first, assigned_nas);
+        if (id == SUBNET_ID_GLOBAL) {
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    "assigned-nas")->getInteger().first, assigned_nas);
 
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "declined-addresses"))->getInteger().first, declined);
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    "declined-addresses")->getInteger().first, declined);
 
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "assigned-pds"))->getInteger().first, assigned_pds);
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    "assigned-pds")->getInteger().first, assigned_pds);
 
-        ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
-                isc::stats::StatsMgr::generateName("subnet", id,
-                          "registered-nas"))->getInteger().first, registered_nas);
+            ASSERT_EQ(0, registered_nas);
+        } else {
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "assigned-nas"))->getInteger().first, assigned_nas);
+
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "declined-addresses"))->getInteger().first, declined);
+
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "assigned-pds"))->getInteger().first, assigned_pds);
+
+            ASSERT_EQ(isc::stats::StatsMgr::instance().getObservation(
+                    isc::stats::StatsMgr::generateName("subnet", id,
+                              "registered-nas"))->getInteger().first, registered_nas);
+        }
     }
 
     /// @brief Check that lease6-add with missing parameters will fail.
@@ -763,6 +776,8 @@ void Lease6CmdsTest::testLease6Add() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -781,6 +796,8 @@ void Lease6CmdsTest::testLease6Add() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -809,6 +826,8 @@ void Lease6CmdsTest::testLease6AddDeclinedLeases() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -828,6 +847,8 @@ void Lease6CmdsTest::testLease6AddDeclinedLeases() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 1, 0, 0);
+
     checkLease6Stats(66, 1, 1, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -856,6 +877,8 @@ void Lease6CmdsTest::testLease6AddReleasedLeases() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -875,6 +898,8 @@ void Lease6CmdsTest::testLease6AddReleasedLeases() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -903,6 +928,8 @@ void Lease6CmdsTest::testLease6AddRegisteredLeases() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -922,6 +949,8 @@ void Lease6CmdsTest::testLease6AddRegisteredLeases() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 1);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -950,6 +979,8 @@ void Lease6CmdsTest::testLease6AddExisting() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -968,6 +999,8 @@ void Lease6CmdsTest::testLease6AddExisting() {
     string exp_rsp = "IPv6 lease already exists.";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -977,6 +1010,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissing() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -995,6 +1030,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissing() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1009,6 +1046,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingDeclinedLeases() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1028,6 +1067,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingDeclinedLeases() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 1, 0, 0);
+
     checkLease6Stats(66, 1, 1, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1042,6 +1083,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingBadAddr() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1061,6 +1104,8 @@ void Lease6CmdsTest::testLease6AddSubnetIdMissingBadAddr() {
                      "address 2001:ffff::1";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1074,6 +1119,8 @@ void Lease6CmdsTest::testLease6AddNegativeExpireTime() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1093,6 +1140,8 @@ void Lease6CmdsTest::testLease6AddNegativeExpireTime() {
     string exp_rsp = "expiration time must be positive for address 2001:db8:1::3";
     testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1106,6 +1155,8 @@ void Lease6CmdsTest::testLease6AddNegativeCltt() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1127,6 +1178,8 @@ void Lease6CmdsTest::testLease6AddNegativeCltt() {
         "address 2001:db8:1::3";
     testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1140,6 +1193,8 @@ void Lease6CmdsTest::testLease6AddPrefix() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1160,6 +1215,8 @@ void Lease6CmdsTest::testLease6AddPrefix() {
     string exp_rsp = "Lease for prefix 2001:db8:abcd::/48, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 1, 0);
+
     checkLease6Stats(66, 0, 0, 1, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1177,6 +1234,8 @@ void Lease6CmdsTest::testLease6AddFullAddr() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1204,6 +1263,8 @@ void Lease6CmdsTest::testLease6AddFullAddr() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1231,6 +1292,8 @@ void Lease6CmdsTest::testLease6AddComment() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1250,6 +1313,8 @@ void Lease6CmdsTest::testLease6AddComment() {
     string exp_rsp = "Lease for address 2001:db8:1::3, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1269,6 +1334,8 @@ void Lease6CmdsTest::testLease6AddExtendedInfo() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -1304,6 +1371,8 @@ void Lease6CmdsTest::testLease6AddExtendedInfo() {
     string exp_rsp = "Lease for address 2001:db8:1::1, subnet-id 66 added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2448,6 +2517,8 @@ void Lease6CmdsTest::testLease6UpdateNoLease() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2469,6 +2540,8 @@ void Lease6CmdsTest::testLease6UpdateNoLease() {
         "database, in both cases a retry might succeed";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2478,6 +2551,8 @@ void Lease6CmdsTest::testLease6Update() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2498,6 +2573,8 @@ void Lease6CmdsTest::testLease6Update() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2519,6 +2596,8 @@ void Lease6CmdsTest::testLease6UpdateDeclinedLeases() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true, true);
 
+    checkLease6Stats(0, 4, 4, 0, 0);
+
     checkLease6Stats(66, 2, 2, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -2539,6 +2618,8 @@ void Lease6CmdsTest::testLease6UpdateDeclinedLeases() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 3, 0, 0);
+
     checkLease6Stats(66, 2, 1, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -2560,6 +2641,8 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetId() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2578,6 +2661,8 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetId() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2601,6 +2686,8 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetIdDeclinedLeases() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true, true);
 
+    checkLease6Stats(0, 4, 4, 0, 0);
+
     checkLease6Stats(66, 2, 2, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -2619,6 +2706,8 @@ void Lease6CmdsTest::testLease6UpdateNoSubnetIdDeclinedLeases() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 3, 0, 0);
+
     checkLease6Stats(66, 2, 1, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -2642,6 +2731,8 @@ void Lease6CmdsTest::testLease6UpdateForceCreate() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2662,6 +2753,8 @@ void Lease6CmdsTest::testLease6UpdateForceCreate() {
     string exp_rsp = "IPv6 lease added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2682,6 +2775,8 @@ void Lease6CmdsTest::testLease6UpdateForceCreateNoSubnetId() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2701,6 +2796,8 @@ void Lease6CmdsTest::testLease6UpdateForceCreateNoSubnetId() {
     string exp_rsp = "IPv6 lease added.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 1, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2724,6 +2821,8 @@ void Lease6CmdsTest::testLease6UpdateDoNotForceCreate() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2746,6 +2845,8 @@ void Lease6CmdsTest::testLease6UpdateDoNotForceCreate() {
         "database, in both cases a retry might succeed";
     testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2755,6 +2856,8 @@ void Lease6CmdsTest::testLease6UpdateComment() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2775,6 +2878,8 @@ void Lease6CmdsTest::testLease6UpdateComment() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2801,6 +2906,8 @@ void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2836,6 +2943,8 @@ void Lease6CmdsTest::testLease6UpdateExtendedInfo() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -2959,6 +3068,8 @@ void Lease6CmdsTest::testLease6UpdateRegistered() {
         isc::stats::StatsMgr::generateName("subnet", 66, "registered-nas"),
         int64_t(1));
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 1);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -2979,6 +3090,8 @@ void Lease6CmdsTest::testLease6UpdateRegistered() {
     string exp_rsp = "IPv6 lease updated.";
     testCommand(txt, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 1);
@@ -3074,6 +3187,8 @@ void Lease6CmdsTest::testLease6DelByAddrNotFound() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3093,6 +3208,8 @@ void Lease6CmdsTest::testLease6DelByAddrNotFound() {
     // just didn't found the lease.
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3102,6 +3219,8 @@ void Lease6CmdsTest::testLease6DelByDuidNotFound() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3122,6 +3241,8 @@ void Lease6CmdsTest::testLease6DelByDuidNotFound() {
     // just didn't found the lease.
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3134,6 +3255,8 @@ void Lease6CmdsTest::testLease6DelByAddr() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3152,6 +3275,8 @@ void Lease6CmdsTest::testLease6DelByAddr() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 3, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3164,6 +3289,8 @@ void Lease6CmdsTest::testLease6DelByAddrDeclinedLeases() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true, true);
 
+    checkLease6Stats(0, 4, 4, 0, 0);
+
     checkLease6Stats(66, 2, 2, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -3182,6 +3309,8 @@ void Lease6CmdsTest::testLease6DelByAddrDeclinedLeases() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 3, 3, 0, 0);
+
     checkLease6Stats(66, 1, 1, 0, 0);
 
     checkLease6Stats(99, 2, 2, 0, 0);
@@ -3204,6 +3333,8 @@ void Lease6CmdsTest::testLease6DelByAddrRegistered() {
         isc::stats::StatsMgr::generateName("subnet", 66, "registered-nas"),
         int64_t(1));
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 1);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3222,6 +3353,8 @@ void Lease6CmdsTest::testLease6DelByAddrRegistered() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3234,6 +3367,8 @@ void Lease6CmdsTest::testLease6DelByAddrBadParam() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3249,6 +3384,8 @@ void Lease6CmdsTest::testLease6DelByAddrBadParam() {
     string exp_rsp = "Invalid IPv6 address specified: 192.0.2.1";
     testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3269,6 +3406,8 @@ void Lease6CmdsTest::testLease6DelByAddrPrefix() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3281,9 +3420,13 @@ void Lease6CmdsTest::testLease6DelByAddrPrefix() {
     lmptr_->addLease(l);
 
     StatsMgr::instance().setValue(StatsMgr::generateName("subnet", 66,
-                                                         "assigned-pds" ),
+                                                         "assigned-pds"),
                                   int64_t(1));
 
+    StatsMgr::instance().setValue("assigned-pds", int64_t(1));
+
+    checkLease6Stats(0, 0, 0, 1, 0);
+
     checkLease6Stats(66, 0, 0, 1, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3302,6 +3445,8 @@ void Lease6CmdsTest::testLease6DelByAddrPrefix() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3314,6 +3459,8 @@ void Lease6CmdsTest::testLease6DelByDuid() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3334,6 +3481,8 @@ void Lease6CmdsTest::testLease6DelByDuid() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 3, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3346,6 +3495,8 @@ void Lease6CmdsTest::testLease6Wipe() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3363,6 +3514,8 @@ void Lease6CmdsTest::testLease6Wipe() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 2, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3380,6 +3533,8 @@ void Lease6CmdsTest::testLease6WipeAll() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3397,6 +3552,8 @@ void Lease6CmdsTest::testLease6WipeAll() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3414,6 +3571,8 @@ void Lease6CmdsTest::testLease6WipeAllNoArgs() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3428,6 +3587,8 @@ void Lease6CmdsTest::testLease6WipeAllNoArgs() {
     // The status expected is success. The lease should be deleted.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3445,6 +3606,8 @@ void Lease6CmdsTest::testLease6WipeNoLeases() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3460,6 +3623,8 @@ void Lease6CmdsTest::testLease6WipeNoLeases() {
     string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66";
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3469,6 +3634,8 @@ void Lease6CmdsTest::testLease6WipeNoLeasesAll() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3484,6 +3651,8 @@ void Lease6CmdsTest::testLease6WipeNoLeasesAll() {
     string exp_rsp = "Deleted 0 IPv6 lease(s) from subnet(s) 66 99";
     testCommand(cmd, CONTROL_RESULT_EMPTY, exp_rsp);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3517,6 +3686,8 @@ void Lease6CmdsTest::testLease6BulkApply() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3557,6 +3728,8 @@ void Lease6CmdsTest::testLease6BulkApply() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 3, 0, 0, 0);
@@ -3624,6 +3797,8 @@ void Lease6CmdsTest::testLease6BulkApplyAddsOnly() {
     // Initialize lease manager (true = v6, false = don't add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 0, 0, 0, 0);
@@ -3654,6 +3829,8 @@ void Lease6CmdsTest::testLease6BulkApplyAddsOnly() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 2, 0, 0, 0);
+
     checkLease6Stats(66, 1, 0, 0, 0);
 
     checkLease6Stats(99, 1, 0, 0, 0);
@@ -3728,6 +3905,8 @@ void Lease6CmdsTest::testLease6BulkApplyUpdatesOnly() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3758,6 +3937,8 @@ void Lease6CmdsTest::testLease6BulkApplyUpdatesOnly() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3777,6 +3958,8 @@ void Lease6CmdsTest::testLease6BulkApplyUpdatesOnlyExtendedInfo() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3823,6 +4006,8 @@ void Lease6CmdsTest::testLease6BulkApplyUpdatesOnlyExtendedInfo() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3869,6 +4054,8 @@ void Lease6CmdsTest::testLease6BulkApplyDeletesOnly() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3895,6 +4082,8 @@ void Lease6CmdsTest::testLease6BulkApplyDeletesOnly() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 2, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3908,6 +4097,8 @@ void Lease6CmdsTest::testLease6BulkApplyDeleteNonExiting() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3936,6 +4127,8 @@ void Lease6CmdsTest::testLease6BulkApplyDeleteNonExiting() {
     ASSERT_TRUE(resp);
     ASSERT_EQ(Element::map, resp->getType());
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -3966,6 +4159,8 @@ void Lease6CmdsTest::testLease6BulkApplyRollback() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, true);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -4006,6 +4201,8 @@ void Lease6CmdsTest::testLease6BulkApplyRollback() {
     // The status expected is success.
     testCommand(cmd, CONTROL_RESULT_ERROR, exp_rsp);
 
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     checkLease6Stats(99, 2, 0, 0, 0);
@@ -4372,6 +4569,8 @@ void Lease6CmdsTest::testLease6ConflictingAdd() {
     ASSERT_FALSE(lease);
 
     // Verify stats show no leases.
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 
     // Lock the address.
@@ -4399,6 +4598,8 @@ void Lease6CmdsTest::testLease6ConflictingAdd() {
     ASSERT_FALSE(lease);
 
     // Stats should not have changed.
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
 }
 
@@ -4409,6 +4610,8 @@ void Lease6CmdsTest::testLease6ConflictingUpdate() {
     initLeaseMgr(true, true);
 
     // Verify stats show no leases.
+    checkLease6Stats(0, 4, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
 
     // Make sure the lease exists.
@@ -4444,6 +4647,11 @@ void Lease6CmdsTest::testLease6ConflictingUpdate() {
 
     // Lease should not have been changed.
     EXPECT_EQ(original_lease, *lease);
+
+    // Stats should not have changed.
+    checkLease6Stats(0, 4, 0, 0, 0);
+
+    checkLease6Stats(66, 2, 0, 0, 0);
 }
 
 void Lease6CmdsTest::testLease6ConflictingBulkApplyAdd() {
@@ -4452,7 +4660,10 @@ void Lease6CmdsTest::testLease6ConflictingBulkApplyAdd() {
     // Initialize lease manager (true = v6, true = add leases)
     initLeaseMgr(true, false);
 
+    checkLease6Stats(0, 0, 0, 0, 0);
+
     checkLease6Stats(66, 0, 0, 0, 0);
+
     checkLease6Stats(99, 0, 0, 0, 0);
 
     // Lock the address.
@@ -4492,7 +4703,10 @@ void Lease6CmdsTest::testLease6ConflictingBulkApplyAdd() {
     // The status expected is success.
     auto rsp = testCommand(cmd, CONTROL_RESULT_SUCCESS, exp_rsp);
 
+    checkLease6Stats(0, 2, 0, 0, 0);
+
     checkLease6Stats(66, 2, 0, 0, 0);
+
     checkLease6Stats(99, 0, 0, 0, 0);
 
     //  Check that the leases we inserted are stored.
index ddde5909effa3d51aa193b382a093a27327d2731..e5f3cf0e831d7f1343224519b57038ee49c6c1a5 100644 (file)
@@ -442,6 +442,7 @@ public:
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 99, "declined-addresses"),
                         int64_t(2));
+                    isc::stats::StatsMgr::instance().setValue("declined-addresses", int64_t(4));
                 } else {
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 66, "declined-addresses"),
@@ -449,6 +450,7 @@ public:
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 99, "declined-addresses"),
                         int64_t(0));
+                    isc::stats::StatsMgr::instance().setValue("declined-addresses", int64_t(0));
                 }
                 isc::stats::StatsMgr::instance().setValue(
                         isc::stats::StatsMgr::generateName("subnet", 66, "assigned-nas" ),
@@ -469,6 +471,7 @@ public:
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 88, "declined-addresses"),
                         int64_t(2));
+                    isc::stats::StatsMgr::instance().setValue("declined-addresses", int64_t(4));
                 } else {
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 44, "declined-addresses"),
@@ -476,6 +479,7 @@ public:
                     isc::stats::StatsMgr::instance().setValue(
                             isc::stats::StatsMgr::generateName("subnet", 88, "declined-addresses"),
                         int64_t(0));
+                    isc::stats::StatsMgr::instance().setValue("declined-addresses", int64_t(0));
                 }
                 isc::stats::StatsMgr::instance().setValue(
                         isc::stats::StatsMgr::generateName("subnet", 44, "assigned-addresses"),
index 0cd80a049cacba9f12b34da337cccfe990387990..5bce27ae3a026e312a87fd63dfae0e2ade6fa498 100644 (file)
@@ -831,11 +831,11 @@ TEST_F(StatCmdsTest, statLease4GetValid) {
         "        \"assigned-addresses\", \"declined-addresses\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 256, 300, 2, 3 ],\n"
+        "       [ 10, 256, 300, 5, 3 ],\n"
         "       [ 20, 16, 10, 3, 0 ],\n"
         "       [ 30, 256, 0, 0, 0 ],\n"
         "       [ 40, 16, 4, 4, 0 ],\n"
-        "       [ 50, 256, 2, 1, 1 ]\n"
+        "       [ 50, 256, 2, 2, 1 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
         "}\n"
@@ -854,11 +854,11 @@ TEST_F(StatCmdsTest, statLease4GetValid) {
         "        \"assigned-addresses\", \"declined-addresses\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 256, 300, 2, 3 ],\n"
+        "       [ 10, 256, 300, 5, 3 ],\n"
         "       [ 20, 16, 10, 3, 0 ],\n"
         "       [ 30, 256, 0, 0, 0 ],\n"
         "       [ 40, 16, 4, 4, 0 ],\n"
-        "       [ 50, 256, 2, 1, 1 ]\n"
+        "       [ 50, 256, 2, 2, 1 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
         "}\n"
@@ -905,7 +905,7 @@ TEST_F(StatCmdsTest, statLease4GetValid) {
         "        \"assigned-addresses\", \"declined-addresses\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 256, 300, 2, 3 ],\n"
+        "       [ 10, 256, 300, 5, 3 ],\n"
         "       [ 20, 16, 10, 3, 0 ],\n"
         "       [ 30, 256, 0, 0, 0 ]\n"
         "   ],\n"
@@ -961,7 +961,7 @@ TEST_F(StatCmdsTest, statLease4GetValid) {
         "   \"rows\": [\n"
         "       [ 30, 256, 0, 0, 0 ],\n"
         "       [ 40, 16, 4, 4, 0 ],\n"
-        "       [ 50, 256, 2, 1, 1 ]\n"
+        "       [ 50, 256, 2, 2, 1 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
         "}\n"
@@ -1253,9 +1253,9 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "        \"cumulative-assigned-pds\", \"assigned-pds\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n"
+        "       [ 10, 65536, 10000, 5, 3, 0, 0, 0 ],\n"
         "       [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ],\n"
         "       [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n"
         "       [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n"
         "   ],\n"
@@ -1277,9 +1277,9 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "        \"cumulative-assigned-pds\", \"assigned-pds\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n"
+        "       [ 10, 65536, 10000, 5, 3, 0, 0, 0 ],\n"
         "       [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ],\n"
         "       [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n"
         "       [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n"
         "   ],\n"
@@ -1330,9 +1330,9 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "        \"cumulative-assigned-pds\", \"assigned-pds\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n"
+        "       [ 10, 65536, 10000, 5, 3, 0, 0, 0 ],\n"
         "       [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ]\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
         "}\n"
@@ -1359,7 +1359,7 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "   ],\n"
         "   \"rows\": [\n"
         "       [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ],\n"
         "       [ 40, 16777216, 0, 0, 0, 0, 0, 0 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
@@ -1386,7 +1386,7 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "        \"cumulative-assigned-pds\", \"assigned-pds\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ],\n"
         "       [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n"
         "       [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n"
         "   ],\n"
@@ -1414,7 +1414,7 @@ TEST_F(StatCmdsTest, statLease6GetValid) {
         "        \"cumulative-assigned-pds\", \"assigned-pds\"\n"
         "   ],\n"
         "   \"rows\": [\n"
-        "       [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n"
+        "       [ 30, 16, 2, 2, 1, 65536, 4, 3 ],\n"
         "       [ 40, 16777216, 0, 0, 0, 0, 0, 0 ]\n"
         "   ],\n"
         "   \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n"
index e9f953b46dd07ad110db2eeeb8094a7b83ffc748..ad758729b6e7b0f99001a0d4a53b82e6b3137301 100644 (file)
@@ -4209,7 +4209,7 @@ void deleteAssignedLease(Lease4Ptr lease) {
             if (pool) {
                 StatsMgr::instance().addValue(StatsMgr::generateName("subnet", subnet->getID(),
                                               StatsMgr::generateName("pool", pool->getID(),
-                                                                      "assigned-addresses")),
+                                                                     "assigned-addresses")),
                                               static_cast<int64_t>(-1));
             }
         }
index eadc17f5507512fde46f18d9492618616b01eaea..020d17682b0e239545391b23990bf1c72ec54720 100644 (file)
@@ -59,6 +59,7 @@ TEST_F(AllocEngine4Test, simpleAlloc4) {
     ASSERT_TRUE(engine);
 
     // Assigned addresses should be zero.
+    EXPECT_TRUE(testStatistics("assigned-addresses", 0));
     EXPECT_TRUE(testStatistics("assigned-addresses", 0, subnet_->getID()));
 
     // Get the cumulative count of assigned addresses.
@@ -335,6 +336,7 @@ TEST_F(AllocEngine4Test, fakeAlloc4) {
     ASSERT_TRUE(engine);
 
     // Assigned addresses should be zero.
+    EXPECT_TRUE(testStatistics("assigned-addresses", 0));
     EXPECT_TRUE(testStatistics("assigned-addresses", 0, subnet_->getID()));
 
     // Get the cumulative count of assigned addresses.
@@ -561,6 +563,7 @@ TEST_F(AllocEngine4Test, simpleRenew4) {
     ASSERT_NO_THROW(engine.reset(new AllocEngine(0)));
     ASSERT_TRUE(engine);
 
+    EXPECT_TRUE(testStatistics("assigned-addresses", 0));
     EXPECT_TRUE(testStatistics("assigned-addresses", 0, subnet_->getID()));
     int64_t cumulative = getStatistics("cumulative-assigned-addresses",
                                        subnet_->getID());
@@ -1737,6 +1740,7 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
 
     IOAddress addr("192.0.2.105");
 
+    EXPECT_TRUE(testStatistics("assigned-addresses", 0));
     EXPECT_TRUE(testStatistics("assigned-addresses", 0, subnet_->getID()));
     int64_t cumulative = getStatistics("cumulative-assigned-addresses",
                                        subnet_->getID());