From 831369775223842d71e9d5fd8be40f60a0f8f34f Mon Sep 17 00:00:00 2001 From: Bikas Saha Date: Wed, 20 Nov 2013 21:16:39 +0000 Subject: [PATCH] YARN-1425. TestRMRestart fails because MockRM.waitForState(AttemptId) uses current attempt instead of the attempt passed as argument (Omkar Vinit Joshi via bikas) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1543952 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 4 ++++ .../hadoop/yarn/server/resourcemanager/MockRM.java | 2 +- .../yarn/server/resourcemanager/TestRMRestart.java | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 02063861a13..9f0f702a102 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -160,6 +160,10 @@ Release 2.3.0 - UNRELEASED process same allocate request twice resulting in additional containers getting allocated. (Omkar Vinit Joshi via bikas) + YARN-1425. TestRMRestart fails because MockRM.waitForState(AttemptId) uses + current attempt instead of the attempt passed as argument (Omkar Vinit + Joshi via bikas) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java index c9a8e6a9ecb..78ca7d1633c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java @@ -107,7 +107,7 @@ public class MockRM extends ResourceManager { throws Exception { RMApp app = getRMContext().getRMApps().get(attemptId.getApplicationId()); Assert.assertNotNull("app shouldn't be null", app); - RMAppAttempt attempt = app.getCurrentAppAttempt(); + RMAppAttempt attempt = app.getRMAppAttempt(attemptId); int timeoutSecs = 0; while (!finalState.equals(attempt.getAppAttemptState()) && timeoutSecs++ < 40) { System.out.println("AppAttempt : " + attemptId diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index d34290e05e0..9e145668426 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -487,6 +487,8 @@ public class TestRMRestart { Assert.assertEquals(2, rmApp.getAppAttempts().size()); // am1 attempt should be in FAILED state where as am2 attempt should be in // LAUNCHED state + rm2.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); + rm2.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.LAUNCHED); Assert.assertEquals(RMAppAttemptState.FAILED, rmApp.getAppAttempts().get(am1.getApplicationAttemptId()) .getAppAttemptState()); @@ -524,14 +526,17 @@ public class TestRMRestart { Assert.assertEquals(3, rmApp.getAppAttempts().size()); // am1 and am2 attempts should be in FAILED state where as am3 should be // in LAUNCHED state + rm3.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); + rm3.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); + ApplicationAttemptId latestAppAttemptId = + rmApp.getCurrentAppAttempt().getAppAttemptId(); + rm3.waitForState(latestAppAttemptId, RMAppAttemptState.LAUNCHED); Assert.assertEquals(RMAppAttemptState.FAILED, rmApp.getAppAttempts().get(am1.getApplicationAttemptId()) .getAppAttemptState()); Assert.assertEquals(RMAppAttemptState.FAILED, rmApp.getAppAttempts().get(am2.getApplicationAttemptId()) .getAppAttemptState()); - ApplicationAttemptId latestAppAttemptId = - rmApp.getCurrentAppAttempt().getAppAttemptId(); Assert.assertEquals(RMAppAttemptState.LAUNCHED,rmApp.getAppAttempts() .get(latestAppAttemptId).getAppAttemptState()); @@ -562,6 +567,7 @@ public class TestRMRestart { rm4.waitForState(rmApp.getApplicationId(), RMAppState.ACCEPTED); Assert.assertEquals(4, rmApp.getAppAttempts().size()); Assert.assertEquals(RMAppState.ACCEPTED, rmApp.getState()); + rm4.waitForState(latestAppAttemptId, RMAppAttemptState.SCHEDULED); Assert.assertEquals(RMAppAttemptState.SCHEDULED, rmApp.getAppAttempts() .get(latestAppAttemptId).getAppAttemptState()); @@ -571,6 +577,8 @@ public class TestRMRestart { rm4.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED); Assert.assertEquals(RMAppState.ACCEPTED, app2.getState()); Assert.assertEquals(1, app2.getAppAttempts().size()); + rm4.waitForState(app2.getCurrentAppAttempt().getAppAttemptId(), + RMAppAttemptState.SCHEDULED); Assert.assertEquals(RMAppAttemptState.SCHEDULED, app2 .getCurrentAppAttempt().getAppAttemptState());