github-advanced-security[bot] commented on code in PR #19286:
URL: https://github.com/apache/druid/pull/19286#discussion_r3074855460
##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagBasedAutoScalerConfigTest.java:
##########
@@ -278,11 +299,145 @@
true,
null,
null,
+ null,
+ null,
0.5
);
Assert.assertEquals(Double.valueOf(0.5), config.getStopTaskCountRatio());
}
+ @Test
+ public void testScaleDelayFallback() throws Exception
+ {
+ // Neither minScaleUpDelay nor minScaleDownDelay set: both fall back to
minTriggerScaleActionFrequencyMillis
+ LagBasedAutoScalerConfig baseOnly = new LagBasedAutoScalerConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 10,
+ null,
+ 1,
+ null,
+ null,
+ false,
+ 60000L,
+ null,
+ null,
+ null,
+ null
+ );
+ Assert.assertEquals(60000L,
baseOnly.getMinTriggerScaleActionFrequencyMillis());
+ Assert.assertEquals(Duration.millis(60000), baseOnly.getMinScaleUpDelay());
+ Assert.assertEquals(Duration.millis(60000),
baseOnly.getMinScaleDownDelay());
+
+ // Only minScaleUpDelay set
+ LagBasedAutoScalerConfig upOnly = new LagBasedAutoScalerConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 10,
+ null,
+ 1,
+ null,
+ null,
+ false,
+ 60000L,
+ Duration.millis(15000),
+ null,
+ null,
+ null
+ );
+ Assert.assertEquals(Duration.millis(15000), upOnly.getMinScaleUpDelay());
+ Assert.assertEquals(Duration.millis(60000), upOnly.getMinScaleDownDelay());
+
+ // Only minScaleDownDelay set
+ LagBasedAutoScalerConfig downOnly = new LagBasedAutoScalerConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 10,
+ null,
+ 1,
+ null,
+ null,
+ false,
+ 60000L,
+ null,
+ Duration.millis(30000),
+ null,
+ null
+ );
+ Assert.assertEquals(Duration.millis(60000), downOnly.getMinScaleUpDelay());
+ Assert.assertEquals(Duration.millis(30000),
downOnly.getMinScaleDownDelay());
+
+ // Both set: serde roundtrip preserves values
+ LagBasedAutoScalerConfig bothSet = new LagBasedAutoScalerConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 10,
+ null,
+ 1,
+ null,
+ null,
+ false,
+ 60000L,
+ Duration.millis(15000),
+ Duration.millis(30000),
+ null,
+ null
+ );
+ Assert.assertEquals(Duration.millis(15000), bothSet.getMinScaleUpDelay());
+ Assert.assertEquals(Duration.millis(30000),
bothSet.getMinScaleDownDelay());
+ LagBasedAutoScalerConfig roundTripped = OBJECT_MAPPER.readValue(
+ OBJECT_MAPPER.writeValueAsString(bothSet),
+ LagBasedAutoScalerConfig.class
+ );
+ Assert.assertEquals(bothSet, roundTripped);
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void testScaleDelayFallbackViaSerde() throws Exception
+ {
+ // JSON with only minTriggerScaleActionFrequencyMillis (no Duration
fields):
+ // both getMinScaleUpDelay() and getMinScaleDownDelay() should fall back
to it.
+ String json =
"{\"taskCountMax\":10,\"taskCountMin\":1,\"minTriggerScaleActionFrequencyMillis\":45000}";
+ LagBasedAutoScalerConfig config = OBJECT_MAPPER.readValue(json,
LagBasedAutoScalerConfig.class);
+ Assert.assertEquals(45000L,
config.getMinTriggerScaleActionFrequencyMillis());
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking
[LagBasedAutoScalerConfig.getMinTriggerScaleActionFrequencyMillis](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10969)
##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagBasedAutoScalerConfigTest.java:
##########
@@ -278,11 +299,145 @@
true,
null,
null,
+ null,
+ null,
0.5
);
Assert.assertEquals(Double.valueOf(0.5), config.getStopTaskCountRatio());
}
+ @Test
+ public void testScaleDelayFallback() throws Exception
+ {
+ // Neither minScaleUpDelay nor minScaleDownDelay set: both fall back to
minTriggerScaleActionFrequencyMillis
+ LagBasedAutoScalerConfig baseOnly = new LagBasedAutoScalerConfig(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 10,
+ null,
+ 1,
+ null,
+ null,
+ false,
+ 60000L,
+ null,
+ null,
+ null,
+ null
+ );
+ Assert.assertEquals(60000L,
baseOnly.getMinTriggerScaleActionFrequencyMillis());
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking
[LagBasedAutoScalerConfig.getMinTriggerScaleActionFrequencyMillis](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10968)
--
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]