This is an automated email from the ASF dual-hosted git repository.

trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 222f87f35560ab4be24b11c20b4a04718968797c
Author: Zhijiang <wangzhijiang...@aliyun.com>
AuthorDate: Wed May 15 17:29:05 2019 +0800

    [hotfix][network,tests] Add new unit tests for 
ResultPartitionManager#createSubpartitionView
    
    It is necessary to make sure PartitionNotFoundException is thrown on 
producer side for flip1, so some new tests are added to cover the cases
    of creating subpartition view via ResultPartitionManager for 
registered/unregistered partitions.
---
 .../partition/ResultPartitionManagerTest.java      | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ResultPartitionManagerTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ResultPartitionManagerTest.java
new file mode 100644
index 0000000..99fd5c9
--- /dev/null
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ResultPartitionManagerTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.util.TestLogger;
+
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests for {@link ResultPartitionManager}.
+ */
+public class ResultPartitionManagerTest extends TestLogger {
+
+       /**
+        * Tests that {@link 
ResultPartitionManager#createSubpartitionView(ResultPartitionID, int, 
BufferAvailabilityListener)}
+        * would throw {@link PartitionNotFoundException} if this partition was 
not registered before.
+        */
+       @Test
+       public void testThrowPartitionNotFoundException() throws Exception {
+               final ResultPartitionManager partitionManager = new 
ResultPartitionManager();
+               final ResultPartition partition = 
PartitionTestUtils.createPartition();
+               try {
+                       
partitionManager.createSubpartitionView(partition.getPartitionId(), 0, new 
NoOpBufferAvailablityListener());
+
+                       fail("Should throw PartitionNotFoundException for 
unregistered partition.");
+               } catch (PartitionNotFoundException notFound) {
+                       assertThat(partition.getPartitionId(), 
Matchers.is(notFound.getPartitionId()));
+               }
+       }
+
+       /**
+        * Tests {@link 
ResultPartitionManager#createSubpartitionView(ResultPartitionID, int, 
BufferAvailabilityListener)}
+        * successful if this partition was already registered before.
+        */
+       @Test
+       public void testCreateViewForRegisteredPartition() throws Exception {
+               final ResultPartitionManager partitionManager = new 
ResultPartitionManager();
+               final ResultPartition partition = 
PartitionTestUtils.createPartition();
+
+               partitionManager.registerResultPartition(partition);
+               
partitionManager.createSubpartitionView(partition.getPartitionId(), 0, new 
NoOpBufferAvailablityListener());
+       }
+}

Reply via email to