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

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/LocalInputChannelTest.java
 ##########
 @@ -389,25 +401,80 @@ public void testGetNextAfterPartitionReleased() throws 
Exception {
                try {
                        channel.getNextBuffer();
                        fail("Did not throw expected CancelTaskException");
-               } catch (CancelTaskException ignored) {
+               } catch (DataConsumptionException ignored) {
                }
 
                channel.releaseAllResources();
                assertFalse(channel.getNextBuffer().isPresent());
        }
 
+       /**
+        * Tests the {@link PartitionNotFoundException} is thrown during 
requesting partition and
+        * wrapped into {@link DataConsumptionException}.
+        */
+       @Test
+       public void testDataConsumptionExceptionDuringPartitionRequest() throws 
Exception {
+               Tuple2<Integer, Integer> backoff = new Tuple2<>(0, 0);
+
+               ResultPartitionManager partitionManager = new 
ResultPartitionManager();
+
+               ResultPartitionID partitionId = new ResultPartitionID();
+
+               LocalInputChannel ch = createLocalInputChannel(
+                       InputChannelTestUtils.createSingleInputGate(1), 
partitionId, partitionManager, backoff);
+
+               try {
+                       ch.requestSubpartition(0);
+                       fail("Did not throw expected DataConsumptionException");
+               } catch (IOException ex) {
+                       assertTrue(ExceptionUtils.findThrowable(ex, 
PartitionNotFoundException.class).isPresent());
+                       verifyDataConsumptionException(partitionId, ex);
+               }
+       }
+
+       /**
+        * Tests the {@link DataConsumptionException} is wrapped when {@link 
ResultSubpartitionView#getNextBuffer()}
+        * throws an exception.
+        */
+       @Test
+       public void testDataConsumptionExceptionDuringGetNextBuffer() throws 
Exception {
+               Tuple2<Integer, Integer> backoff = new Tuple2<>(0, 0);
+
+               ResultSubpartitionView view = 
mock(ResultSubpartitionView.class);
+               when(view.getNextBuffer()).thenThrow(new IOException("Expected 
test exception"));
+
+               ResultPartitionManager partitionManager = 
mock(ResultPartitionManager.class);
+               when(partitionManager
+                       .createSubpartitionView(any(ResultPartitionID.class), 
anyInt(), any(BufferAvailabilityListener.class)))
+                       .thenReturn(view);
 
 Review comment:
   Same here. Is it possible to do it without mocking?

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

Reply via email to