From a7a5737bc46c9c9e1aa2bcc5c8a3e06d15394891 Mon Sep 17 00:00:00 2001 From: Jian He Date: Wed, 29 Apr 2015 14:50:01 -0700 Subject: [PATCH] YARN-3533. Test: Fix launchAM in MockRM to wait for attempt to be scheduled. Contributed by Anubhav Dhoot (cherry picked from commit 4c1af156aef4f3bb1d9823d5980c59b12007dc77) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../apache/hadoop/yarn/server/resourcemanager/MockRM.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 8f4907f9902..fe8221f390f 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -223,6 +223,9 @@ Release 2.8.0 - UNRELEASED YARN-3517. RM web ui for dumping scheduler logs should be for admins only (Varun Vasudev via tgraves) + YARN-3533. Test: Fix launchAM in MockRM to wait for attempt to be scheduled. + (Anubhav Dhoot via jianhe) + Release 2.7.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 f2b1d8646de..63d6557f961 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 @@ -164,6 +164,8 @@ public class MockRM extends ResourceManager { nm.nodeHeartbeat(true); Thread.sleep(200); } + Assert.assertNotNull("Failed in waiting for " + containerId + " " + + "allocation.", getResourceScheduler().getRMContainer(containerId)); } public void waitForContainerToComplete(RMAppAttempt attempt, @@ -662,7 +664,7 @@ public class MockRM extends ResourceManager { am.waitForState(RMAppAttemptState.FINISHED); rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED); } - + @SuppressWarnings("rawtypes") private static void waitForSchedulerAppAttemptAdded( ApplicationAttemptId attemptId, MockRM rm) throws InterruptedException { @@ -677,6 +679,9 @@ public class MockRM extends ResourceManager { } tick++; } + Assert.assertNotNull("Timed out waiting for SchedulerApplicationAttempt=" + + attemptId + " to be added.", ((AbstractYarnScheduler) + rm.getResourceScheduler()).getApplicationAttempt(attemptId)); } public static MockAM launchAM(RMApp app, MockRM rm, MockNM nm) @@ -684,6 +689,7 @@ public class MockRM extends ResourceManager { rm.waitForState(app.getApplicationId(), RMAppState.ACCEPTED); RMAppAttempt attempt = app.getCurrentAppAttempt(); waitForSchedulerAppAttemptAdded(attempt.getAppAttemptId(), rm); + rm.waitForState(attempt.getAppAttemptId(), RMAppAttemptState.SCHEDULED); System.out.println("Launch AM " + attempt.getAppAttemptId()); nm.nodeHeartbeat(true); MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());