tudorm commented on a change in pull request #12994:
URL: https://github.com/apache/beam/pull/12994#discussion_r498598992
##########
File path:
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/util/common/worker/MapTaskExecutorTest.java
##########
@@ -483,4 +483,29 @@ public void testExceptionInAbortSuppressed() throws
Exception {
assertThat(e.getSuppressed()[0].getMessage(), equalTo("suppressed in
abort"));
}
}
+
+ @Test
+ public void testAbort() throws Exception {
+ // Operation must be an instance of ReadOperation or ReceivingOperation
per preconditions
+ // in MapTaskExecutor.
+ Operation o = Mockito.mock(ReadOperation.class);
+
+ ExecutionStateTracker stateTracker = ExecutionStateTracker.newForTest();
+ try (MapTaskExecutor executor =
+ new MapTaskExecutor(Arrays.<Operation>asList(o), counterSet,
stateTracker)) {
+ Mockito.doAnswer(
+ invocation -> {
+ executor.abort();
+ return null;
+ })
+ .when(o)
+ .start();
+ executor.execute();
+ fail("Should have aborted");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof InterruptedException);
Review comment:
Done.
##########
File path:
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/util/common/worker/MapTaskExecutorTest.java
##########
@@ -483,4 +483,29 @@ public void testExceptionInAbortSuppressed() throws
Exception {
assertThat(e.getSuppressed()[0].getMessage(), equalTo("suppressed in
abort"));
}
}
+
+ @Test
+ public void testAbort() throws Exception {
+ // Operation must be an instance of ReadOperation or ReceivingOperation
per preconditions
+ // in MapTaskExecutor.
+ Operation o = Mockito.mock(ReadOperation.class);
+
+ ExecutionStateTracker stateTracker = ExecutionStateTracker.newForTest();
+ try (MapTaskExecutor executor =
+ new MapTaskExecutor(Arrays.<Operation>asList(o), counterSet,
stateTracker)) {
+ Mockito.doAnswer(
+ invocation -> {
+ executor.abort();
+ return null;
+ })
+ .when(o)
+ .start();
+ executor.execute();
+ fail("Should have aborted");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof InterruptedException);
+ Mockito.verify(o).abort();
+ }
+ Assert.assertTrue(Thread.currentThread().isInterrupted());
Review comment:
Done
----------------------------------------------------------------
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]