Skip to content

Commit

Permalink
Add better unit test to ensure task is scheduled/unscheduled.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Oct 19, 2023
1 parent 22edb10 commit e4eaffc
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void testFailStaleReplicaTask() throws Exception {

// call the background task
assertTrue(service.getFailStaleReplicaTask().mustReschedule());
assertTrue(service.getFailStaleReplicaTask().isScheduled());
service.getFailStaleReplicaTask().runInternal();

// verify that remote shard failed method is called which fails the replica shards falling behind.
Expand Down Expand Up @@ -281,14 +282,15 @@ public void testFailStaleReplicaTaskToggleOnOff() throws Exception {
assertEquals(5, shardStats.getCheckpointsBehindCount());

assertTrue(service.getFailStaleReplicaTask().mustReschedule());

assertTrue(service.getFailStaleReplicaTask().isScheduled());
replicateSegments(primaryShard, shards.getReplicas());

service.setReplicationTimeLimitFailReplica(TimeValue.ZERO);
assertFalse(service.getFailStaleReplicaTask().mustReschedule());

assertFalse(service.getFailStaleReplicaTask().isScheduled());
service.setReplicationTimeLimitFailReplica(TimeValue.timeValueMillis(1));
assertTrue(service.getFailStaleReplicaTask().mustReschedule());
assertTrue(service.getFailStaleReplicaTask().isScheduled());
}
}

Expand Down

0 comments on commit e4eaffc

Please sign in to comment.