github-advanced-security[bot] commented on code in PR #19051:
URL: https://github.com/apache/druid/pull/19051#discussion_r2850470824
##########
indexing-service/src/test/java/org/apache/druid/indexing/compact/CascadingReindexingTemplateTest.java:
##########
@@ -1507,6 +1516,323 @@
);
}
+ /**
+ * Comprehensive test covering:
+ * - Multiple intervals with different segment granularities
+ * - All rule types (segment gran, data schema, deletion, tuning, IO)
+ * - Non-segment-gran rules triggering interval splitting
+ * - Applied rules tracking with correct rule types in each interval
+ * - Full DataSourceCompactionConfig generation
+ * - Rule count accuracy
+ */
+ @Test
+ public void test_getReindexingTimelineView_comprehensive()
+ {
+ DateTime referenceTime = DateTimes.of("2025-02-01T00:00:00Z");
+
+ // Create rules with various periods to test interval generation and
splitting
+ ReindexingSegmentGranularityRule segGran7d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-7d",
+ null,
+ Period.days(7),
+ Granularities.HOUR
+ );
+
+ ReindexingSegmentGranularityRule segGran30d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-30d",
+ null,
+ Period.days(30),
+ Granularities.DAY
+ );
+
+ // Data schema rule at P15D (will split the HOUR interval)
+ ReindexingDataSchemaRule dataSchema15d = new ReindexingDataSchemaRule(
+ "data-schema-15d",
+ null,
+ Period.days(15),
+ new UserCompactionTaskDimensionsConfig(null),
+ new AggregatorFactory[]{new CountAggregatorFactory("count")},
+ Granularities.MINUTE,
+ true,
+ null
+ );
+
+ // Deletion rules at different periods
+ ReindexingDeletionRule deletion10d = new ReindexingDeletionRule(
+ "deletion-10d",
+ null,
+ Period.days(10),
+ new EqualityFilter("country", ColumnType.STRING, "US", null),
+ null
+ );
+
+ ReindexingDeletionRule deletion20d = new ReindexingDeletionRule(
+ "deletion-20d",
+ null,
+ Period.days(20),
+ new EqualityFilter("device", ColumnType.STRING, "mobile", null),
+ null
+ );
+
+ // Tuning and IO rules
+ ReindexingTuningConfigRule tuning7d = new ReindexingTuningConfigRule(
+ "tuning-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskQueryTuningConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ )
+ );
+
+ ReindexingIOConfigRule io7d = new ReindexingIOConfigRule(
+ "io-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskIOConfig(true)
+ );
+
+ ReindexingRuleProvider provider = InlineReindexingRuleProvider.builder()
+
.segmentGranularityRules(List.of(segGran7d, segGran30d))
+
.dataSchemaRules(List.of(dataSchema15d))
+
.deletionRules(List.of(deletion10d, deletion20d))
+
.tuningConfigRules(List.of(tuning7d))
+
.ioConfigRules(List.of(io7d))
+ .build();
+
+ CascadingReindexingTemplate template = new CascadingReindexingTemplate(
+ "testDS",
+ null,
+ null,
+ provider,
+ null,
+ null,
+ null,
+ null,
+ Granularities.DAY
+ );
+
+ ReindexingTimelineView timeline =
template.getReindexingTimelineView(referenceTime);
+
+ // Verify basic timeline properties
+ Assertions.assertEquals("testDS", timeline.getDataSource());
+ Assertions.assertEquals(referenceTime, timeline.getReferenceTime());
+ Assertions.assertNull(timeline.getValidationError());
+ Assertions.assertNull(timeline.getSkipOffset());
+
+ // Verify we have multiple intervals (splitting should occur)
+ Assertions.assertTrue(timeline.getIntervals().size() >= 2, "Expected at
least 2 intervals");
+
+ // Verify each interval has correct structure
+ for (ReindexingTimelineView.IntervalConfig intervalConfig :
timeline.getIntervals()) {
+ Assertions.assertNotNull(intervalConfig.getInterval());
+ Assertions.assertTrue(intervalConfig.getRuleCount() > 0, "Rule count
should be > 0");
+ Assertions.assertNotNull(intervalConfig.getConfig());
+ Assertions.assertNotNull(intervalConfig.getAppliedRules());
+ Assertions.assertEquals(
+ intervalConfig.getRuleCount(),
+ intervalConfig.getAppliedRules().size(),
+ "Applied rules size should match rule count"
+ );
+
+ // Verify config has expected components
+ DataSourceCompactionConfig config = intervalConfig.getConfig();
+ Assertions.assertNotNull(config.getGranularitySpec(), "Should have
granularity spec");
+
Assertions.assertNotNull(config.getGranularitySpec().getSegmentGranularity(),
"Should have segment granularity");
+
+ // Verify appliedRules contain expected rule types
+ boolean hasTuningRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingTuningConfigRule);
+ boolean hasIORule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingIOConfigRule);
+ boolean hasDataSchemaRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingDataSchemaRule);
+ boolean hasDeletionRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingDeletionRule);
Review Comment:
## Unread local variable
Variable 'boolean hasDeletionRule' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10831)
##########
indexing-service/src/test/java/org/apache/druid/indexing/compact/CascadingReindexingTemplateTest.java:
##########
@@ -1507,6 +1516,323 @@
);
}
+ /**
+ * Comprehensive test covering:
+ * - Multiple intervals with different segment granularities
+ * - All rule types (segment gran, data schema, deletion, tuning, IO)
+ * - Non-segment-gran rules triggering interval splitting
+ * - Applied rules tracking with correct rule types in each interval
+ * - Full DataSourceCompactionConfig generation
+ * - Rule count accuracy
+ */
+ @Test
+ public void test_getReindexingTimelineView_comprehensive()
+ {
+ DateTime referenceTime = DateTimes.of("2025-02-01T00:00:00Z");
+
+ // Create rules with various periods to test interval generation and
splitting
+ ReindexingSegmentGranularityRule segGran7d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-7d",
+ null,
+ Period.days(7),
+ Granularities.HOUR
+ );
+
+ ReindexingSegmentGranularityRule segGran30d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-30d",
+ null,
+ Period.days(30),
+ Granularities.DAY
+ );
+
+ // Data schema rule at P15D (will split the HOUR interval)
+ ReindexingDataSchemaRule dataSchema15d = new ReindexingDataSchemaRule(
+ "data-schema-15d",
+ null,
+ Period.days(15),
+ new UserCompactionTaskDimensionsConfig(null),
+ new AggregatorFactory[]{new CountAggregatorFactory("count")},
+ Granularities.MINUTE,
+ true,
+ null
+ );
+
+ // Deletion rules at different periods
+ ReindexingDeletionRule deletion10d = new ReindexingDeletionRule(
+ "deletion-10d",
+ null,
+ Period.days(10),
+ new EqualityFilter("country", ColumnType.STRING, "US", null),
+ null
+ );
+
+ ReindexingDeletionRule deletion20d = new ReindexingDeletionRule(
+ "deletion-20d",
+ null,
+ Period.days(20),
+ new EqualityFilter("device", ColumnType.STRING, "mobile", null),
+ null
+ );
+
+ // Tuning and IO rules
+ ReindexingTuningConfigRule tuning7d = new ReindexingTuningConfigRule(
+ "tuning-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskQueryTuningConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ )
+ );
+
+ ReindexingIOConfigRule io7d = new ReindexingIOConfigRule(
+ "io-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskIOConfig(true)
+ );
+
+ ReindexingRuleProvider provider = InlineReindexingRuleProvider.builder()
+
.segmentGranularityRules(List.of(segGran7d, segGran30d))
+
.dataSchemaRules(List.of(dataSchema15d))
+
.deletionRules(List.of(deletion10d, deletion20d))
+
.tuningConfigRules(List.of(tuning7d))
+
.ioConfigRules(List.of(io7d))
+ .build();
+
+ CascadingReindexingTemplate template = new CascadingReindexingTemplate(
+ "testDS",
+ null,
+ null,
+ provider,
+ null,
+ null,
+ null,
+ null,
+ Granularities.DAY
+ );
+
+ ReindexingTimelineView timeline =
template.getReindexingTimelineView(referenceTime);
+
+ // Verify basic timeline properties
+ Assertions.assertEquals("testDS", timeline.getDataSource());
+ Assertions.assertEquals(referenceTime, timeline.getReferenceTime());
+ Assertions.assertNull(timeline.getValidationError());
+ Assertions.assertNull(timeline.getSkipOffset());
+
+ // Verify we have multiple intervals (splitting should occur)
+ Assertions.assertTrue(timeline.getIntervals().size() >= 2, "Expected at
least 2 intervals");
+
+ // Verify each interval has correct structure
+ for (ReindexingTimelineView.IntervalConfig intervalConfig :
timeline.getIntervals()) {
+ Assertions.assertNotNull(intervalConfig.getInterval());
+ Assertions.assertTrue(intervalConfig.getRuleCount() > 0, "Rule count
should be > 0");
+ Assertions.assertNotNull(intervalConfig.getConfig());
+ Assertions.assertNotNull(intervalConfig.getAppliedRules());
+ Assertions.assertEquals(
+ intervalConfig.getRuleCount(),
+ intervalConfig.getAppliedRules().size(),
+ "Applied rules size should match rule count"
+ );
+
+ // Verify config has expected components
+ DataSourceCompactionConfig config = intervalConfig.getConfig();
+ Assertions.assertNotNull(config.getGranularitySpec(), "Should have
granularity spec");
+
Assertions.assertNotNull(config.getGranularitySpec().getSegmentGranularity(),
"Should have segment granularity");
+
+ // Verify appliedRules contain expected rule types
+ boolean hasTuningRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingTuningConfigRule);
+ boolean hasIORule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingIOConfigRule);
+ boolean hasDataSchemaRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingDataSchemaRule);
Review Comment:
## Unread local variable
Variable 'boolean hasDataSchemaRule' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10830)
##########
indexing-service/src/test/java/org/apache/druid/indexing/compact/CascadingReindexingTemplateTest.java:
##########
@@ -1507,6 +1516,323 @@
);
}
+ /**
+ * Comprehensive test covering:
+ * - Multiple intervals with different segment granularities
+ * - All rule types (segment gran, data schema, deletion, tuning, IO)
+ * - Non-segment-gran rules triggering interval splitting
+ * - Applied rules tracking with correct rule types in each interval
+ * - Full DataSourceCompactionConfig generation
+ * - Rule count accuracy
+ */
+ @Test
+ public void test_getReindexingTimelineView_comprehensive()
+ {
+ DateTime referenceTime = DateTimes.of("2025-02-01T00:00:00Z");
+
+ // Create rules with various periods to test interval generation and
splitting
+ ReindexingSegmentGranularityRule segGran7d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-7d",
+ null,
+ Period.days(7),
+ Granularities.HOUR
+ );
+
+ ReindexingSegmentGranularityRule segGran30d = new
ReindexingSegmentGranularityRule(
+ "seg-gran-30d",
+ null,
+ Period.days(30),
+ Granularities.DAY
+ );
+
+ // Data schema rule at P15D (will split the HOUR interval)
+ ReindexingDataSchemaRule dataSchema15d = new ReindexingDataSchemaRule(
+ "data-schema-15d",
+ null,
+ Period.days(15),
+ new UserCompactionTaskDimensionsConfig(null),
+ new AggregatorFactory[]{new CountAggregatorFactory("count")},
+ Granularities.MINUTE,
+ true,
+ null
+ );
+
+ // Deletion rules at different periods
+ ReindexingDeletionRule deletion10d = new ReindexingDeletionRule(
+ "deletion-10d",
+ null,
+ Period.days(10),
+ new EqualityFilter("country", ColumnType.STRING, "US", null),
+ null
+ );
+
+ ReindexingDeletionRule deletion20d = new ReindexingDeletionRule(
+ "deletion-20d",
+ null,
+ Period.days(20),
+ new EqualityFilter("device", ColumnType.STRING, "mobile", null),
+ null
+ );
+
+ // Tuning and IO rules
+ ReindexingTuningConfigRule tuning7d = new ReindexingTuningConfigRule(
+ "tuning-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskQueryTuningConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ )
+ );
+
+ ReindexingIOConfigRule io7d = new ReindexingIOConfigRule(
+ "io-7d",
+ null,
+ Period.days(7),
+ new UserCompactionTaskIOConfig(true)
+ );
+
+ ReindexingRuleProvider provider = InlineReindexingRuleProvider.builder()
+
.segmentGranularityRules(List.of(segGran7d, segGran30d))
+
.dataSchemaRules(List.of(dataSchema15d))
+
.deletionRules(List.of(deletion10d, deletion20d))
+
.tuningConfigRules(List.of(tuning7d))
+
.ioConfigRules(List.of(io7d))
+ .build();
+
+ CascadingReindexingTemplate template = new CascadingReindexingTemplate(
+ "testDS",
+ null,
+ null,
+ provider,
+ null,
+ null,
+ null,
+ null,
+ Granularities.DAY
+ );
+
+ ReindexingTimelineView timeline =
template.getReindexingTimelineView(referenceTime);
+
+ // Verify basic timeline properties
+ Assertions.assertEquals("testDS", timeline.getDataSource());
+ Assertions.assertEquals(referenceTime, timeline.getReferenceTime());
+ Assertions.assertNull(timeline.getValidationError());
+ Assertions.assertNull(timeline.getSkipOffset());
+
+ // Verify we have multiple intervals (splitting should occur)
+ Assertions.assertTrue(timeline.getIntervals().size() >= 2, "Expected at
least 2 intervals");
+
+ // Verify each interval has correct structure
+ for (ReindexingTimelineView.IntervalConfig intervalConfig :
timeline.getIntervals()) {
+ Assertions.assertNotNull(intervalConfig.getInterval());
+ Assertions.assertTrue(intervalConfig.getRuleCount() > 0, "Rule count
should be > 0");
+ Assertions.assertNotNull(intervalConfig.getConfig());
+ Assertions.assertNotNull(intervalConfig.getAppliedRules());
+ Assertions.assertEquals(
+ intervalConfig.getRuleCount(),
+ intervalConfig.getAppliedRules().size(),
+ "Applied rules size should match rule count"
+ );
+
+ // Verify config has expected components
+ DataSourceCompactionConfig config = intervalConfig.getConfig();
+ Assertions.assertNotNull(config.getGranularitySpec(), "Should have
granularity spec");
+
Assertions.assertNotNull(config.getGranularitySpec().getSegmentGranularity(),
"Should have segment granularity");
+
+ // Verify appliedRules contain expected rule types
+ boolean hasTuningRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingTuningConfigRule);
+ boolean hasIORule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingIOConfigRule);
+ boolean hasDataSchemaRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingDataSchemaRule);
+ boolean hasDeletionRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingDeletionRule);
+ boolean hasSegmentGranRule = intervalConfig.getAppliedRules().stream()
+ .anyMatch(r -> r instanceof
ReindexingSegmentGranularityRule);
Review Comment:
## Unread local variable
Variable 'boolean hasSegmentGranRule' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10832)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]