This is an automated email from the ASF dual-hosted git repository.
kfaraz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 84b4c83d593 Perform auth check in /compaction/status/datasources API
(#18600)
84b4c83d593 is described below
commit 84b4c83d59377c4672b848b02bd71a091ff5286b
Author: Kashif Faraz <[email protected]>
AuthorDate: Mon Oct 6 16:46:53 2025 +0530
Perform auth check in /compaction/status/datasources API (#18600)
Changes:
- Perform auth check in `/druid/indexer/v1/compaction/status/datasources`
API when supervisor is disabled
- Verify the change via embedded tests
- Enable most test methods in `AutoCompactionTest`
---
.../testing/embedded/compact/AutoCompactionTest.java | 17 ++++++++++++++++-
.../compact/CompactionResourceTestClient.java | 16 ++++++++++++++++
.../overlord/http/OverlordCompactionResource.java | 16 +++++++++++++++-
.../http/OverlordCompactionResourceTest.java | 20 ++++++++++++++++++++
4 files changed, 67 insertions(+), 2 deletions(-)
diff --git
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/AutoCompactionTest.java
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/AutoCompactionTest.java
index f77667b311b..0c7f4a93ff7 100644
---
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/AutoCompactionTest.java
+++
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/AutoCompactionTest.java
@@ -111,7 +111,6 @@ import java.util.stream.Collectors;
/**
* Embedded mode of integration-tests originally present in {@code
ITAutoCompactionTest}.
*/
-@Disabled("Disabled due to issues with compaction task not publishing schema
to broker")
public class AutoCompactionTest extends CompactionTestBase
{
private static final Logger LOG = new Logger(AutoCompactionTest.class);
@@ -201,8 +200,10 @@ public class AutoCompactionTest extends CompactionTestBase
@Override
protected EmbeddedDruidCluster createCluster()
{
+ // Use timeout required for hash partitioning task
return EmbeddedDruidCluster.withEmbeddedDerbyAndZookeeper()
.useLatchableEmitter()
+ .useDefaultTimeoutForLatchableEmitter(30)
.addExtension(SketchModule.class)
.addExtension(HllSketchModule.class)
.addExtension(DoublesSketchModule.class)
@@ -620,6 +621,17 @@ public class AutoCompactionTest extends CompactionTestBase
0,
2,
0);
+
+ final List<AutoCompactionSnapshot> allSnapshots =
compactionResource.getAllCompactionSnapshots();
+ Assertions.assertFalse(allSnapshots.isEmpty());
+
+ AutoCompactionSnapshot snapshot = allSnapshots
+ .stream()
+ .filter(s -> s.getDataSource().equals(fullDatasourceName))
+ .findFirst()
+ .orElse(null);
+ Assertions.assertNotNull(snapshot);
+ Assertions.assertEquals(snapshot.getBytesAwaitingCompaction(), 0L);
}
}
@@ -778,6 +790,7 @@ public class AutoCompactionTest extends CompactionTestBase
@MethodSource("getEngine")
@ParameterizedTest(name = "compactionEngine={0}")
+ @Disabled("Disabled due to issues with compaction task not publishing schema
to broker")
public void
testAutoCompactionDutyWithSegmentGranularityAndWithDropExistingTrue(CompactionEngine
engine) throws Exception
{
// Interval is "2013-08-31/2013-09-02", segment gran is DAY,
@@ -901,6 +914,7 @@ public class AutoCompactionTest extends CompactionTestBase
@MethodSource("getEngine")
@ParameterizedTest(name = "compactionEngine={0}")
+ @Disabled("Disabled due to issues with compaction task not publishing schema
to broker")
public void
testAutoCompactionDutyWithSegmentGranularityAndWithDropExistingTrueThenFalse(CompactionEngine
engine) throws Exception
{
// Interval is "2013-08-31/2013-09-02", segment gran is DAY,
@@ -1175,6 +1189,7 @@ public class AutoCompactionTest extends CompactionTestBase
@MethodSource("getEngine")
@ParameterizedTest(name = "compactionEngine={0}")
+ @Disabled("Disabled due to issues with compaction task not publishing schema
to broker")
public void
testAutoCompactionDutyWithSegmentGranularityAndSmallerSegmentGranularityCoveringMultipleSegmentsInTimelineAndDropExistingTrue(CompactionEngine
engine) throws Exception
{
loadData(INDEX_TASK);
diff --git
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/CompactionResourceTestClient.java
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/CompactionResourceTestClient.java
index 4e9016b3328..0229add690c 100644
---
a/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/CompactionResourceTestClient.java
+++
b/embedded-tests/src/test/java/org/apache/druid/testing/embedded/compact/CompactionResourceTestClient.java
@@ -193,6 +193,22 @@ public class CompactionResourceTestClient
}
}
+ public List<AutoCompactionSnapshot> getAllCompactionSnapshots()
+ {
+ String url = StringUtils.format("%s/compaction/status/datasources",
getOverlordURL());
+
+ try {
+ final CompactionStatusResponse latestSnapshots = client.onLeaderOverlord(
+ mapper -> new RequestBuilder(HttpMethod.GET, url),
+ new TypeReference<>() {}
+ );
+ return Objects.requireNonNull(latestSnapshots).getLatestStatus();
+ }
+ catch (Exception e) {
+ return ServletResourceUtils.getDefaultValueIfCauseIs404ElseThrow(e, ()
-> null);
+ }
+ }
+
public CompactionSimulateResult simulateRunOnCoordinator()
{
final ClusterCompactionConfig clusterConfig = getClusterConfig();
diff --git
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResource.java
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResource.java
index 057de1aef23..e2d08fa97c4 100644
---
a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResource.java
+++
b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResource.java
@@ -158,7 +158,21 @@ public class OverlordCompactionResource
);
});
} else {
- return buildResponse(coordinatorClient.getCompactionSnapshots(null));
+ return ServletResourceUtils.buildReadResponse(() -> {
+ final CompactionStatusResponse response = FutureUtils.getUnchecked(
+ coordinatorClient.getCompactionSnapshots(null),
+ true
+ );
+
+ return new CompactionStatusResponse(
+ AuthorizationUtils.filterByAuthorizedDatasources(
+ request,
+ response.getLatestStatus(),
+ AutoCompactionSnapshot::getDataSource,
+ authorizerMapper
+ )
+ );
+ });
}
}
diff --git
a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResourceTest.java
b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResourceTest.java
index 1bc00709c4b..fc20739af15 100644
---
a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResourceTest.java
+++
b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResourceTest.java
@@ -255,6 +255,26 @@ public class OverlordCompactionResourceTest
Assert.assertEquals(new CompactionStatusResponse(List.of(snapshot)),
response.getEntity());
}
+ @Test
+ public void
test_getAllCompactionSnapshots_redirectsToCoordinator_ifSchedulerIsDisabled()
+ {
+ useSupervisors.set(false);
+
+ final AutoCompactionSnapshot snapshot =
+ AutoCompactionSnapshot.builder(TestDataSource.WIKI).build();
+
+ setupMockRequestForUser("druid");
+ EasyMock.expect(httpRequest.getMethod()).andReturn("GET").once();
+
+ EasyMock.expect(coordinatorClient.getCompactionSnapshots(null))
+ .andReturn(Futures.immediateFuture(new
CompactionStatusResponse(List.of(snapshot))));
+ replayAll();
+
+ final Response response =
compactionResource.getAllCompactionSnapshots(httpRequest);
+ Assert.assertEquals(200, response.getStatus());
+ Assert.assertEquals(new CompactionStatusResponse(List.of(snapshot)),
response.getEntity());
+ }
+
@Test
public void test_getDatasourceCompactionConfig()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]