diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java index 38178a4..0e6fb5b 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClient.java @@ -122,6 +122,7 @@ static String[] nodes; static String[] racks; private final static int DEFAULT_ITERATION = 3; + private final static int SETUP_RETRIES = 20; @BeforeClass public static void setup() throws Exception { @@ -145,8 +146,21 @@ public static void setup() throws Exception { yarnClient.start(); // get node info - nodeReports = yarnClient.getNodeReports(NodeState.RUNNING); + for (int i = 0; i < SETUP_RETRIES; i++) { + nodeReports = yarnClient.getNodeReports(NodeState.RUNNING); + + if (nodeReports.size() == nodeCount) { + break; + } + + sleep(50); + } + if (nodeReports.size() != nodeCount) { + fail("Not all node managers were reported running within " + + SETUP_RETRIES + " iterations"); + } + priority = Priority.newInstance(1); priority2 = Priority.newInstance(2); capability = Resource.newInstance(1024, 1); @@ -1350,11 +1364,11 @@ public void testWaitFor() throws InterruptedException { } } - private void sleep(int sleepTime) { + private static void sleep(int sleepTime) { try { Thread.sleep(sleepTime); - } catch (InterruptedException e) { - e.printStackTrace(); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); } }