summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranciszek Gorski <fagorski9@gmail.com>2019-08-26 11:54:48 +0200
committerMarcin Siodelski <marcin@isc.org>2019-09-06 11:34:54 +0200
commitb56fa9d4918d4aca1eab4bb70ff304e7aee1df9e (patch)
tree10289e14dabb443e286a1b74627aa536484b56f9
parentupdated ChangeLog (diff)
downloadkea-b56fa9d4918d4aca1eab4bb70ff304e7aee1df9e.tar.xz
kea-b56fa9d4918d4aca1eab4bb70ff304e7aee1df9e.zip
[755-Kea-DHCP-servers-observations-should-be-reset-to-some-initial-values-upon-restart-or-reconfiguration] add initialization of all statistisc during set up
-rw-r--r--src/bin/dhcp4/dhcp4_srv.cc42
-rw-r--r--src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc46
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc49
-rw-r--r--src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc124
-rw-r--r--src/bin/dhcp6/tests/dhcp6_srv_unittest.cc11
-rw-r--r--src/bin/dhcp6/tests/dhcp6_test_utils.cc9
-rw-r--r--src/bin/dhcp6/tests/infrequest_unittest.cc12
-rw-r--r--src/bin/dhcp6/tests/sarr_unittest.cc16
8 files changed, 288 insertions, 21 deletions
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index d6614f737b..b84e5c3be3 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -481,6 +481,48 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t server_port, uint16_t client_port,
return;
}
+ // Initializing all observations with zero value
+ isc::stats::StatsMgr::instance().setValue("pkt4-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-discover-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-offer-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-request-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-ack-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-nak-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-release-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-decline-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-inform-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-unknown-received",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("pkt4-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-offer-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-ack-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-nak-sent",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("pkt4-parse-failed",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt4-receive-drop",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("reclaimed-leases",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("declined-addresses",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("reclaimed-declined-addresses",
+ static_cast<int64_t>(0));
shutdown_ = false;
}
diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
index 1793898ca9..f06f62cf27 100644
--- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
@@ -21,6 +21,7 @@
#include <hooks/hooks_manager.h>
#include <log/logger_support.h>
#include <stats/stats_mgr.h>
+#include <util/boost_time_utils.h>
#include <testutils/io_utils.h>
#include <testutils/unix_control_client.h>
#include <testutils/sandbox.h>
@@ -550,7 +551,50 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) {
// Check statistic-get-all
sendUnixCommand("{ \"command\" : \"statistic-get-all\", "
" \"arguments\": {}}", response);
- EXPECT_EQ("{ \"arguments\": { }, \"result\": 0 }", response);
+
+ // preparing the schema which check if all statistics are set to zero
+ std::string stats_get_all = "{ \"arguments\": { "
+ "\"declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("declined-addresses")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-ack-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-ack-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-ack-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-ack-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-decline-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-decline-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-discover-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-discover-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-inform-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-inform-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-nak-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-nak-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-nak-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-nak-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-offer-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-offer-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-offer-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-offer-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-parse-failed\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-parse-failed")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-receive-drop\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-receive-drop")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-release-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-release-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-request-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-request-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt4-unknown-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt4-unknown-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"reclaimed-declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-declined-addresses")
+ ->getInteger().second) + "\" ] ], "
+ "\"reclaimed-leases\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-leases")
+ ->getInteger().second) + "\" ] ] }, "
+ "\"result\": 0 }";
+
+ EXPECT_EQ(stats_get_all, response);
// Check statistic-reset
sendUnixCommand("{ \"command\" : \"statistic-reset\", "
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index fd761877ef..a82a0e634e 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -216,7 +216,54 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t server_port, uint16_t client_port)
LOG_ERROR(dhcp6_logger, DHCP6_SRV_CONSTRUCT_ERROR).arg(e.what());
return;
}
-
+ // Initializing all observations with zero value
+ isc::stats::StatsMgr::instance().setValue("pkt6-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-solicit-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-advertise-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-request-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-reply-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-renew-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-rebind-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-release-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-decline-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-infrequest-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-query-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-response-received",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-unknown-received",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("pkt6-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-advertise-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-reply-sent",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-dhcpv4-response-sent",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("pkt6-parse-failed",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("pkt6-receive-drop",
+ static_cast<int64_t>(0));
+
+ isc::stats::StatsMgr::instance().setValue("reclaimed-leases",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("declined-addresses",
+ static_cast<int64_t>(0));
+ isc::stats::StatsMgr::instance().setValue("reclaimed-declined-addresses",
+ static_cast<int64_t>(0));
// All done, so can proceed
shutdown_ = false;
}
diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
index 08cbf13e5c..8cdb0a4f62 100644
--- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
@@ -21,6 +21,7 @@
#include <testutils/io_utils.h>
#include <testutils/unix_control_client.h>
#include <testutils/sandbox.h>
+#include <util/boost_time_utils.h>
#include "marker_file.h"
#include "test_libraries.h"
@@ -1115,6 +1116,129 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlLeasesReclaimRemove) {
ASSERT_FALSE(lease1);
}
+// Tests that the server properly responds to statistics commands. Note this
+// is really only intended to verify that the appropriate Statistics handler
+// is called based on the command. It is not intended to be an exhaustive
+// test of Dhcpv6 statistics.
+TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
+ createUnixChannelServer();
+ std::string response;
+
+ // Check statistic-get
+ sendUnixCommand("{ \"command\" : \"statistic-get\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\" }}", response);
+ EXPECT_EQ("{ \"arguments\": { }, \"result\": 0 }", response);
+
+ // Check statistic-get-all
+ sendUnixCommand("{ \"command\" : \"statistic-get-all\", "
+ " \"arguments\": {}}", response);
+
+ // preparing the schema which check if all statistics are set to zero
+ std::string stats_get_all = "{ \"arguments\": { "
+ "\"declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("declined-addresses")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-advertise-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-advertise-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-advertise-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-advertise-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-decline-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-decline-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-dhcpv4-query-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-dhcpv4-query-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-dhcpv4-response-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-dhcpv4-response-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-dhcpv4-response-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-dhcpv4-response-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-infrequest-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-infrequest-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-parse-failed\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-parse-failed")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-rebind-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-rebind-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-receive-drop\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-receive-drop")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-release-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-release-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-renew-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-renew-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-reply-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-reply-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-reply-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-reply-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-request-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-request-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-sent\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-sent")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-solicit-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-solicit-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"pkt6-unknown-received\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("pkt6-unknown-received")
+ ->getInteger().second) + "\" ] ], "
+ "\"reclaimed-declined-addresses\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-declined-addresses")
+ ->getInteger().second) + "\" ] ], "
+ "\"reclaimed-leases\": [ [ 0, \"" + isc::util::ptimeToText(StatsMgr::instance().getObservation("reclaimed-leases")
+ ->getInteger().second) + "\" ] ] }, "
+ "\"result\": 0 }";
+
+ EXPECT_EQ(stats_get_all, response);
+
+ // Check statistic-reset
+ sendUnixCommand("{ \"command\" : \"statistic-reset\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\" }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-reset-all
+ sendUnixCommand("{ \"command\" : \"statistic-reset-all\", "
+ " \"arguments\": {}}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": "
+ "\"All statistics reset to neutral values.\" }", response);
+
+ // Check statistic-remove
+ sendUnixCommand("{ \"command\" : \"statistic-remove\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\" }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-remove-all
+ sendUnixCommand("{ \"command\" : \"statistic-remove-all\", "
+ " \"arguments\": {}}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics removed.\" }",
+ response);
+
+ // Check statistic-sample-age-set
+ sendUnixCommand("{ \"command\" : \"statistic-sample-age-set\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-sample-age-set-all
+ sendUnixCommand("{ \"command\" : \"statistic-sample-age-set-all\", "
+ " \"arguments\": {"
+ " \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics duration limit are set.\" }",
+ response);
+
+ // Check statistic-sample-count-set
+ sendUnixCommand("{ \"command\" : \"statistic-sample-count-set\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-sample-count-set-all
+ sendUnixCommand("{ \"command\" : \"statistic-sample-count-set-all\", "
+ " \"arguments\": {"
+ " \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics count limit are set.\" }",
+ response);
+}
+
// Tests that the server properly responds to shtudown command sent
// via ControlChannel
TEST_F(CtrlChannelDhcpv6SrvTest, listCommands) {
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index c01bf663c5..764d42b5d3 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -2589,13 +2589,16 @@ TEST_F(Dhcpv6SrvTest, receiveParseFailedStat) {
// And pretend it's packet is only 3 bytes long.
pkt->data_.resize(3);
- // Check that those statistics are not set before the test
+ // Check that those statistics are set before the test.
+ // All should be present because we initialize
+ // all of them in server constructor. This piece of code is mainly reffered
+ // to previous situation when Kea used lazy initialization of statistics.
ObservationPtr pkt6_rcvd = mgr.getObservation("pkt6-received");
ObservationPtr parse_fail = mgr.getObservation("pkt6-parse-failed");
ObservationPtr recv_drop = mgr.getObservation("pkt6-receive-drop");
- EXPECT_FALSE(pkt6_rcvd);
- EXPECT_FALSE(parse_fail);
- EXPECT_FALSE(recv_drop);
+ EXPECT_TRUE(pkt6_rcvd);
+ EXPECT_TRUE(parse_fail);
+ EXPECT_TRUE(recv_drop);
// Simulate that we have received that traffic
srv.fakeReceive(pkt);
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc
index 9ff1706544..106a7d366e 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc
@@ -770,11 +770,14 @@ Dhcpv6SrvTest::testReceiveStats(uint8_t pkt_type, const std::string& stat_name)
// And pretend it's packet of a different type
pkt->data_[0] = pkt_type;
- // Check that those statistics are not set before the test
+ // Check that those statistics are set before the test.
+ // All should be present because we initialize
+ // all of them in server constructor. This piece of code is mainly reffered
+ // to previous situation when Kea used lazy initialization of statistics.
ObservationPtr pkt6_rcvd = mgr.getObservation("pkt6-received");
ObservationPtr tested_stat = mgr.getObservation(stat_name);
- EXPECT_FALSE(pkt6_rcvd);
- EXPECT_FALSE(tested_stat);
+ EXPECT_TRUE(pkt6_rcvd);
+ EXPECT_TRUE(tested_stat);
// Simulate that we have received that traffic
srv.fakeReceive(pkt);
diff --git a/src/bin/dhcp6/tests/infrequest_unittest.cc b/src/bin/dhcp6/tests/infrequest_unittest.cc
index bf0cd43706..42ab8da99a 100644
--- a/src/bin/dhcp6/tests/infrequest_unittest.cc
+++ b/src/bin/dhcp6/tests/infrequest_unittest.cc
@@ -316,17 +316,19 @@ TEST_F(InfRequestTest, infRequestStats) {
getCfgSubnets6()->getAll();
ASSERT_EQ(1, subnets->size());
- // Ok, let's check the statistics. None should be present.
+ // Ok, let's check the statistics. All should be present because we initialize
+ // all of them in server constructor. This piece of code is mainly reffered
+ // to previous situation when Kea used lazy initialization of statistics.
using namespace isc::stats;
StatsMgr& mgr = StatsMgr::instance();
ObservationPtr pkt6_rcvd = mgr.getObservation("pkt6-received");
ObservationPtr pkt6_infreq_rcvd = mgr.getObservation("pkt6-infrequest-received");
ObservationPtr pkt6_reply_sent = mgr.getObservation("pkt6-reply-sent");
ObservationPtr pkt6_sent = mgr.getObservation("pkt6-sent");
- EXPECT_FALSE(pkt6_rcvd);
- EXPECT_FALSE(pkt6_infreq_rcvd);
- EXPECT_FALSE(pkt6_reply_sent);
- EXPECT_FALSE(pkt6_sent);
+ EXPECT_TRUE(pkt6_rcvd);
+ EXPECT_TRUE(pkt6_infreq_rcvd);
+ EXPECT_TRUE(pkt6_reply_sent);
+ EXPECT_TRUE(pkt6_sent);
// Perform 2-way exchange (Inf-request/reply)
client.requestOption(D6O_NAME_SERVERS);
diff --git a/src/bin/dhcp6/tests/sarr_unittest.cc b/src/bin/dhcp6/tests/sarr_unittest.cc
index 120cb5a739..a0dfab6f15 100644
--- a/src/bin/dhcp6/tests/sarr_unittest.cc
+++ b/src/bin/dhcp6/tests/sarr_unittest.cc
@@ -492,7 +492,9 @@ TEST_F(SARRTest, sarrStats) {
getCfgSubnets6()->getAll();
ASSERT_EQ(2, subnets->size());
- // Ok, let's check the statistics. None should be present.
+ // Ok, let's check the statistics. All should be present because we initialize
+ // all of them in server constructor. This piece of code is mainly reffered
+ // to previous situation when Kea used lazy initialization of statistics.
using namespace isc::stats;
StatsMgr& mgr = StatsMgr::instance();
ObservationPtr pkt6_rcvd = mgr.getObservation("pkt6-received");
@@ -501,12 +503,12 @@ TEST_F(SARRTest, sarrStats) {
ObservationPtr pkt6_request_rcvd = mgr.getObservation("pkt6-request-received");
ObservationPtr pkt6_reply_sent = mgr.getObservation("pkt6-reply-sent");
ObservationPtr pkt6_sent = mgr.getObservation("pkt6-sent");
- EXPECT_FALSE(pkt6_rcvd);
- EXPECT_FALSE(pkt6_solicit_rcvd);
- EXPECT_FALSE(pkt6_adv_sent);
- EXPECT_FALSE(pkt6_request_rcvd);
- EXPECT_FALSE(pkt6_reply_sent);
- EXPECT_FALSE(pkt6_sent);
+ EXPECT_TRUE(pkt6_rcvd);
+ EXPECT_TRUE(pkt6_solicit_rcvd);
+ EXPECT_TRUE(pkt6_adv_sent);
+ EXPECT_TRUE(pkt6_request_rcvd);
+ EXPECT_TRUE(pkt6_reply_sent);
+ EXPECT_TRUE(pkt6_sent);
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());