RocMarshal commented on code in PR #27446:
URL: https://github.com/apache/flink/pull/27446#discussion_r2724804658


##########
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/api/writer/AdaptiveLoadBasedRecordWriterTest.java:
##########
@@ -0,0 +1,192 @@
+/*
+ * 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.runtime.io.network.api.writer;
+
+import org.apache.flink.core.io.IOReadableWritable;
+import org.apache.flink.runtime.checkpoint.CheckpointException;
+import org.apache.flink.runtime.event.AbstractEvent;
+import org.apache.flink.runtime.io.network.api.StopMode;
+import 
org.apache.flink.runtime.io.network.partition.BufferAvailabilityListener;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import 
org.apache.flink.runtime.io.network.partition.ResultSubpartitionIndexSet;
+import org.apache.flink.runtime.io.network.partition.ResultSubpartitionView;
+import org.apache.flink.runtime.metrics.groups.TaskIOMetricGroup;
+
+import org.junit.jupiter.api.Test;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link AdaptiveLoadBasedRecordWriter}. */
+class AdaptiveLoadBasedRecordWriterTest {
+
+    @Test
+    void testGetTheIdlestChannelIndex() {
+        final Map<Integer, Long> bytesPerPartition = new HashMap<>();
+        final Map<Integer, Integer> bufferPerPartition = new HashMap<>();
+        TestingResultPartitionWriter resultPartitionWriter =
+                new TestingResultPartitionWriter(3, bytesPerPartition, 
bufferPerPartition);
+
+        bufferPerPartition.put(1, 1);
+        bufferPerPartition.put(2, 1);
+
+        AdaptiveLoadBasedRecordWriter<IOReadableWritable> 
adaptiveLoadBasedRecordWriter =
+                new AdaptiveLoadBasedRecordWriter<>(resultPartitionWriter, 5L, 
"testingTask", 3);
+        
assertThat(adaptiveLoadBasedRecordWriter.getTheIdlestChannelIndex()).isZero();
+        bufferPerPartition.put(1, 1);
+        bufferPerPartition.put(2, 2);
+        bufferPerPartition.put(0, 2);
+        
assertThat(adaptiveLoadBasedRecordWriter.getTheIdlestChannelIndex()).isOne();
+
+        bufferPerPartition.put(0, 2);
+        bufferPerPartition.put(1, 2);
+        bufferPerPartition.put(2, 2);
+        bytesPerPartition.put(0, 5L);
+        bytesPerPartition.put(1, 3L);
+        bytesPerPartition.put(2, 1L);
+        
assertThat(adaptiveLoadBasedRecordWriter.getTheIdlestChannelIndex()).isEqualTo(2);
+    }

Review Comment:
   > the zero bytes case
   > setting different maxTraverseSizes in the config.
   
   Sounds good to me .update.
   
   
   > flush all vs not flush all
   
   The test case is ignored to avoid redundant testing, Because the current 
change is not about the flush performance. It's about the channels selection 
before flushing.
    So, I introduced the benchmark testing in the related [sub-jira 
](https://issues.apache.org/jira/browse/FLINK-38944).
    
    WDYTA?
   



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