Skip to content

Commit

Permalink
LockServiceIT
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Aug 11, 2023
1 parent ce1774e commit 5bf1867
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.mockito.Mockito;
import org.opensearch.action.ActionListener;
import org.opensearch.core.action.ActionListener;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.jobscheduler.spi.JobDocVersion;
Expand Down Expand Up @@ -81,7 +81,8 @@ public Long getLockDurationSeconds() {

@Before
public void setup() {
// the test cluster is an external cluster instead of internal cluster in new test framework,
// the test cluster is an external cluster instead of internal cluster in new
// test framework,
// thus the OpenSearchIntegTestCase.clusterService() will throw exception.
this.clusterService = Mockito.mock(ClusterService.class, Mockito.RETURNS_DEEP_STUBS);
Mockito.when(this.clusterService.state().routingTable().hasIndex(".opendistro-job-scheduler-lock"))
Expand Down Expand Up @@ -454,7 +455,8 @@ public void testRenewLock() throws Exception {

lockService.acquireLockWithId(context.getJobIndexName(), LOCK_DURATION_SECONDS, lockID, ActionListener.wrap(lock -> {
assertNotNull("Expected to successfully grab lock", lock);
// Set the time of LockService (the 'lockTime' of acquired locks) to a fixed time.
// Set the time of LockService (the 'lockTime' of acquired locks) to a fixed
// time.
Instant now = Instant.now();
lockService.setTime(now);
lockService.renewLock(lock, ActionListener.wrap(renewedLock -> {
Expand Down

0 comments on commit 5bf1867

Please sign in to comment.