From 0b8bfc50c6e759a5693c409cb760b6ad4b316f11 Mon Sep 17 00:00:00 2001 From: Peter Bacsko Date: Mon, 8 Mar 2021 14:32:13 +0100 Subject: [PATCH] YARN-10672. All testcases in TestReservations are flaky. Contributed by Szilard Nemeth. --- .../scheduler/capacity/TestReservations.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java index 625b1e79bad..53c2318ffb7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java @@ -106,7 +106,6 @@ public class TestReservations { CapacityScheduler spyCs = new CapacityScheduler(); cs = spy(spyCs); rmContext = TestUtils.getMockRMContext(); - } private void setup(CapacitySchedulerConfiguration csConf) throws Exception { @@ -115,6 +114,9 @@ public class TestReservations { private void setup(CapacitySchedulerConfiguration csConf, boolean addUserLimits) throws Exception { + //All stub calls on the spy object of the 'cs' field should happen + //before cs.start() is invoked. See YARN-10672 for more details. + when(cs.getNumClusterNodes()).thenReturn(3); csConf.setBoolean(CapacitySchedulerConfiguration.ENABLE_USER_METRICS, true); final String newRoot = "root" + System.currentTimeMillis(); @@ -157,8 +159,6 @@ public class TestReservations { cs.setRMContext(spyRMContext); cs.init(csConf); cs.start(); - - when(cs.getNumClusterNodes()).thenReturn(3); } private static final String A = "a";