Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions indexing-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
Expand Down Expand Up @@ -261,6 +266,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collections;

Expand All @@ -34,6 +34,6 @@ public class LocalTaskActionClientTest
public void testGetActionType()
{
final TaskAction<?> action = SegmentTransactionalInsertAction.appendAction(Collections.emptySet(), null, null, null, null, null);
Assert.assertEquals("segmentTransactionalInsert", LocalTaskActionClient.getActionType(objectMapper, action));
Assertions.assertEquals("segmentTransactionalInsert", LocalTaskActionClient.getActionType(objectMapper, action));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.apache.druid.indexing.common.RetryPolicyConfig;
import org.apache.druid.rpc.StandardRetryPolicy;
import org.joda.time.Period;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class RemoteTaskActionClientFactoryTest
{
Expand All @@ -34,13 +34,13 @@ public void test_buildRetryPolicy_withDefaultConfig()
final StandardRetryPolicy retryPolicy = RemoteTaskActionClientFactory.buildRetryPolicy(config);

// Default maxRetryCount is 13, so maxAttempts should be 14 (13 retries + 1 initial attempt)
Assert.assertEquals(14, retryPolicy.maxAttempts());
Assertions.assertEquals(14, retryPolicy.maxAttempts());

// Default minWait is PT5S (5 seconds)
Assert.assertEquals(5000, retryPolicy.minWaitMillis());
Assertions.assertEquals(5000, retryPolicy.minWaitMillis());

// Default maxWait is PT1M (1 minute)
Assert.assertEquals(60000, retryPolicy.maxWaitMillis());
Assertions.assertEquals(60000, retryPolicy.maxWaitMillis());
}

@Test
Expand All @@ -54,13 +54,13 @@ public void test_buildRetryPolicy_withCustomConfig()
final StandardRetryPolicy retryPolicy = RemoteTaskActionClientFactory.buildRetryPolicy(config);

// maxRetryCount is 5, so maxAttempts should be 6 (5 retries + 1 initial attempt)
Assert.assertEquals(6, retryPolicy.maxAttempts());
Assertions.assertEquals(6, retryPolicy.maxAttempts());

// minWait is PT10S (10 seconds)
Assert.assertEquals(10000, retryPolicy.minWaitMillis());
Assertions.assertEquals(10000, retryPolicy.minWaitMillis());

// maxWait is PT2M (2 minutes)
Assert.assertEquals(120000, retryPolicy.maxWaitMillis());
Assertions.assertEquals(120000, retryPolicy.maxWaitMillis());
}

@Test
Expand All @@ -74,12 +74,12 @@ public void test_buildRetryPolicy_withZeroRetries()
final StandardRetryPolicy retryPolicy = RemoteTaskActionClientFactory.buildRetryPolicy(config);

// maxRetryCount is 0, so maxAttempts should be 1 (0 retries + 1 initial attempt)
Assert.assertEquals(1, retryPolicy.maxAttempts());
Assertions.assertEquals(1, retryPolicy.maxAttempts());

// minWait is PT1S (1 second)
Assert.assertEquals(1000, retryPolicy.minWaitMillis());
Assertions.assertEquals(1000, retryPolicy.minWaitMillis());

// maxWait is PT30S (30 seconds)
Assert.assertEquals(30000, retryPolicy.maxWaitMillis());
Assertions.assertEquals(30000, retryPolicy.maxWaitMillis());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -59,13 +57,10 @@

public class RemoteTaskActionClientTest
{
@Rule
public ExpectedException expectedException = ExpectedException.none();

private ServiceClient directOverlordClient;
private final ObjectMapper objectMapper = new DefaultObjectMapper();

@Before
@BeforeEach
public void setUp()
{
directOverlordClient = EasyMock.createMock(ServiceClient.class);
Expand Down Expand Up @@ -108,7 +103,7 @@ public void testSubmitSimple() throws Exception
RemoteTaskActionClient client = new RemoteTaskActionClient(task, directOverlordClient, objectMapper);
final List<TaskLock> locks = client.submit(action);

Assert.assertEquals(expectedLocks, locks);
Assertions.assertEquals(expectedLocks, locks);
EasyMock.verify(directOverlordClient);
}

Expand Down Expand Up @@ -142,12 +137,15 @@ public void testSubmitWithIllegalStatusCode() throws Exception
EasyMock.replay(directOverlordClient);

RemoteTaskActionClient client = new RemoteTaskActionClient(task, directOverlordClient, objectMapper);
expectedException.expect(IOException.class);
expectedException.expectMessage(
final IOException exception = Assertions.assertThrows(
IOException.class,
() -> client.submit(action)
);
Assertions.assertEquals(
"Error with status[400 Bad Request] and message[testSubmitWithIllegalStatusCode]. "
+ "Check overlord logs for details."
+ "Check overlord logs for details.",
exception.getMessage()
);
client.submit(action);

EasyMock.verify(directOverlordClient, response);
}
Expand All @@ -173,6 +171,6 @@ public void test_defaultTaskActionRetryPolicy_hasMaxRetryDurationOf10Minutes()
totalWaitTimeMillis += ServiceClientImpl.computeBackoffMs(retryPolicy, attempt);
}

