|
@@ -41,6 +41,7 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
+import com.google.common.base.Supplier;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.io.DataInputByteBuffer;
|
|
import org.apache.hadoop.io.DataInputByteBuffer;
|
|
@@ -52,6 +53,7 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.security.token.TokenIdentifier;
|
|
import org.apache.hadoop.security.token.TokenIdentifier;
|
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
|
|
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
|
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest;
|
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest;
|
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse;
|
|
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse;
|
|
@@ -1193,35 +1195,27 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private MiniYARNCluster setupMiniYARNCluster() {
|
|
|
|
|
|
+ private MiniYARNCluster setupMiniYARNCluster() throws Exception {
|
|
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
ReservationSystemTestUtil.setupQueueConfiguration(conf);
|
|
ReservationSystemTestUtil.setupQueueConfiguration(conf);
|
|
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
ResourceScheduler.class);
|
|
ResourceScheduler.class);
|
|
conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true);
|
|
conf.setBoolean(YarnConfiguration.RM_RESERVATION_SYSTEM_ENABLE, true);
|
|
- MiniYARNCluster cluster =
|
|
|
|
|
|
+ final MiniYARNCluster cluster =
|
|
new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
|
new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
|
|
|
|
|
cluster.init(conf);
|
|
cluster.init(conf);
|
|
cluster.start();
|
|
cluster.start();
|
|
|
|
|
|
- int attempts;
|
|
|
|
- for (attempts = 10; attempts > 0; attempts--) {
|
|
|
|
- if (cluster.getResourceManager().getRMContext().getReservationSystem()
|
|
|
|
- .getPlan(ReservationSystemTestUtil.reservationQ).getTotalCapacity()
|
|
|
|
- .getMemorySize() > 6000) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(100);
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean get() {
|
|
|
|
+ return cluster.getResourceManager().getRMContext()
|
|
|
|
+ .getReservationSystem()
|
|
|
|
+ .getPlan(ReservationSystemTestUtil.reservationQ)
|
|
|
|
+ .getTotalCapacity().getMemorySize() > 6000;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (attempts <= 0) {
|
|
|
|
- Assert.fail("Exhausted attempts in checking if node capacity was "
|
|
|
|
- + "added to the plan");
|
|
|
|
- }
|
|
|
|
|
|
+ }, 10, 10000);
|
|
|
|
|
|
return cluster;
|
|
return cluster;
|
|
}
|
|
}
|
|
@@ -1253,7 +1247,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testCreateReservation() {
|
|
|
|
|
|
+ public void testCreateReservation() throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1296,7 +1290,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testUpdateReservation() {
|
|
|
|
|
|
+ public void testUpdateReservation() throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1338,7 +1332,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testListReservationsByReservationId() {
|
|
|
|
|
|
+ public void testListReservationsByReservationId() throws Exception{
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1375,7 +1369,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testListReservationsByTimeInterval() {
|
|
|
|
|
|
+ public void testListReservationsByTimeInterval() throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1440,7 +1434,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testListReservationsByInvalidTimeInterval() {
|
|
|
|
|
|
+ public void testListReservationsByInvalidTimeInterval() throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1490,7 +1484,8 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testListReservationsByTimeIntervalContainingNoReservations() {
|
|
|
|
|
|
+ public void testListReservationsByTimeIntervalContainingNoReservations()
|
|
|
|
+ throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|
|
@@ -1580,7 +1575,7 @@ public class TestYarnClient {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testReservationDelete() {
|
|
|
|
|
|
+ public void testReservationDelete() throws Exception {
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
MiniYARNCluster cluster = setupMiniYARNCluster();
|
|
YarnClient client = setupYarnClient(cluster);
|
|
YarnClient client = setupYarnClient(cluster);
|
|
try {
|
|
try {
|