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_r285985409
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/consumer/LocalInputChannelTest.java
 ##########
 @@ -269,6 +272,73 @@ public void testProducerFailedException() throws 
Exception {
                ch.getNextBuffer();
        }
 
+       /**
+        * Tests that {@link LocalInputChannel#requestSubpartition(int)} throws 
{@link PartitionNotFoundException}
+        * if the result partition was not registered in {@link 
ResultPartitionManager} and no backoff.
+        */
+       @Test
+       public void testPartitionNotFoundExceptionWhileRequestingPartition() 
throws Exception {
+               final SingleInputGate inputGate = createSingleInputGate(1);
+               final LocalInputChannel localChannel = 
createLocalInputChannel(inputGate, new ResultPartitionManager());
+
+               try {
+                       localChannel.requestSubpartition(0);
+
+                       fail("Should throw PartitionNotFoundException while 
requesting unregistered partition.");
+               } catch (PartitionNotFoundException notFound) {
+                       assertThat(localChannel.getPartitionId(), 
Matchers.is(notFound.getPartitionId()));
+               }
+       }
+
+       /**
+        * Tests that {@link 
SingleInputGate#retriggerPartitionRequest(IntermediateResultPartitionID)} is 
triggered
+        * after {@link LocalInputChannel#requestSubpartition(int)} throws 
{@link PartitionNotFoundException}
+        * within backoff.
+        */
+       @Test
+       public void testRetriggerPartitionRequestWhilePartitionNotFound() 
throws Exception {
+               final SingleInputGate inputGate = createSingleInputGate(1);
+               final LocalInputChannel localChannel = createLocalInputChannel(
+                       inputGate, new ResultPartitionManager(), 1, 1);
+
+               
inputGate.setInputChannel(localChannel.getPartitionId().getPartitionId(), 
localChannel);
+               localChannel.requestSubpartition(0);
+
+               // The timer should be initialized at the first time of 
retriggering partition request.
+               assertNotNull(inputGate.getRetriggerLocalRequestTimer());
+       }
+
+       /**
+        * Tests that {@link 
LocalInputChannel#retriggerSubpartitionRequest(Timer, int)} would throw
+        * {@link PartitionNotFoundException} which is set onto the input 
channel then.
+        */
+       @Test
+       public void testChannelErrorWhileRetriggeringRequest() {
+               final SingleInputGate inputGate = createSingleInputGate(1);
+               final LocalInputChannel localChannel = 
createLocalInputChannel(inputGate, new ResultPartitionManager());
+
+               final Timer timer = new Timer(true) {
+                       @Override
+                       public void schedule(TimerTask task, long delay) {
+                               task.run();
+
+                               try {
+                                       localChannel.checkError();
 
 Review comment:
   `fail` is missing

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