1996fanrui commented on code in PR #824:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/824#discussion_r1594925851
##########
flink-autoscaler-standalone/src/test/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutorTest.java:
##########
@@ -227,6 +229,160 @@ public void cleanup(JobID jobID) {
}
}
+ @Test
+ void testCleanupAfterStopped() throws Exception {
+ var eventCollector = new TestingEventCollector<JobID,
JobAutoScalerContext<JobID>>();
+
+ var job1 = createJobAutoScalerContext();
+ var job2 = createJobAutoScalerContext();
+ var scaleCounter = new ConcurrentHashMap<JobID, Integer>();
+ var cleanupCounter = new ConcurrentHashMap<JobID, Integer>();
+
+ var jobList = new ArrayList<JobAutoScalerContext<JobID>>();
+
+ try (var autoscalerExecutor =
+ new StandaloneAutoscalerExecutor<>(
+ new Configuration(),
+ () -> jobList,
+ eventCollector,
+ new JobAutoScaler<>() {
+ @Override
+ public void scale(JobAutoScalerContext<JobID>
context) {
+ scaleCounter.put(
+ context.getJobKey(),
+
scaleCounter.getOrDefault(context.getJobKey(), 0) + 1);
+ }
+
+ @Override
+ public void cleanup(JobID jobID) {
+ cleanupCounter.put(
+ jobID,
cleanupCounter.getOrDefault(jobID, 0) + 1);
+ }
+ })) {
+
+ // Test for empty job list.
+ autoscalerExecutor.scaling();
+ Thread.sleep(100);
Review Comment:
Good suggestion!
Updated with your idea, and I changed some code for
`StandaloneAutoscalerExecutorTest#testCleanupForStoppedJobAfterScaling`.
--
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]