+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.
| | | 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 |
| 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. |
| | | 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 |
| | | 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 |
| | | 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. |
+----------------------------------------------------+----------------+------------------------------------+
| | | 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 |
| 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 |
| | | 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 |
| | | 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. |
| | | 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 |
| | | 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. |
| | | 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 |
| | | 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. |
+---------------------------------------------------+----------------+------------------------------------+
| | | 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 |
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(
/// @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.
// 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);
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);
// 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);
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);
// 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);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// 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);
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);
// 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);
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);
// 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);
"address 192.0.55.1";
testCommand(txt, CONTROL_RESULT_CONFLICT, exp_rsp);
+ checkLease4Stats(0, 0, 0);
+
checkLease4Stats(44, 0, 0);
checkLease4Stats(88, 0, 0);
// 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);
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);
// 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);
"address 192.0.2.202";
testCommand(txt, CONTROL_RESULT_ERROR, exp_rsp);
+ checkLease4Stats(0, 0, 0);
+
checkLease4Stats(44, 0, 0);
checkLease4Stats(88, 0, 0);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
"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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true, true);
+ checkLease4Stats(0, 4, 4);
+
checkLease4Stats(44, 2, 2);
checkLease4Stats(88, 2, 2);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true, true);
+ checkLease4Stats(0, 4, 4);
+
checkLease4Stats(44, 2, 2);
checkLease4Stats(88, 2, 2);
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);
// 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);
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);
// 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);
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);
// 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);
"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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true, true);
+ checkLease4Stats(0, 4, 4);
+
checkLease4Stats(44, 2, 2);
checkLease4Stats(88, 2, 2);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// Initialize lease manager (false = v4, true = add leases)
initLeaseMgr(false, true);
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
checkLease4Stats(88, 2, 0);
// 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);
// 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);
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);
// 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);
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);
ASSERT_FALSE(lease);
// Verify stats show no leases.
+ checkLease4Stats(0, 0, 0);
+
checkLease4Stats(44, 0, 0);
// Lock the address.
ASSERT_FALSE(lease);
// Stats should not have changed.
+ checkLease4Stats(0, 0, 0);
+
checkLease4Stats(44, 0, 0);
}
initLeaseMgr(false, true);
// Verify stats show no leases.
+ checkLease4Stats(0, 4, 0);
+
checkLease4Stats(44, 2, 0);
// Make sure the lease exists.
// 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() {
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.
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
"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);
// 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);
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);
// 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);
"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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
"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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
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);
// 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);
"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);
// 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);
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);
// 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);
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);
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);
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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
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);
// 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);
// 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);
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);
// 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);
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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
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);
// 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);
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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
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);
// 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);
// 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);
ASSERT_FALSE(lease);
// Verify stats show no leases.
+ checkLease6Stats(0, 0, 0, 0, 0);
+
checkLease6Stats(66, 0, 0, 0, 0);
// Lock the address.
ASSERT_FALSE(lease);
// Stats should not have changed.
+ checkLease6Stats(0, 0, 0, 0, 0);
+
checkLease6Stats(66, 0, 0, 0, 0);
}
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.
// 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() {
// 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.
// 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.
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"),
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" ),
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"),
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"),
" \"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"
" \"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"
" \"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"
" \"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"
" \"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"
" \"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"
" \"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"
" ],\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"
" \"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"
" \"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"
if (pool) {
StatsMgr::instance().addValue(StatsMgr::generateName("subnet", subnet->getID(),
StatsMgr::generateName("pool", pool->getID(),
- "assigned-addresses")),
+ "assigned-addresses")),
static_cast<int64_t>(-1));
}
}
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.
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.
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());
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());