You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2017/11/08 14:33:50 UTC
flink git commit: [FLINK-7773] [tests] Move all mocking before
testing code in UtilsTest to avoid unfinished stubbing
Repository: flink
Updated Branches:
refs/heads/master 1602bc3ca -> 7d293692f
[FLINK-7773] [tests] Move all mocking before testing code in UtilsTest to avoid unfinished stubbing
Move all mocking code before the actual testing code in UtilsTest#testYarnFlinkResourceManagerJobManagerLostLeadership.
Hopefully, this will fix the unfinished stubbing exception which still occurs spuriously.
This closes #4957.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/7d293692
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/7d293692
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/7d293692
Branch: refs/heads/master
Commit: 7d293692f328b9c8b560cba7040109c933e1b74d
Parents: 1602bc3
Author: Till Rohrmann <tr...@apache.org>
Authored: Mon Nov 6 17:07:38 2017 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Wed Nov 8 15:32:39 2017 +0100
----------------------------------------------------------------------
.../java/org/apache/flink/yarn/UtilsTest.java | 32 ++++++++++++++------
1 file changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/7d293692/flink-yarn/src/test/java/org/apache/flink/yarn/UtilsTest.java
----------------------------------------------------------------------
diff --git a/flink-yarn/src/test/java/org/apache/flink/yarn/UtilsTest.java b/flink-yarn/src/test/java/org/apache/flink/yarn/UtilsTest.java
index 69c6e7d..ab7f93c 100644
--- a/flink-yarn/src/test/java/org/apache/flink/yarn/UtilsTest.java
+++ b/flink-yarn/src/test/java/org/apache/flink/yarn/UtilsTest.java
@@ -62,6 +62,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import scala.Option;
@@ -135,6 +136,26 @@ public class UtilsTest extends TestLogger {
}
}).when(resourceManagerClient).addContainerRequest(Matchers.any(AMRMClient.ContainerRequest.class));
+ final CompletableFuture<AkkaActorGateway> resourceManagerFuture = new CompletableFuture<>();
+ final CompletableFuture<AkkaActorGateway> leaderGatewayFuture = new CompletableFuture<>();
+
+ doAnswer(
+ (InvocationOnMock invocation) -> {
+ Container container = (Container) invocation.getArguments()[0];
+ resourceManagerFuture.thenCombine(leaderGatewayFuture,
+ (resourceManagerGateway, leaderGateway) -> {
+ resourceManagerGateway.tell(
+ new NotifyResourceStarted(YarnFlinkResourceManager.extractResourceID(container)),
+ leaderGateway);
+ return null;
+ });
+ return null;
+ })
+ .when(nodeManagerClient)
+ .startContainer(
+ Matchers.any(Container.class),
+ Matchers.any(ContainerLaunchContext.class));
+
ActorRef resourceManager = null;
ActorRef leader1;
@@ -169,15 +190,8 @@ public class UtilsTest extends TestLogger {
final AkkaActorGateway leader1Gateway = new AkkaActorGateway(leader1, leaderSessionID);
final AkkaActorGateway resourceManagerGateway = new AkkaActorGateway(resourceManager, leaderSessionID);
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- Container container = (Container) invocation.getArguments()[0];
- resourceManagerGateway.tell(new NotifyResourceStarted(YarnFlinkResourceManager.extractResourceID(container)),
- leader1Gateway);
- return null;
- }
- }).when(nodeManagerClient).startContainer(Matchers.any(Container.class), Matchers.any(ContainerLaunchContext.class));
+ leaderGatewayFuture.complete(leader1Gateway);
+ resourceManagerFuture.complete(resourceManagerGateway);
expectMsgClass(deadline.timeLeft(), RegisterResourceManager.class);