1996fanrui commented on code in PR #757: URL: https://github.com/apache/flink-kubernetes-operator/pull/757#discussion_r1453296427
########## flink-autoscaler/src/test/java/org/apache/flink/autoscaler/event/AutoScalerEventHandlerTest.java: ########## @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.autoscaler.event; + +import org.apache.flink.autoscaler.ScalingSummary; +import org.apache.flink.autoscaler.metrics.EvaluatedScalingMetric; +import org.apache.flink.runtime.jobgraph.JobVertexID; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.jupiter.api.Test; + +import javax.annotation.Nonnull; + +import java.util.HashMap; +import java.util.Map; + +import static org.apache.flink.autoscaler.metrics.ScalingMetric.EXPECTED_PROCESSING_RATE; +import static org.apache.flink.autoscaler.metrics.ScalingMetric.TARGET_DATA_RATE; +import static org.apache.flink.autoscaler.metrics.ScalingMetric.TRUE_PROCESSING_RATE; +import static org.assertj.core.api.Assertions.assertThat; + +/** Test for {@link AutoScalerEventHandler}. */ +class AutoScalerEventHandlerTest { + + @Test + void testScalingReport() throws JsonProcessingException { + var expectedJson = + "{\"scalingMessage\":\"Scaling execution enabled, begin scaling vertices:\",\"scalingResults\":[" + + "{\"vertexId\":\"0a448493b4782967b150582570326227\",\"currentParallelism\":5,\"newParallelism\":8," + + "\"currentProcessCapacity\":404.727,\"expectedProcessCapacity\":645.0,\"targetDataRate\":404.268}," + + "{\"vertexId\":\"bc764cd8ddf7a0cff126f51c16239658\",\"currentParallelism\":4,\"newParallelism\":2," + + "\"currentProcessCapacity\":\"Infinity\",\"expectedProcessCapacity\":\"Infinity\",\"targetDataRate\":812.583}," + + "{\"vertexId\":\"ea632d67b7d595e5b851708ae9ad79d6\",\"currentParallelism\":3,\"newParallelism\":1," + + "\"currentProcessCapacity\":424.678,\"expectedProcessCapacity\":123.4,\"targetDataRate\":403.673}]}"; Review Comment: I found the json format is easy to read as well. 😂 I added the `JsonPropertyOrder` annotation to control the property order in json format. > It's also a breaking change. Our users expect to see the current format. Could we add an option to determine which format will be used? Also, if current format is useful for read, how about add some separators between 2 vertices? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org