Assert.assertEquals(13, defaultRetryConfig.getMaxRetryCount());
Assertions.assertEquals(13, defaultRetryConfig.getMaxRetryCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.partition.NoneShardSpec;
import org.joda.time.Interval;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -42,14 +42,14 @@ public class RetrieveSegmentsActionsTest
private static final String UNUSED_V0 = "v0";
private static final String UNUSED_V1 = "v1";

@Rule
@RegisterExtension
public TaskActionTestKit actionTestKit = new TaskActionTestKit();

private static Task task;
private static Set<DataSegment> expectedUnusedSegments;
private static Set<DataSegment> expectedUsedSegments;

@Before
@BeforeEach
public void setup()
{
task = NoopTask.create();
Expand Down Expand Up @@ -102,7 +102,7 @@ public void testRetrieveUsedSegmentsAction()
final RetrieveUsedSegmentsAction action =
new RetrieveUsedSegmentsAction(task.getDataSource(), ImmutableList.of(INTERVAL));
final Set<DataSegment> observedUsedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
Assert.assertEquals(expectedUsedSegments, observedUsedSegments);
Assertions.assertEquals(expectedUsedSegments, observedUsedSegments);
}

@Test
Expand All @@ -116,7 +116,7 @@ public void testRetrieveUnusedSegmentsActionWithVersions()
null
);
final Set<DataSegment> observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
Assert.assertEquals(expectedUnusedSegments, observedUnusedSegments);
Assertions.assertEquals(expectedUnusedSegments, observedUnusedSegments);
}

@Test
Expand All @@ -130,22 +130,22 @@ public void testRetrieveUnusedSegmentsActionWithEmptyVersions()
null
);
final Set<DataSegment> observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
Assert.assertEquals(ImmutableSet.of(), observedUnusedSegments);
Assertions.assertEquals(ImmutableSet.of(), observedUnusedSegments);
}

@Test
public void testRetrieveUnusedSegmentsActionWithMinUsedLastUpdatedTime()
{
final RetrieveUnusedSegmentsAction action = new RetrieveUnusedSegmentsAction(task.getDataSource(), INTERVAL, null, null, DateTimes.MIN);
final Set<DataSegment> observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
Assert.assertEquals(ImmutableSet.of(), observedUnusedSegments);
Assertions.assertEquals(ImmutableSet.of(), observedUnusedSegments);
}

@Test
public void testRetrieveUnusedSegmentsActionWithNowUsedLastUpdatedTime()
{
final RetrieveUnusedSegmentsAction action = new RetrieveUnusedSegmentsAction(task.getDataSource(), INTERVAL, null, null, DateTimes.nowUtc());
final Set<DataSegment> observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
Assert.assertEquals(expectedUnusedSegments, observedUnusedSegments);
Assertions.assertEquals(expectedUnusedSegments, observedUnusedSegments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.apache.druid.java.util.common.Intervals;
import org.apache.druid.segment.TestHelper;
import org.joda.time.Interval;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;
Expand All @@ -47,8 +47,8 @@ public void testSingleIntervalSerde() throws Exception

RetrieveUsedSegmentsAction actual =
MAPPER.readValue(MAPPER.writeValueAsString(expected), RetrieveUsedSegmentsAction.class);
Assert.assertEquals(ImmutableList.of(interval), actual.getIntervals());
Assert.assertEquals(expected, actual);
Assertions.assertEquals(ImmutableList.of(interval), actual.getIntervals());
Assertions.assertEquals(expected, actual);
}

@Test
Expand All @@ -62,8 +62,8 @@ public void testMultiIntervalSerde() throws Exception

RetrieveUsedSegmentsAction actual =
MAPPER.readValue(MAPPER.writeValueAsString(expected), RetrieveUsedSegmentsAction.class);
Assert.assertEquals(intervals, actual.getIntervals());
Assert.assertEquals(expected, actual);
Assertions.assertEquals(intervals, actual.getIntervals());
Assertions.assertEquals(expected, actual);
}

@Test
Expand All @@ -72,7 +72,7 @@ public void testOldJsonDeserialization() throws Exception
String jsonStr = "{\"type\": \"segmentListUsed\", \"dataSource\": \"test\", \"intervals\": [\"2014/2015\"]}";
RetrieveUsedSegmentsAction actual = (RetrieveUsedSegmentsAction) MAPPER.readValue(jsonStr, TaskAction.class);

