From a7260a26c278071628789ab0c75d73ef0059e194 Mon Sep 17 00:00:00 2001 From: Dan Theisen Date: Wed, 6 Jul 2022 13:36:08 -0600 Subject: [#2419] Fix statistics (add v4-reservation-conflicts) unit tests for dhcp4 --- src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc | 3 ++- src/bin/dhcp4/tests/shared_network_unittest.cc | 2 +- src/lib/dhcpsrv/alloc_engine.cc | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 69580a0c25..4f38e126ec 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -648,7 +648,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) { "v4-allocation-fail-shared-network", "v4-allocation-fail-subnet", "v4-allocation-fail-no-pools", - "v4-allocation-fail-classes" + "v4-allocation-fail-classes", + "v4-reservation-conflicts" }; // preparing the schema which check if all statistics are set to zero diff --git a/src/bin/dhcp4/tests/shared_network_unittest.cc b/src/bin/dhcp4/tests/shared_network_unittest.cc index 5fb3b30efc..8e9601f969 100644 --- a/src/bin/dhcp4/tests/shared_network_unittest.cc +++ b/src/bin/dhcp4/tests/shared_network_unittest.cc @@ -1771,7 +1771,7 @@ TEST_F(Dhcpv4SharedNetworkTest, reservationInSharedNetworkTwoClientsSameIdentifi // Ensure stats are being recorded for HR conflicts ObservationPtr subnet_conflicts = StatsMgr::instance().getObservation( - "subnet[100].reservation-conflicts"); + "subnet[10].reservation-conflicts"); ASSERT_TRUE(subnet_conflicts); ASSERT_EQ(1, subnet_conflicts->getInteger().first); ObservationPtr global_conflicts = StatsMgr::instance().getObservation( diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 350cc46758..444c95fca2 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -3703,7 +3703,7 @@ AllocEngine::discoverLease4(AllocEngine::ClientContext4& ctx) { "(no lease info)"); StatsMgr::instance().addValue(StatsMgr::generateName( "subnet", - new_lease->subnet_id_, + ctx.conflicting_lease_->subnet_id_, "reservation-conflicts"), static_cast(1)); StatsMgr::instance().addValue("v4-reservation-conflicts", -- cgit v1.2.3