mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[#1196] Checkpoint: added bug trigger tests
This commit is contained in:
parent
e959c14e1e
commit
dcc64131e7
@ -858,4 +858,14 @@ TEST_F(CqlLeaseMgrTest, leaseStatsQuery6) {
|
||||
testLeaseStatsQuery6();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(CqlLeaseMgrTest, leaseStatsQueryNegative4) {
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(CqlLeaseMgrTest, leaseStatsQueryNegative6) {
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -3355,7 +3355,7 @@ GenericLeaseMgrTest::checkQueryAgainstRowSet(const LeaseStatsQueryPtr& query,
|
||||
<< " count: " << row.state_count_;
|
||||
} else {
|
||||
if (row.state_count_ != (*found_row).state_count_) {
|
||||
ADD_FAILURE() << "row count wrong for "
|
||||
ADD_FAILURE() << "row count wrong for"
|
||||
<< " id: " << row.subnet_id_
|
||||
<< " type: " << row.lease_type_
|
||||
<< " state: " << row.lease_state_
|
||||
@ -3629,6 +3629,93 @@ GenericLeaseMgrTest::testLeaseStatsQuery6() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GenericLeaseMgrTest::testLeaseStatsQueryNegative4() {
|
||||
// Create two subnets for the same range.
|
||||
CfgSubnets4Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets4();
|
||||
Subnet4Ptr subnet;
|
||||
|
||||
subnet.reset(new Subnet4(IOAddress("192.0.1.0"), 24, 1, 2, 3, 1));
|
||||
cfg->add(subnet);
|
||||
|
||||
subnet.reset(new Subnet4(IOAddress("192.0.1.1"), 24, 1, 2, 3, 2));
|
||||
cfg->add(subnet);
|
||||
|
||||
ASSERT_NO_THROW(CfgMgr::instance().commit());
|
||||
|
||||
LeaseStatsQueryPtr query;
|
||||
RowSet expected_rows;
|
||||
|
||||
// Now let's insert two leases into subnet 1.
|
||||
int subnet_id = 1;
|
||||
makeLease4("192.0.1.1", subnet_id);
|
||||
Lease4Ptr lease = makeLease4("192.0.1.2", subnet_id);
|
||||
|
||||
// And one lease into subnet 2.
|
||||
subnet_id = 2;
|
||||
makeLease4("192.0.1.3", subnet_id);
|
||||
|
||||
// Move a lease to the second subnet.
|
||||
lease->subnet_id_ = subnet_id;
|
||||
EXPECT_NO_THROW(lmptr_->updateLease4(lease));
|
||||
|
||||
// Add expected rows for Subnets.
|
||||
expected_rows.insert(LeaseStatsRow(1, Lease::STATE_DEFAULT, 1));
|
||||
expected_rows.insert(LeaseStatsRow(2, Lease::STATE_DEFAULT, 2));
|
||||
|
||||
// Start the query
|
||||
ASSERT_NO_THROW(query = lmptr_->startLeaseStatsQuery4());
|
||||
|
||||
// Verify contents
|
||||
checkQueryAgainstRowSet(query, expected_rows);
|
||||
}
|
||||
|
||||
void
|
||||
GenericLeaseMgrTest::testLeaseStatsQueryNegative6() {
|
||||
// Create two subnets.
|
||||
CfgSubnets6Ptr cfg = CfgMgr::instance().getStagingCfg()->getCfgSubnets6();
|
||||
Subnet6Ptr subnet;
|
||||
|
||||
int subnet_id = 1;
|
||||
subnet.reset(new Subnet6(IOAddress("2001:db8:1::"), 64, 1, 2, 3, 4,
|
||||
subnet_id));
|
||||
cfg->add(subnet);
|
||||
|
||||
++subnet_id;
|
||||
subnet.reset(new Subnet6(IOAddress("2001:db8:1::1"), 64, 1, 2, 3, 4,
|
||||
subnet_id));
|
||||
cfg->add(subnet);
|
||||
|
||||
ASSERT_NO_THROW(CfgMgr::instance().commit());
|
||||
|
||||
LeaseStatsQueryPtr query;
|
||||
RowSet expected_rows;
|
||||
|
||||
// Now let's insert two leases into subnet 1.
|
||||
subnet_id = 1;
|
||||
makeLease6(Lease::TYPE_NA, "2001:db81::1", 0, subnet_id);
|
||||
Lease6Ptr lease = makeLease6(Lease::TYPE_NA, "2001:db81::2", 0, subnet_id);
|
||||
|
||||
// And one lease into subnet 2.
|
||||
subnet_id = 2;
|
||||
makeLease6(Lease::TYPE_NA, "2001:db81::3", 0, subnet_id);
|
||||
|
||||
// Move a lease to the second subnet.
|
||||
lease->subnet_id_ = subnet_id;
|
||||
EXPECT_NO_THROW(lmptr_->updateLease6(lease));
|
||||
|
||||
// Add expected rows for Subnets.
|
||||
expected_rows.insert(LeaseStatsRow(1, Lease::TYPE_NA,
|
||||
Lease::STATE_DEFAULT, 1));
|
||||
expected_rows.insert(LeaseStatsRow(2, Lease::TYPE_NA,
|
||||
Lease::STATE_DEFAULT, 2));
|
||||
// Start the query
|
||||
ASSERT_NO_THROW(query = lmptr_->startLeaseStatsQuery6());
|
||||
|
||||
// Verify contents
|
||||
checkQueryAgainstRowSet(query, expected_rows);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace dhcp
|
||||
} // namespace isc
|
||||
|
@ -467,6 +467,24 @@ public:
|
||||
///
|
||||
void testLeaseStatsQuery6();
|
||||
|
||||
/// @brief Checks if v4 LeaseStatsQuery can get negative counters
|
||||
///
|
||||
/// It creates two subnets with leases and move one from the first
|
||||
/// to the second. If counters are not updated this can lead to
|
||||
/// negative counters.
|
||||
///
|
||||
void testLeaseStatsQueryNegative4();
|
||||
|
||||
/// @brief Checks if v6 LeaseStatsQuery can get negative counters
|
||||
///
|
||||
/// It creates two subnets with leases and move one from the first
|
||||
/// to the second. If counters are not updated this can lead to
|
||||
/// negative counters.
|
||||
///
|
||||
/// @note We can check the lease type change too but in the real
|
||||
/// world this never happens.
|
||||
void testLeaseStatsQueryNegative6();
|
||||
|
||||
/// @brief Compares LeaseQueryStats content to expected set of rows
|
||||
///
|
||||
/// @param qry - a started LeaseStatsQuery
|
||||
|
@ -2258,4 +2258,16 @@ TEST_F(MemfileLeaseMgrTest, leaseStatsQuery6) {
|
||||
testLeaseStatsQuery6();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(MemfileLeaseMgrTest, leaseStatsQueryNegative4) {
|
||||
startBackend(V4);
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(MemfileLeaseMgrTest, leaseStatsQueryNegative6) {
|
||||
startBackend(V6);
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -1015,4 +1015,26 @@ TEST_F(MySqlLeaseMgrTest, leaseStatsQuery6MultiThreading) {
|
||||
testLeaseStatsQuery6();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(MySqlLeaseMgrTest, leaseStatsQueryNegative4) {
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(MySqlLeaseMgrTest, leaseStatsQueryNegative4MultiThreading) {
|
||||
MultiThreadingMgr::instance().setMode(true);
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(MySqlLeaseMgrTest, leaseStatsQueryNegative6) {
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(MySqlLeaseMgrTest, leaseStatsQueryNegative6MultiThreading) {
|
||||
MultiThreadingMgr::instance().setMode(true);
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -971,4 +971,26 @@ TEST_F(PgSqlLeaseMgrTest, leaseStatsQuery6MultiThreading) {
|
||||
testLeaseStatsQuery6();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(PgSqlLeaseMgrTest, leaseStatsQueryNegative4) {
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v4 lease stats to never go negative.
|
||||
TEST_F(PgSqlLeaseMgrTest, leaseStatsQueryNegative4MultiThreading) {
|
||||
MultiThreadingMgr::instance().setMode(true);
|
||||
testLeaseStatsQueryNegative4();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(PgSqlLeaseMgrTest, leaseStatsQueryNegative6) {
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
/// @brief Tests v6 lease stats to never go negative.
|
||||
TEST_F(PgSqlLeaseMgrTest, leaseStatsQueryNegative6MultiThreading) {
|
||||
MultiThreadingMgr::instance().setMode(true);
|
||||
testLeaseStatsQueryNegative6();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user