This is an automated email from the ASF dual-hosted git repository.
akalash pushed a commit to branch release-1.17
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.17 by this push:
new aa47c3f8624 [FLINK-30852][runtime] Checking task cancelation
explicitly rather than failing the cancel method
aa47c3f8624 is described below
commit aa47c3f862414511e92637d9816f6908c86b4cf6
Author: Anton Kalashnikov <[email protected]>
AuthorDate: Thu Feb 2 16:10:43 2023 +0100
[FLINK-30852][runtime] Checking task cancelation explicitly rather than
failing the cancel method
(cherry picked from commit a6f0165c09b7f276f1e755ba46c7f15bf4f21c92)
---
.../apache/flink/runtime/taskmanager/TaskTest.java | 46 +++++++++++-----------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git
a/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskTest.java
index 057d6f3dd49..5a1a2c2de86 100644
---
a/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskTest.java
+++
b/flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskTest.java
@@ -158,31 +158,35 @@ public class TaskTest extends TestLogger {
@Test
public void testCleanupWhenAfterInvokeSucceeded() throws Exception {
- createTaskBuilder()
- .setInvokable(TestInvokableCorrect.class)
- .build(Executors.directExecutor())
- .run();
+ Task task =
+ createTaskBuilder()
+ .setInvokable(TestInvokableCorrect.class)
+ .build(Executors.directExecutor());
+ task.run();
assertTrue(wasCleanedUp);
+ assertFalse(task.isCanceledOrFailed());
}
@Test
public void testCleanupWhenSwitchToInitializationFails() throws Exception {
- createTaskBuilder()
- .setInvokable(TestInvokableCorrect.class)
- .setTaskManagerActions(
- new NoOpTaskManagerActions() {
- @Override
- public void updateTaskExecutionState(
- TaskExecutionState taskExecutionState) {
- if (taskExecutionState.getExecutionState()
- == ExecutionState.INITIALIZING) {
- throw new ExpectedTestException();
- }
- }
- })
- .build(Executors.directExecutor())
- .run();
+ Task task =
+ createTaskBuilder()
+ .setInvokable(TestInvokableCorrect.class)
+ .setTaskManagerActions(
+ new NoOpTaskManagerActions() {
+ @Override
+ public void updateTaskExecutionState(
+ TaskExecutionState
taskExecutionState) {
+ if
(taskExecutionState.getExecutionState()
+ ==
ExecutionState.INITIALIZING) {
+ throw new ExpectedTestException();
+ }
+ }
+ })
+ .build(Executors.directExecutor());
+ task.run();
assertTrue(wasCleanedUp);
+ assertTrue(task.isCanceledOrFailed());
}
@Test
@@ -1300,9 +1304,7 @@ public class TaskTest extends TestLogger {
public void invoke() {}
@Override
- public void cancel() {
- fail("This should not be called");
- }
+ public void cancel() {}
@Override
public void cleanUp(Throwable throwable) throws Exception {