LeaseStatsRow row;
while (query->getNextRow(row)) {
if (row.lease_state_ == Lease::STATE_DEFAULT) {
- // Set subnet level value.
- stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
+ // Add to subnet level value.
+ stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
"assigned-addresses"),
row.state_count_);
} else if (row.lease_state_ == Lease::STATE_DECLINED) {
// Add to the global value.
stats_mgr.addValue("declined-addresses", row.state_count_);
+
+ // Add to subnet level value.
+ stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
+ "assigned-addresses"),
+ row.state_count_);
}
}
}
if (!stats_mgr.getObservation("cumulative-assigned-nas")) {
stats_mgr.setValue("cumulative-assigned-nas", zero);
}
+
if (!stats_mgr.getObservation("cumulative-assigned-pds")) {
stats_mgr.setValue("cumulative-assigned-pds", zero);
}
switch(row.lease_type_) {
case Lease::TYPE_NA:
if (row.lease_state_ == Lease::STATE_DEFAULT) {
- // Set subnet level value.
- stats_mgr.setValue(StatsMgr::
+ // Add subnet level value.
+ stats_mgr.addValue(StatsMgr::
generateName("subnet", row.subnet_id_,
"assigned-nas"),
row.state_count_);
// Add to the global value.
stats_mgr.addValue("declined-addresses", row.state_count_);
+
+ // Add subnet level value.
+ stats_mgr.addValue(StatsMgr::
+ generateName("subnet", row.subnet_id_,
+ "assigned-nas"),
+ row.state_count_);
}
break;
makeLease4("192.0.1.4", subnet_id);
// Update the expected stats list for subnet 1.
- expectedStats[subnet_id - 1]["assigned-addresses"] = 2;
+ expectedStats[subnet_id - 1]["assigned-addresses"] = 3; // 2 + 1 declined
expectedStats[subnet_id - 1]["declined-addresses"] = 1;
// Now let's add leases to subnet 2.
makeLease4("192.0.2.2", subnet_id, Lease::STATE_DECLINED);
// Update the expected stats.
+ expectedStats[subnet_id - 1]["assigned-addresses"] = 1; // 0 + 1 declined
expectedStats[subnet_id - 1]["declined-addresses"] = 1;
// Now Recount the stats.
// Delete some leases from subnet, and update the expected stats.
EXPECT_TRUE(lmptr_->deleteLease(lease1));
- expectedStats[0]["assigned-addresses"] = 1;
+ expectedStats[0]["assigned-addresses"] = 2;
EXPECT_TRUE(lmptr_->deleteLease(lease2));
+ expectedStats[0]["assigned-addresses"] = 1;
expectedStats[0]["declined-addresses"] = 0;
// Recount the stats.
makeLease6(Lease::TYPE_NA, "3001:1::1", 0, subnet_id);
Lease6Ptr lease2 = makeLease6(Lease::TYPE_NA, "3001:1::2", 0, subnet_id);
makeLease6(Lease::TYPE_NA, "3001:1::3", 0, subnet_id);
- expectedStats[subnet_id - 1]["assigned-nas"] = 3;
+ expectedStats[subnet_id - 1]["assigned-nas"] = 5; // 3 + 2 declined
// Insert two declined NAs.
makeLease6(Lease::TYPE_NA, "3001:1::4", 0, subnet_id,
// Insert two assigned NAs.
makeLease6(Lease::TYPE_NA, "2001:db81::1", 0, subnet_id);
makeLease6(Lease::TYPE_NA, "2001:db81::2", 0, subnet_id);
- expectedStats[subnet_id - 1]["assigned-nas"] = 2;
+ expectedStats[subnet_id - 1]["assigned-nas"] = 3; // 2 + 1 declined
// Insert one declined NA.
Lease6Ptr lease3 = makeLease6(Lease::TYPE_NA, "2001:db81::3", 0, subnet_id,
// Delete some leases and update the expected stats.
EXPECT_TRUE(lmptr_->deleteLease(lease2));
- expectedStats[0]["assigned-nas"] = 2;
+ expectedStats[0]["assigned-nas"] = 4;
EXPECT_TRUE(lmptr_->deleteLease(lease3));
+ expectedStats[1]["assigned-nas"] = 2;
expectedStats[1]["declined-addresses"] = 0;
// Recount the stats.