StephanEwen commented on a change in pull request #8290: [FLINK-12070] [network] Implement new bounded blocking subpartitions URL: https://github.com/apache/flink/pull/8290#discussion_r279691076
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/BoundedBlockingSubpartitionWriteReadTest.java ########## @@ -0,0 +1,223 @@ +/* + * 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.partition; + +import org.apache.flink.core.memory.MemorySegment; +import org.apache.flink.core.memory.MemorySegmentFactory; +import org.apache.flink.core.testutils.CheckedThread; +import org.apache.flink.runtime.io.network.buffer.BufferConsumer; +import org.apache.flink.runtime.io.network.partition.ResultSubpartition.BufferAndBacklog; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Tests that read the BoundedBlockingSubpartition with multiple threads in parallel. + */ +public class BoundedBlockingSubpartitionWriteReadTest { + + @ClassRule + public static final TemporaryFolder TMP_FOLDER = new TemporaryFolder(); + + @Test + public void testWriteAndReadData() throws Exception { + final int numLongs = 15_000_000; // roughly 115 MiBytes + + // setup + final BoundedBlockingSubpartition subpartition = createSubpartition(); + writeLongs(subpartition, numLongs); + subpartition.finish(); + + // test + final ResultSubpartitionView reader = subpartition.createReadView(() -> {}); + readLongs(reader, numLongs, subpartition.getBuffersInBacklog()); + + // cleanup + reader.releaseAllResources(); + subpartition.release(); + } + + @Test + public void testWriteAndReadDataAcrossRegions() throws Exception { Review comment: I was looking into alternative byte buffer implementations that would not have that limit, and then we could simply remove that parameter and test, rather than altering other tests as well. There is a trade-off here between "the test should only see methods/parameters related to what it is testing" and code de-duplication. In that case, I leaned towards the first aspect more. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services