Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AmatyaAvadhanula committed Oct 12, 2023
1 parent 1380b29 commit ad084e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ public ListenableFuture<CloseableIterator<SupervisorStatus>> supervisorStatuses(
throw new UnsupportedOperationException();
}

@Override
public ListenableFuture<Map<String, List<Interval>>> findLockedIntervals(Map<String, Integer> minTaskPriority)
{
throw new UnsupportedOperationException();
}

@Override
public ListenableFuture<Map<String, List<Interval>>> findConflictingLockIntervals(
List<ConflictingLockRequest> conflictingLockRequests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.http.client.response.StringFullResponseHolder;
import org.apache.druid.metadata.ConflictingLockRequest;
import org.apache.druid.rpc.HttpResponseException;
import org.apache.druid.rpc.MockServiceClient;
import org.apache.druid.rpc.RequestBuilder;
Expand Down Expand Up @@ -219,40 +220,44 @@ public void test_taskStatuses_null_null_zero() throws Exception
@Test
public void test_findLockedIntervals() throws Exception
{
final Map<String, Integer> priorityMap = ImmutableMap.of("foo", 3);
final Map<String, List<Interval>> lockMap =
ImmutableMap.of("foo", Collections.singletonList(Intervals.of("2000/2001")));
final List<ConflictingLockRequest> requests = ImmutableList.of(
new ConflictingLockRequest("foo", 3, null)
);

serviceClient.expectAndRespond(
new RequestBuilder(HttpMethod.POST, "/druid/indexer/v1/lockedIntervals")
.jsonContent(jsonMapper, priorityMap),
new RequestBuilder(HttpMethod.POST, "/druid/indexer/v1/conflictingLockIntervals")
.jsonContent(jsonMapper, requests),
HttpResponseStatus.OK,
ImmutableMap.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON),
jsonMapper.writeValueAsBytes(lockMap)
);

Assert.assertEquals(
lockMap,
overlordClient.findLockedIntervals(priorityMap).get()
overlordClient.findConflictingLockIntervals(requests).get()
);
}

@Test
public void test_findLockedIntervals_nullReturn() throws Exception
{
final Map<String, Integer> priorityMap = ImmutableMap.of("foo", 3);
final List<ConflictingLockRequest> requests = ImmutableList.of(
new ConflictingLockRequest("foo", 3, null)
);

serviceClient.expectAndRespond(
new RequestBuilder(HttpMethod.POST, "/druid/indexer/v1/lockedIntervals")
.jsonContent(jsonMapper, priorityMap),
new RequestBuilder(HttpMethod.POST, "/druid/indexer/v1/conflictingLockIntervals")
.jsonContent(jsonMapper, requests),
HttpResponseStatus.OK,
ImmutableMap.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON),
jsonMapper.writeValueAsBytes(null)
);

Assert.assertEquals(
Collections.emptyMap(),
overlordClient.findLockedIntervals(priorityMap).get()
overlordClient.findConflictingLockIntervals(requests).get()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ public void testCompactWithGranularitySpecConflictWithActiveCompactionTask()
.thenReturn(
Futures.immediateFuture(
CloseableIterators.withEmptyBaggage(ImmutableList.of(runningConflictCompactionTask).iterator())));
Mockito.when(mockClient.findLockedIntervals(ArgumentMatchers.any()))
Mockito.when(mockClient.findConflictingLockIntervals(ArgumentMatchers.any()))
.thenReturn(Futures.immediateFuture(Collections.emptyMap()));
Mockito.when(mockClient.cancelTask(conflictTaskId))
.thenReturn(Futures.immediateFuture(null));
Expand Down Expand Up @@ -2004,12 +2004,6 @@ public ListenableFuture<Map<String, List<Interval>>> findConflictingLockInterval
return Futures.immediateFuture(lockedIntervals);
}

@Override
public ListenableFuture<Map<String, List<Interval>>> findLockedIntervals(Map<String, Integer> minTaskPriority)
{
return Futures.immediateFuture(lockedIntervals);
}

@Override
public ListenableFuture<CloseableIterator<TaskStatusPlus>> taskStatuses(
@Nullable String state,
Expand Down Expand Up @@ -2196,7 +2190,7 @@ private static ArgumentCaptor<Object> setUpMockClient(final OverlordClient mockC
final ArgumentCaptor<Object> payloadCaptor = ArgumentCaptor.forClass(Object.class);
Mockito.when(mockClient.taskStatuses(null, null, 0))
.thenReturn(Futures.immediateFuture(CloseableIterators.withEmptyBaggage(Collections.emptyIterator())));
Mockito.when(mockClient.findLockedIntervals(ArgumentMatchers.any()))
Mockito.when(mockClient.findConflictingLockIntervals(ArgumentMatchers.any()))
.thenReturn(Futures.immediateFuture(Collections.emptyMap()));
Mockito.when(mockClient.getTotalWorkerCapacity())
.thenReturn(Futures.immediateFuture(new IndexingTotalWorkerCapacityInfo(0, 0)));
Expand Down

0 comments on commit ad084e7

Please sign in to comment.