tillrohrmann commented on a change in pull request #8242: [FLINK-6227][network] 
Introduce the PartitionException for downstream task failure
URL: https://github.com/apache/flink/pull/8242#discussion_r285104610
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestServerHandlerTest.java
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * 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.netty;
+
+import org.apache.flink.runtime.io.network.TaskEventDispatcher;
+import org.apache.flink.runtime.io.network.netty.NettyMessage.ErrorResponse;
+import org.apache.flink.runtime.io.network.netty.NettyMessage.PartitionRequest;
+import 
org.apache.flink.runtime.io.network.partition.PartitionNotFoundException;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionManager;
+import org.apache.flink.runtime.io.network.partition.consumer.InputChannelID;
+
+import 
org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link PartitionRequestServerHandler}.
+ */
+public class PartitionRequestServerHandlerTest {
+
+       /**
+        * Tests that {@link PartitionRequestServerHandler} responses {@link 
ErrorResponse} with wrapped
+        * {@link PartitionNotFoundException} after receiving invalid {@link 
PartitionRequest}.
+        */
+       @Test
+       public void testResponsePartitionNotFoundException() {
+               final PartitionRequestServerHandler serverHandler = new 
PartitionRequestServerHandler(
+                       new ResultPartitionManager(),
+                       new TaskEventDispatcher(),
+                       new PartitionRequestQueue(),
+                       true);
+               final EmbeddedChannel channel = new 
EmbeddedChannel(serverHandler);
+               final ResultPartitionID partitionId = new ResultPartitionID();
+
+               // Write the message of partition request to server
+               channel.writeInbound(new PartitionRequest(partitionId, 0, new 
InputChannelID(), 2));
+               channel.runPendingTasks();
+
+               // Read the response message after handling partition request
+               final Object msg = channel.readOutbound();
+
+               assertEquals(msg.getClass(), ErrorResponse.class);
 
 Review comment:
   It's not super critical, but I would suggest to use Hamcrest's Matchers for 
assertions because they offer a bit more expressive assertion messages. With 
Hamcrest it could look like: `assertThat(msg, 
Matchers.instanceOf(ErrorResponse.class))` or `assertThat(msg, 
Matchers.isA(ErrorResponse.class))`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to