diff --git a/indexing-service/pom.xml b/indexing-service/pom.xml
index b43e6283d0f2..8dde19657516 100644
--- a/indexing-service/pom.xml
+++ b/indexing-service/pom.xml
@@ -197,6 +197,11 @@
junit-jupiter-engine
test
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
org.junit.jupiter
junit-jupiter-migrationsupport
@@ -261,6 +266,11 @@
mockito-core
test
+
+ org.mockito
+ mockito-junit-jupiter
+ test
+
com.google.api.grpc
proto-google-common-protos
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/LocalTaskActionClientTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/LocalTaskActionClientTest.java
index 75720b85d1de..35d410013ce0 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/LocalTaskActionClientTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/LocalTaskActionClientTest.java
@@ -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;
@@ -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));
}
}
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientFactoryTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientFactoryTest.java
index 0c504c53687f..514b2a50539a 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientFactoryTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientFactoryTest.java
@@ -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
{
@@ -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
@@ -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
@@ -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());
}
}
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java
index f6db5ea50d7c..a84fe68ab2bf 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RemoteTaskActionClientTest.java
@@ -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;
@@ -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);
@@ -108,7 +103,7 @@ public void testSubmitSimple() throws Exception
RemoteTaskActionClient client = new RemoteTaskActionClient(task, directOverlordClient, objectMapper);
final List locks = client.submit(action);
- Assert.assertEquals(expectedLocks, locks);
+ Assertions.assertEquals(expectedLocks, locks);
EasyMock.verify(directOverlordClient);
}
@@ -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);
}
@@ -173,6 +171,6 @@ public void test_defaultTaskActionRetryPolicy_hasMaxRetryDurationOf10Minutes()
totalWaitTimeMillis += ServiceClientImpl.computeBackoffMs(retryPolicy, attempt);
}
- Assert.assertEquals(13, defaultRetryConfig.getMaxRetryCount());
+ Assertions.assertEquals(13, defaultRetryConfig.getMaxRetryCount());
}
}
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveSegmentsActionsTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveSegmentsActionsTest.java
index ef27e4a600b0..d2edd1487336 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveSegmentsActionsTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveSegmentsActionsTest.java
@@ -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;
@@ -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 expectedUnusedSegments;
private static Set expectedUsedSegments;
- @Before
+ @BeforeEach
public void setup()
{
task = NoopTask.create();
@@ -102,7 +102,7 @@ public void testRetrieveUsedSegmentsAction()
final RetrieveUsedSegmentsAction action =
new RetrieveUsedSegmentsAction(task.getDataSource(), ImmutableList.of(INTERVAL));
final Set observedUsedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
- Assert.assertEquals(expectedUsedSegments, observedUsedSegments);
+ Assertions.assertEquals(expectedUsedSegments, observedUsedSegments);
}
@Test
@@ -116,7 +116,7 @@ public void testRetrieveUnusedSegmentsActionWithVersions()
null
);
final Set observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
- Assert.assertEquals(expectedUnusedSegments, observedUnusedSegments);
+ Assertions.assertEquals(expectedUnusedSegments, observedUnusedSegments);
}
@Test
@@ -130,7 +130,7 @@ public void testRetrieveUnusedSegmentsActionWithEmptyVersions()
null
);
final Set observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
- Assert.assertEquals(ImmutableSet.of(), observedUnusedSegments);
+ Assertions.assertEquals(ImmutableSet.of(), observedUnusedSegments);
}
@Test
@@ -138,7 +138,7 @@ public void testRetrieveUnusedSegmentsActionWithMinUsedLastUpdatedTime()
{
final RetrieveUnusedSegmentsAction action = new RetrieveUnusedSegmentsAction(task.getDataSource(), INTERVAL, null, null, DateTimes.MIN);
final Set observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
- Assert.assertEquals(ImmutableSet.of(), observedUnusedSegments);
+ Assertions.assertEquals(ImmutableSet.of(), observedUnusedSegments);
}
@Test
@@ -146,6 +146,6 @@ public void testRetrieveUnusedSegmentsActionWithNowUsedLastUpdatedTime()
{
final RetrieveUnusedSegmentsAction action = new RetrieveUnusedSegmentsAction(task.getDataSource(), INTERVAL, null, null, DateTimes.nowUtc());
final Set observedUnusedSegments = new HashSet<>(action.perform(task, actionTestKit.getTaskActionToolbox()));
- Assert.assertEquals(expectedUnusedSegments, observedUnusedSegments);
+ Assertions.assertEquals(expectedUnusedSegments, observedUnusedSegments);
}
}
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveUsedSegmentsActionSerdeTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveUsedSegmentsActionSerdeTest.java
index 6ae9fc80e3cf..6a1a20ed6c9c 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveUsedSegmentsActionSerdeTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/RetrieveUsedSegmentsActionSerdeTest.java
@@ -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;
@@ -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
@@ -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
@@ -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")),
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionSerdeTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionSerdeTest.java
index 4bed168ce80c..b4d272a422f2 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionSerdeTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionSerdeTest.java
@@ -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;
@@ -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
@@ -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")));
}
}
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionTest.java
index e51ff0560fea..0a9453f457fc 100644
--- a/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionTest.java
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/actions/SegmentAllocateActionTest.java
@@ -54,14 +54,14 @@
import org.easymock.EasyMock;
import org.joda.time.DateTime;
import org.joda.time.Period;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.MethodSource;
import java.time.Duration;
import java.util.ArrayList;
@@ -79,10 +79,11 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-@RunWith(Parameterized.class)
+@ParameterizedClass
+@MethodSource("constructorFeeder")
public class SegmentAllocateActionTest
{
- @Rule
+ @RegisterExtension
public TaskActionTestKit taskActionTestKit = new TaskActionTestKit();
private static final String DATA_SOURCE = "none";
@@ -94,7 +95,6 @@ public class SegmentAllocateActionTest
private SegmentAllocationQueue allocationQueue;
- @Parameterized.Parameters(name = "lock={0}, useBatch={1}, useSegmentCache={2}, reduceMetadataIO={3}")
public static Iterable