gaborgsomogyi commented on code in PR #664:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/664#discussion_r1315559669


##########
flink-kubernetes-operator-autoscaler/src/test/java/org/apache/flink/kubernetes/operator/autoscaler/JobAutoScalerImplTest.java:
##########
@@ -196,4 +199,75 @@ void testParallelismOverrides() throws Exception {
         ctx = getResourceContext(app);
         assertEquals(Map.of(), autoscaler.getParallelismOverrides(ctx));
     }
+
+    @Test
+    public void testApplyAutoscalerParallelism() {
+        var overrides = new HashMap<String, String>();
+        var autoscaler =
+                new JobAutoScalerImpl(null, null, null, eventRecorder) {
+                    public Map<String, String> getParallelismOverrides(
+                            FlinkResourceContext<?> ctx) {
+                        return new HashMap<>(overrides);
+                    }
+                };
+
+        var deployment = TestUtils.buildApplicationCluster();
+        var specClone = ReconciliationUtils.clone(deployment.getSpec());
+
+        // Verify no upgrades if overrides are empty
+        autoscaler.applyParallelismOverrides(getResourceContext(deployment));
+        assertEquals(specClone, deployment.getSpec());
+
+        // Test when there are only overrides by the autoscaler
+        var v1 = new JobVertexID();
+        overrides.put(v1.toHexString(), "2");
+
+        // Verify no upgrades if overrides are empty
+        autoscaler.applyParallelismOverrides(getResourceContext(deployment));
+        assertEquals(
+                Map.of(v1.toHexString(), "2"),
+                getResourceContext(deployment)
+                        .getDeployConfig(deployment.getSpec())
+                        .get(PipelineOptions.PARALLELISM_OVERRIDES));
+
+        // Test when there are also user overrides, autoscaler should take 
precedence
+        specClone = ReconciliationUtils.clone(deployment.getSpec());
+
+        // This should be ignored
+        deployment
+                .getSpec()
+                .getFlinkConfiguration()
+                .put(PipelineOptions.PARALLELISM_OVERRIDES.key(), v1 + ":1");
+        autoscaler.applyParallelismOverrides(getResourceContext(deployment));
+        assertEquals(specClone, deployment.getSpec());
+
+        // Define partly overlapping overrides
+        var v2 = new JobVertexID();
+        deployment
+                .getSpec()
+                .getFlinkConfiguration()
+                .put(PipelineOptions.PARALLELISM_OVERRIDES.key(), v1 + ":1," + 
v2 + ":4");

Review Comment:
   OFFTOPIC: As a general user it would be good to see in the doc how to define 
maps in the config.



##########
flink-kubernetes-operator-autoscaler/src/test/java/org/apache/flink/kubernetes/operator/autoscaler/JobAutoScalerImplTest.java:
##########
@@ -196,4 +199,75 @@ void testParallelismOverrides() throws Exception {
         ctx = getResourceContext(app);
         assertEquals(Map.of(), autoscaler.getParallelismOverrides(ctx));
     }
+
+    @Test
+    public void testApplyAutoscalerParallelism() {
+        var overrides = new HashMap<String, String>();
+        var autoscaler =
+                new JobAutoScalerImpl(null, null, null, eventRecorder) {
+                    public Map<String, String> getParallelismOverrides(
+                            FlinkResourceContext<?> ctx) {
+                        return new HashMap<>(overrides);
+                    }
+                };
+
+        var deployment = TestUtils.buildApplicationCluster();
+        var specClone = ReconciliationUtils.clone(deployment.getSpec());
+
+        // Verify no upgrades if overrides are empty
+        autoscaler.applyParallelismOverrides(getResourceContext(deployment));
+        assertEquals(specClone, deployment.getSpec());
+
+        // Test when there are only overrides by the autoscaler
+        var v1 = new JobVertexID();
+        overrides.put(v1.toHexString(), "2");
+
+        // Verify no upgrades if overrides are empty
+        autoscaler.applyParallelismOverrides(getResourceContext(deployment));
+        assertEquals(
+                Map.of(v1.toHexString(), "2"),
+                getResourceContext(deployment)
+                        .getDeployConfig(deployment.getSpec())
+                        .get(PipelineOptions.PARALLELISM_OVERRIDES));
+
+        // Test when there are also user overrides, autoscaler should take 
precedence
+        specClone = ReconciliationUtils.clone(deployment.getSpec());
+
+        // This should be ignored

Review Comment:
   It would be good to add a minimal explanation why: `, because ...`



-- 
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]

Reply via email to