diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java index 4e5d8cd..c8ce3cc 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java @@ -26,7 +26,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.io.PrintWriter; import java.lang.Thread.State; import java.nio.ByteBuffer; import java.security.PrivilegedExceptionAction; @@ -123,9 +126,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystemTestUtil; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics; -import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairSchedulerConfiguration; import org.apache.hadoop.yarn.util.Clock; import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.UTCClock; @@ -1308,11 +1312,14 @@ public void testParseTimelineDelegationTokenRenewer() throws Exception { } private MiniYARNCluster setupMiniYARNCluster() throws Exception { - CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); - ReservationSystemTestUtil.setupQueueConfiguration(conf); - conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, - ResourceScheduler.class); - conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true); + Configuration conf = new YarnConfiguration(); + String scheduler = conf.get(YarnConfiguration.RM_SCHEDULER); + if (scheduler.equals(FairScheduler.class.getName())) { + conf = configureReservationForFairScheduler(); + } else if (scheduler.equals(CapacityScheduler.class.getName())) { + conf = configureReservationForCapacityScheduler(); + } + MiniYARNCluster cluster = new MiniYARNCluster("testReservationAPIs", 2, 1, 1); @@ -1332,6 +1339,44 @@ public Boolean get() { return cluster; } + private Configuration configureReservationForCapacityScheduler() { + CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); + ReservationSystemTestUtil.setupQueueConfiguration(conf); + conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true); + return conf; + } + + private Configuration configureReservationForFairScheduler() { + final String testDir = new File(System.getProperty( + "test.build.data", "/tmp")).getAbsolutePath(); + final String allocFile = new File(testDir, + "test-fs-queues.xml").getAbsolutePath(); + + Configuration conf = new Configuration(); + try { + PrintWriter out = new PrintWriter(new FileWriter(allocFile)); + out.println(""); + out.println(""); + out.println(""); + out.println(" "); + out.println(" "); + out.println(" "); + // set weight to 10 to make sure this queue get enough steady fair share + out.println(" 10"); + out.println(" "); + out.println(""); + out.println("drf" + + ""); + out.println(""); + out.close(); + } catch (IOException e) { + } + + conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, allocFile); + conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true); + return conf; + } + private YarnClient setupYarnClient(MiniYARNCluster cluster) { final Configuration yarnConf = cluster.getConfig(); YarnClient client = YarnClient.createYarnClient();