You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/10/02 02:35:07 UTC

[GitHub] [beam] kennknowles commented on a change in pull request #12994: Add support for gracefully aborting workers.

kennknowles commented on a change in pull request #12994:
URL: https://github.com/apache/beam/pull/12994#discussion_r498595635



##########
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:
       Same

##########
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:
       It would be nice for the next person if there is a diagnostic error message attached to this failure, lest we get a failure that says "false is not true".




----------------------------------------------------------------
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:
users@infra.apache.org