github-advanced-security[bot] commented on code in PR #19286:
URL: https://github.com/apache/druid/pull/19286#discussion_r3132306836
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorStateTest.java:
##########
@@ -3588,4 +3741,118 @@
serverPriority
);
}
+
+ /**
+ * Resets the {@link #spec} and {@link #taskMaster} mocks so the supervisor
sees an ioConfig with
+ * the given direction-specific cooldowns and so {@code
changeTaskCountInIOConfig} can run
+ * without hitting unmocked calls. Returns a dedicated emitter for the
caller to pass into the
+ * notice handler so dynamic-allocation events can be asserted in isolation.
+ */
+ private StubServiceEmitter setupSupervisorForAutoScalingTest(
+ long minScaleUpDelayMillis,
+ long minScaleDownDelayMillis,
+ int initialTaskCount
+ )
+ {
+ final AutoScalerConfig autoScalerConfig = testAutoScalerConfig(
+ minScaleUpDelayMillis,
+ minScaleDownDelayMillis
+ );
+ final SeekableStreamSupervisorIOConfig ioConfig = createSupervisorIOConfig(
+ initialTaskCount,
+ autoScalerConfig,
+ null
+ );
+ return resetSpecAndTaskMasterForScaling(ioConfig);
+ }
+
+ /**
+ * Returns a minimal test-only {@link AutoScalerConfig}
+ */
+ private static AutoScalerConfig testAutoScalerConfig(long
minScaleUpDelayMillis, long minScaleDownDelayMillis)
+ {
+ return new AutoScalerConfig()
+ {
+ @Override
+ public boolean getEnableTaskAutoScaler()
+ {
+ return true;
+ }
+
+ @Override
+ public long getMinTriggerScaleActionFrequencyMillis()
+ {
+ return 0L;
+ }
+
+ @Override
+ public Duration getMinScaleUpDelay()
+ {
+ return Duration.millis(minScaleUpDelayMillis);
+ }
+
+ @Override
+ public Duration getMinScaleDownDelay()
+ {
+ return Duration.millis(minScaleDownDelayMillis);
+ }
+
+ @Override
+ public int getTaskCountMax()
+ {
+ return 100;
+ }
+
+ @Override
+ public int getTaskCountMin()
+ {
+ return 1;
+ }
+
+ @Override
+ public Integer getTaskCountStart()
+ {
+ return null;
+ }
+
+ @Override
+ public Double getStopTaskCountRatio()
+ {
+ return null;
+ }
+
+ @Override
+ public SupervisorTaskAutoScaler createAutoScaler(
+ Supervisor supervisor,
+ SupervisorSpec spec,
+ ServiceEmitter emitter
+ )
+ {
+ throw new UnsupportedOperationException("test autoscaler config:
createAutoScaler not used");
+ }
+ };
+ }
+
+ private StubServiceEmitter
resetSpecAndTaskMasterForScaling(SeekableStreamSupervisorIOConfig ioConfig)
+ {
+ final StubServiceEmitter scalingEmitter = new
StubServiceEmitter("scaling", "localhost");
+
+ EasyMock.reset(spec, taskMaster);
+ EasyMock.expect(spec.getId()).andReturn(SUPERVISOR_ID).anyTimes();
+
EasyMock.expect(spec.getSupervisorStateManagerConfig()).andReturn(supervisorConfig).anyTimes();
+
EasyMock.expect(spec.getDataSchema()).andReturn(getDataSchema()).anyTimes();
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [SeekableStreamSupervisorSpec.getDataSchema](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11123)
--
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]