Skip to content

Commit ff951d2

Browse files
committed
[#3649] More unit tests
1 parent 63b0786 commit ff951d2

File tree

1 file changed

+58
-8
lines changed

1 file changed

+58
-8
lines changed

src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc

+58-8
Original file line numberDiff line numberDiff line change
@@ -9137,8 +9137,8 @@ TEST_F(HAServiceStateMachineTest, doNotTerminateWhenPartnerUnavailable) {
91379137
EXPECT_EQ(HA_COMMUNICATION_RECOVERY_ST, service_->getCurrState());
91389138
}
91399139

9140-
// This test verifies that the service correctly identifies the leases that can
9141-
// be reclaimed while the server is the primary.
9140+
// This test verifies that the service reclaims the leases while the server is
9141+
// primary and it is in the terminated state.
91429142
TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisPrimary) {
91439143
startService(createValidConfiguration(HAConfig::HOT_STANDBY));
91449144
service_->verboseTransition(HA_TERMINATED_ST);
@@ -9148,8 +9148,19 @@ TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisPrimary) {
91489148
EXPECT_TRUE(service_->shouldReclaim(lease4));
91499149
}
91509150

9151-
// This test verifies that the service correctly identifies the leases that can
9152-
// be reclaimed while the server is the standby.
9151+
// This test verifies that the service reclaims the leases while the server is
9152+
// primary and it is in the non-terminated state.
9153+
TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisPrimaryNotTerminated) {
9154+
startService(createValidConfiguration(HAConfig::HOT_STANDBY));
9155+
service_->verboseTransition(HA_READY_ST);
9156+
service_->runModel(HAService::NOP_EVT);
9157+
9158+
Lease4Ptr lease4 = createLease4(randomKey(HWAddr::ETHERNET_HWADDR_LEN));
9159+
EXPECT_TRUE(service_->shouldReclaim(lease4));
9160+
}
9161+
9162+
// This test verifies that the service does not reclaim the leases while the server is
9163+
// standby and it is in the terminated state.
91539164
TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisStandby) {
91549165
HAConfigPtr valid_config = createValidConfiguration(HAConfig::HOT_STANDBY);
91559166
valid_config->getPeerConfig("server2")->setRole("standby");
@@ -9162,8 +9173,22 @@ TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisStandby) {
91629173
EXPECT_FALSE(service_->shouldReclaim(lease4));
91639174
}
91649175

9165-
// This test verifies that the service correctly identifies the leases that can
9166-
// be reclaimed while the server is the primary.
9176+
// This test verifies that the service reclaims the leases while the server is
9177+
// standby and it is in the non-terminated state.
9178+
TEST_F(HAServiceStateMachineTest, shouldReclaimLease4HotStandbyThisStandbyNotTerminated) {
9179+
HAConfigPtr valid_config = createValidConfiguration(HAConfig::HOT_STANDBY);
9180+
valid_config->getPeerConfig("server2")->setRole("standby");
9181+
valid_config->setThisServerName("server2");
9182+
startService(valid_config);
9183+
service_->verboseTransition(HA_READY_ST);
9184+
service_->runModel(HAService::NOP_EVT);
9185+
9186+
Lease4Ptr lease4 = createLease4(randomKey(HWAddr::ETHERNET_HWADDR_LEN));
9187+
EXPECT_TRUE(service_->shouldReclaim(lease4));
9188+
}
9189+
9190+
// This test verifies that the service reclaims the leases while the server is
9191+
// primary and it is in the terminated state.
91679192
TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisPrimary) {
91689193
startService(createValidConfiguration(HAConfig::HOT_STANDBY));
91699194
service_->verboseTransition(HA_TERMINATED_ST);
@@ -9173,8 +9198,19 @@ TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisPrimary) {
91739198
EXPECT_TRUE(service_->shouldReclaim(lease6));
91749199
}
91759200

9176-
// This test verifies that the service correctly identifies the leases that can
9177-
// be reclaimed while the server is the standby.
9201+
// This test verifies that the service reclaims the leases while the server is
9202+
// primary and it is in the non-terminated state.
9203+
TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisPrimaryNotTerminated) {
9204+
startService(createValidConfiguration(HAConfig::HOT_STANDBY));
9205+
service_->verboseTransition(HA_READY_ST);
9206+
service_->runModel(HAService::NOP_EVT);
9207+
9208+
Lease6Ptr lease6 = createLease6(randomKey(10));
9209+
EXPECT_TRUE(service_->shouldReclaim(lease6));
9210+
}
9211+
9212+
// This test verifies that the service does not reclaim the leases while the server is
9213+
// standby and it is in the terminated state.
91789214
TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisStandby) {
91799215
HAConfigPtr valid_config = createValidConfiguration(HAConfig::HOT_STANDBY);
91809216
valid_config->getPeerConfig("server2")->setRole("standby");
@@ -9187,6 +9223,20 @@ TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisStandby) {
91879223
EXPECT_FALSE(service_->shouldReclaim(lease6));
91889224
}
91899225

9226+
// This test verifies that the service reclaims the leases while the server is
9227+
// standby and it is in the non-terminated state.
9228+
TEST_F(HAServiceStateMachineTest, shouldReclaimLease6HotStandbyThisStandbyNotTerminated) {
9229+
HAConfigPtr valid_config = createValidConfiguration(HAConfig::HOT_STANDBY);
9230+
valid_config->getPeerConfig("server2")->setRole("standby");
9231+
valid_config->setThisServerName("server2");
9232+
startService(valid_config);
9233+
service_->verboseTransition(HA_READY_ST);
9234+
service_->runModel(HAService::NOP_EVT);
9235+
9236+
Lease6Ptr lease6 = createLease6(randomKey(10));
9237+
EXPECT_TRUE(service_->shouldReclaim(lease6));
9238+
}
9239+
91909240
// Test scenario when a single lease4 update is sent successfully, parking is not
91919241
// employed.
91929242
TEST_F(HAServiceTest, successfulSendSingleLeaseUpdateWithoutParking) {

0 commit comments

Comments
 (0)