capistrant commented on code in PR #20063:
URL: https://github.com/apache/druid/pull/20063#discussion_r3814708225
##########
server/src/test/java/org/apache/druid/server/coordinator/duty/RunRulesTest.java:
##########
@@ -1286,6 +1209,94 @@ public void
testSegmentWithZeroRequiredReplicasHasZeroReplicationFactor()
Assert.assertEquals(0, replicaCounts.requiredAndLoadable());
}
+ @Test
+ public void testRuleChangeDuringRunIsNotObservedInThatRun()
+ {
+ mockPeon.loadSegment(EasyMock.anyObject(), EasyMock.anyObject(),
EasyMock.anyObject());
+ EasyMock.expectLastCall().atLeastOnce();
+ mockEmptyPeon();
+
+ final TestMetadataRuleManager ruleManager = new TestMetadataRuleManager();
+ ruleManager.overrideRule(
+ DATASOURCE,
+ Collections.singletonList(new
ForeverLoadRule(ImmutableMap.of("normal", 1), null)),
+ AUDIT_INFO
+ );
+
+ final DruidCluster druidCluster = DruidCluster
+ .builder()
+ .addTier("normal", createServerHolder("server1", "normal", mockPeon))
+ .build();
+
+ final DruidCoordinatorRuntimeParams params =
createCoordinatorRuntimeParams(druidCluster)
+ .withRetentionRulesSnapshot(ruleManager.getRulesSnapshot())
+ .withBalancerStrategy(new CostBalancerStrategy(balancerExecutor))
+ .withDynamicConfigs(
+
CoordinatorDynamicConfig.builder().withSmartSegmentLoading(false).build()
+ )
+ .withSegmentAssignerUsing(loadQueueManager)
+ .build();
+
+ // The rules change after the snapshot was taken, but before the duty runs
+ ruleManager.overrideRule(DATASOURCE, Collections.singletonList(new
ForeverDropRule()), AUDIT_INFO);
+
+ final CoordinatorRunStats stats = runDutyAndGetStats(params);
+
+ // The snapshotted load rule is applied, not the drop rule that replaced it
+ Assert.assertEquals(24L, stats.getSegmentStat(Stats.Segments.ASSIGNED,
"normal", DATASOURCE));
+ Assert.assertEquals(0L, stats.get(Stats.Segments.DELETED,
DATASOURCE_STAT_KEY));
+ }
+
+ @Test
+ public void testRuleChangeToUnresolvedAliasTierDoesNotDropReplicas()
Review Comment:
removed this and added some hopefully more useful tests
--
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]