Assert.assertEquals(
Assertions.assertEquals(
new RetrieveUsedSegmentsAction(
"test",
Collections.singletonList(Intervals.of("2014/2015")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.java.util.common.granularity.Granularity;
import org.apache.druid.timeline.partition.NumberedPartialShardSpec;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -66,14 +66,14 @@ public void testSerde() throws Exception
TaskAction.class
);

Assert.assertEquals(target.getDataSource(), fromJson.getDataSource());
Assert.assertEquals(target.getTimestamp(), fromJson.getTimestamp());
Assert.assertEquals(target.getQueryGranularity(), fromJson.getQueryGranularity());
Assert.assertEquals(target.getPreferredSegmentGranularity(), fromJson.getPreferredSegmentGranularity());
Assert.assertEquals(target.getSequenceName(), fromJson.getSequenceName());
Assert.assertEquals(target.getPreviousSegmentId(), fromJson.getPreviousSegmentId());
Assert.assertEquals(target.isSkipSegmentLineageCheck(), fromJson.isSkipSegmentLineageCheck());
Assert.assertEquals(TaskLockType.EXCLUSIVE, target.getTaskLockType());
Assertions.assertEquals(target.getDataSource(), fromJson.getDataSource());
Assertions.assertEquals(target.getTimestamp(), fromJson.getTimestamp());
Assertions.assertEquals(target.getQueryGranularity(), fromJson.getQueryGranularity());
Assertions.assertEquals(target.getPreferredSegmentGranularity(), fromJson.getPreferredSegmentGranularity());
Assertions.assertEquals(target.getSequenceName(), fromJson.getSequenceName());
Assertions.assertEquals(target.getPreviousSegmentId(), fromJson.getPreviousSegmentId());
Assertions.assertEquals(target.isSkipSegmentLineageCheck(), fromJson.isSkipSegmentLineageCheck());
Assertions.assertEquals(TaskLockType.EXCLUSIVE, target.getTaskLockType());
}

@Test
Expand All @@ -84,23 +84,23 @@ public void testJsonPropertyNames() throws IOException
Map.class
);

Assert.assertEquals(11, fromJson.size());
Assert.assertEquals(SegmentAllocateAction.TYPE, fromJson.get("type"));
Assert.assertEquals(target.getDataSource(), fromJson.get("dataSource"));
Assert.assertEquals(target.getTimestamp(), DateTimes.of((String) fromJson.get("timestamp")));
Assert.assertEquals(
Assertions.assertEquals(11, fromJson.size());
Assertions.assertEquals(SegmentAllocateAction.TYPE, fromJson.get("type"));
Assertions.assertEquals(target.getDataSource(), fromJson.get("dataSource"));
Assertions.assertEquals(target.getTimestamp(), DateTimes.of((String) fromJson.get("timestamp")));
Assertions.assertEquals(
target.getQueryGranularity(),
Granularity.fromString((String) fromJson.get("queryGranularity"))
);
Assert.assertEquals(
Assertions.assertEquals(
target.getPreferredSegmentGranularity(),
Granularity.fromString((String) fromJson.get("preferredSegmentGranularity"))
);
Assert.assertEquals(target.getSequenceName(), fromJson.get("sequenceName"));
Assert.assertEquals(target.getPreviousSegmentId(), fromJson.get("previousSegmentId"));
Assert.assertEquals(target.isSkipSegmentLineageCheck(), fromJson.get("skipSegmentLineageCheck"));
Assert.assertEquals(ImmutableMap.of("type", "numbered"), fromJson.get("shardSpecFactory"));
Assert.assertEquals(target.getLockGranularity(), LockGranularity.valueOf((String) fromJson.get("lockGranularity")));
Assert.assertEquals(target.getTaskLockType(), TaskLockType.valueOf((String) fromJson.get("taskLockType")));
Assertions.assertEquals(target.getSequenceName(), fromJson.get("sequenceName"));
Assertions.assertEquals(target.getPreviousSegmentId(), fromJson.get("previousSegmentId"));
Assertions.assertEquals(target.isSkipSegmentLineageCheck(), fromJson.get("skipSegmentLineageCheck"));
Assertions.assertEquals(ImmutableMap.of("type", "numbered"), fromJson.get("shardSpecFactory"));
Assertions.assertEquals(target.getLockGranularity(), LockGranularity.valueOf((String) fromJson.get("lockGranularity")));
Assertions.assertEquals(target.getTaskLockType(), TaskLockType.valueOf((String) fromJson.get("taskLockType")));
}
}
Loading
Loading