YARN-4994. Use MiniYARNCluster with try-with-resources in tests. Contributed by Andras Bokor.
This commit is contained in:
parent
736f54b727
commit
ae401539ea
|
@ -563,11 +563,9 @@ public class TestJobHistoryEventHandler {
|
||||||
TestParams t = new TestParams(RunningAppContext.class, false);
|
TestParams t = new TestParams(RunningAppContext.class, false);
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||||
MiniYARNCluster yarnCluster = null;
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
try {
|
try (MiniYARNCluster yarnCluster = new MiniYARNCluster(
|
||||||
yarnCluster = new MiniYARNCluster(
|
TestJobHistoryEventHandler.class.getSimpleName(), 1, 1, 1, 1)) {
|
||||||
TestJobHistoryEventHandler.class.getSimpleName(), 1, 1, 1, 1);
|
|
||||||
yarnCluster.init(conf);
|
yarnCluster.init(conf);
|
||||||
yarnCluster.start();
|
yarnCluster.start();
|
||||||
Configuration confJHEH = new YarnConfiguration(conf);
|
Configuration confJHEH = new YarnConfiguration(conf);
|
||||||
|
@ -720,10 +718,6 @@ public class TestJobHistoryEventHandler {
|
||||||
tEntity.getEvents().get(0).getEventInfo().get("TASK_TYPE"));
|
tEntity.getEvents().get(0).getEventInfo().get("TASK_TYPE"));
|
||||||
Assert.assertEquals(TaskType.MAP.toString(),
|
Assert.assertEquals(TaskType.MAP.toString(),
|
||||||
tEntity.getEvents().get(1).getEventInfo().get("TASK_TYPE"));
|
tEntity.getEvents().get(1).getEventInfo().get("TASK_TYPE"));
|
||||||
} finally {
|
|
||||||
if (yarnCluster != null) {
|
|
||||||
yarnCluster.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,13 +165,11 @@ public class TestHadoopArchiveLogs {
|
||||||
|
|
||||||
@Test(timeout = 30000)
|
@Test(timeout = 30000)
|
||||||
public void testFilterAppsByAggregatedStatus() throws Exception {
|
public void testFilterAppsByAggregatedStatus() throws Exception {
|
||||||
MiniYARNCluster yarnCluster = null;
|
try (MiniYARNCluster yarnCluster =
|
||||||
try {
|
new MiniYARNCluster(TestHadoopArchiveLogs.class.getSimpleName(),
|
||||||
|
1, 1, 1, 1)) {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
yarnCluster =
|
|
||||||
new MiniYARNCluster(TestHadoopArchiveLogs.class.getSimpleName(), 1,
|
|
||||||
1, 1, 1);
|
|
||||||
yarnCluster.init(conf);
|
yarnCluster.init(conf);
|
||||||
yarnCluster.start();
|
yarnCluster.start();
|
||||||
conf = yarnCluster.getConfig();
|
conf = yarnCluster.getConfig();
|
||||||
|
@ -237,10 +235,6 @@ public class TestHadoopArchiveLogs {
|
||||||
Assert.assertTrue(hal.eligibleApplications.contains(app4));
|
Assert.assertTrue(hal.eligibleApplications.contains(app4));
|
||||||
Assert.assertTrue(hal.eligibleApplications.contains(app7));
|
Assert.assertTrue(hal.eligibleApplications.contains(app7));
|
||||||
Assert.assertTrue(hal.eligibleApplications.contains(app8));
|
Assert.assertTrue(hal.eligibleApplications.contains(app8));
|
||||||
} finally {
|
|
||||||
if (yarnCluster != null) {
|
|
||||||
yarnCluster.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,16 +52,14 @@ public class TestHadoopArchiveLogsRunner {
|
||||||
|
|
||||||
@Test(timeout = 50000)
|
@Test(timeout = 50000)
|
||||||
public void testHadoopArchiveLogs() throws Exception {
|
public void testHadoopArchiveLogs() throws Exception {
|
||||||
MiniYARNCluster yarnCluster = null;
|
|
||||||
MiniDFSCluster dfsCluster = null;
|
MiniDFSCluster dfsCluster = null;
|
||||||
FileSystem fs = null;
|
FileSystem fs = null;
|
||||||
try {
|
try (MiniYARNCluster yarnCluster =
|
||||||
|
new MiniYARNCluster(TestHadoopArchiveLogsRunner.class.getSimpleName(),
|
||||||
|
1, 2, 1, 1)) {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
|
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
|
||||||
yarnCluster =
|
|
||||||
new MiniYARNCluster(TestHadoopArchiveLogsRunner.class.getSimpleName(),
|
|
||||||
1, 2, 1, 1);
|
|
||||||
yarnCluster.init(conf);
|
yarnCluster.init(conf);
|
||||||
yarnCluster.start();
|
yarnCluster.start();
|
||||||
conf = yarnCluster.getConfig();
|
conf = yarnCluster.getConfig();
|
||||||
|
@ -133,9 +131,6 @@ public class TestHadoopArchiveLogsRunner {
|
||||||
harLogs[2].getOwner());
|
harLogs[2].getOwner());
|
||||||
Assert.assertEquals(0, fs.listStatus(workingDir).length);
|
Assert.assertEquals(0, fs.listStatus(workingDir).length);
|
||||||
} finally {
|
} finally {
|
||||||
if (yarnCluster != null) {
|
|
||||||
yarnCluster.stop();
|
|
||||||
}
|
|
||||||
if (fs != null) {
|
if (fs != null) {
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ public class TestHedgingRequestRMFailoverProxyProvider {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHedgingRequestProxyProvider() throws Exception {
|
public void testHedgingRequestProxyProvider() throws Exception {
|
||||||
final MiniYARNCluster cluster =
|
|
||||||
new MiniYARNCluster("testHedgingRequestProxyProvider", 5, 0, 1, 1);
|
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
|
|
||||||
conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
|
||||||
|
@ -49,6 +47,9 @@ public class TestHedgingRequestRMFailoverProxyProvider {
|
||||||
conf.setLong(YarnConfiguration.RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS,
|
conf.setLong(YarnConfiguration.RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS,
|
||||||
2000);
|
2000);
|
||||||
|
|
||||||
|
try (MiniYARNCluster cluster =
|
||||||
|
new MiniYARNCluster("testHedgingRequestProxyProvider", 5, 0, 1, 1)) {
|
||||||
|
|
||||||
HATestUtil.setRpcAddressForRM("rm1", 10000, conf);
|
HATestUtil.setRpcAddressForRM("rm1", 10000, conf);
|
||||||
HATestUtil.setRpcAddressForRM("rm2", 20000, conf);
|
HATestUtil.setRpcAddressForRM("rm2", 20000, conf);
|
||||||
HATestUtil.setRpcAddressForRM("rm3", 30000, conf);
|
HATestUtil.setRpcAddressForRM("rm3", 30000, conf);
|
||||||
|
@ -83,7 +84,7 @@ public class TestHedgingRequestRMFailoverProxyProvider {
|
||||||
|
|
||||||
validateActiveRM(client);
|
validateActiveRM(client);
|
||||||
|
|
||||||
cluster.stop();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateActiveRM(YarnClient client) throws IOException {
|
private void validateActiveRM(YarnClient client) throws IOException {
|
||||||
|
|
|
@ -60,11 +60,11 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 120000)
|
@Test(timeout = 120000)
|
||||||
public void testAMRMProxyE2E() throws Exception {
|
public void testAMRMProxyE2E() throws Exception {
|
||||||
MiniYARNCluster cluster = new MiniYARNCluster("testAMRMProxyE2E", 1, 1, 1);
|
|
||||||
YarnClient rmClient = null;
|
|
||||||
ApplicationMasterProtocol client;
|
ApplicationMasterProtocol client;
|
||||||
|
|
||||||
try {
|
try (MiniYARNCluster cluster = new MiniYARNCluster("testAMRMProxyE2E",
|
||||||
|
1, 1, 1);
|
||||||
|
YarnClient rmClient = YarnClient.createYarnClient()) {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
|
@ -75,7 +75,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
|
|
||||||
yarnConf.set(YarnConfiguration.RM_SCHEDULER_ADDRESS,
|
yarnConf.set(YarnConfiguration.RM_SCHEDULER_ADDRESS,
|
||||||
YarnConfiguration.DEFAULT_AMRM_PROXY_ADDRESS);
|
YarnConfiguration.DEFAULT_AMRM_PROXY_ADDRESS);
|
||||||
rmClient = YarnClient.createYarnClient();
|
|
||||||
rmClient.init(yarnConf);
|
rmClient.init(yarnConf);
|
||||||
rmClient.start();
|
rmClient.start();
|
||||||
|
|
||||||
|
@ -135,11 +134,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
Assert.assertNotEquals(RMAppState.FINISHED, rmApp.getState());
|
Assert.assertNotEquals(RMAppState.FINISHED, rmApp.getState());
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (rmClient != null) {
|
|
||||||
rmClient.stop();
|
|
||||||
}
|
|
||||||
cluster.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,12 +144,11 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 120000)
|
@Test(timeout = 120000)
|
||||||
public void testE2ETokenRenewal() throws Exception {
|
public void testE2ETokenRenewal() throws Exception {
|
||||||
MiniYARNCluster cluster =
|
|
||||||
new MiniYARNCluster("testE2ETokenRenewal", 1, 1, 1);
|
|
||||||
YarnClient rmClient = null;
|
|
||||||
ApplicationMasterProtocol client;
|
ApplicationMasterProtocol client;
|
||||||
|
|
||||||
try {
|
try (MiniYARNCluster cluster =
|
||||||
|
new MiniYARNCluster("testE2ETokenRenewal", 1, 1, 1);
|
||||||
|
YarnClient rmClient = YarnClient.createYarnClient()) {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
||||||
conf.setInt(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1500);
|
conf.setInt(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1500);
|
||||||
|
@ -170,7 +163,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
final Configuration yarnConf = cluster.getConfig();
|
final Configuration yarnConf = cluster.getConfig();
|
||||||
yarnConf.set(YarnConfiguration.RM_SCHEDULER_ADDRESS,
|
yarnConf.set(YarnConfiguration.RM_SCHEDULER_ADDRESS,
|
||||||
YarnConfiguration.DEFAULT_AMRM_PROXY_ADDRESS);
|
YarnConfiguration.DEFAULT_AMRM_PROXY_ADDRESS);
|
||||||
rmClient = YarnClient.createYarnClient();
|
|
||||||
rmClient.init(yarnConf);
|
rmClient.init(yarnConf);
|
||||||
rmClient.start();
|
rmClient.start();
|
||||||
|
|
||||||
|
@ -216,11 +208,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
client.finishApplicationMaster(FinishApplicationMasterRequest
|
client.finishApplicationMaster(FinishApplicationMasterRequest
|
||||||
.newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
|
.newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (rmClient != null) {
|
|
||||||
rmClient.stop();
|
|
||||||
}
|
|
||||||
cluster.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,11 +217,11 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 120000)
|
@Test(timeout = 120000)
|
||||||
public void testE2ETokenSwap() throws Exception {
|
public void testE2ETokenSwap() throws Exception {
|
||||||
MiniYARNCluster cluster = new MiniYARNCluster("testE2ETokenSwap", 1, 1, 1);
|
|
||||||
YarnClient rmClient = null;
|
|
||||||
ApplicationMasterProtocol client;
|
ApplicationMasterProtocol client;
|
||||||
|
|
||||||
try {
|
try (MiniYARNCluster cluster = new MiniYARNCluster("testE2ETokenSwap",
|
||||||
|
1, 1, 1);
|
||||||
|
YarnClient rmClient = YarnClient.createYarnClient()) {
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.AMRM_PROXY_ENABLED, true);
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
|
@ -242,7 +229,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
|
|
||||||
// the client will connect to the RM with the token provided by AMRMProxy
|
// the client will connect to the RM with the token provided by AMRMProxy
|
||||||
final Configuration yarnConf = cluster.getConfig();
|
final Configuration yarnConf = cluster.getConfig();
|
||||||
rmClient = YarnClient.createYarnClient();
|
|
||||||
rmClient.init(yarnConf);
|
rmClient.init(yarnConf);
|
||||||
rmClient.start();
|
rmClient.start();
|
||||||
|
|
||||||
|
@ -260,11 +246,6 @@ public class TestAMRMProxy extends BaseAMRMProxyE2ETest {
|
||||||
e.getMessage().startsWith("Invalid AMRMToken from appattempt_"));
|
e.getMessage().startsWith("Invalid AMRMToken from appattempt_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (rmClient != null) {
|
|
||||||
rmClient.stop();
|
|
||||||
}
|
|
||||||
cluster.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1721,15 +1721,13 @@ public class TestYarnCLI {
|
||||||
+ "ProportionalCapacityPreemptionPolicy");
|
+ "ProportionalCapacityPreemptionPolicy");
|
||||||
conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
||||||
conf.setBoolean(PREFIX + "root.a.a1.disable_preemption", true);
|
conf.setBoolean(PREFIX + "root.a.a1.disable_preemption", true);
|
||||||
MiniYARNCluster cluster =
|
|
||||||
new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
|
||||||
|
|
||||||
YarnClient yarnClient = null;
|
try (MiniYARNCluster cluster =
|
||||||
try {
|
new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
||||||
|
YarnClient yarnClient = YarnClient.createYarnClient()) {
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
cluster.start();
|
cluster.start();
|
||||||
final Configuration yarnConf = cluster.getConfig();
|
final Configuration yarnConf = cluster.getConfig();
|
||||||
yarnClient = YarnClient.createYarnClient();
|
|
||||||
yarnClient.init(yarnConf);
|
yarnClient.init(yarnConf);
|
||||||
yarnClient.start();
|
yarnClient.start();
|
||||||
|
|
||||||
|
@ -1742,13 +1740,6 @@ public class TestYarnCLI {
|
||||||
assertEquals(0, result);
|
assertEquals(0, result);
|
||||||
Assert.assertTrue(sysOutStream.toString()
|
Assert.assertTrue(sysOutStream.toString()
|
||||||
.contains("Preemption : disabled"));
|
.contains("Preemption : disabled"));
|
||||||
} finally {
|
|
||||||
// clean-up
|
|
||||||
if (yarnClient != null) {
|
|
||||||
yarnClient.stop();
|
|
||||||
}
|
|
||||||
cluster.stop();
|
|
||||||
cluster.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.HATestUtil;
|
import org.apache.hadoop.yarn.server.resourcemanager.HATestUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TestMiniYarnCluster {
|
public class TestMiniYarnCluster {
|
||||||
|
|
||||||
|
@ -41,10 +42,11 @@ public class TestMiniYarnCluster {
|
||||||
*/
|
*/
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
||||||
enableAHS = false;
|
enableAHS = false;
|
||||||
MiniYARNCluster cluster = null;
|
try (MiniYARNCluster cluster =
|
||||||
try {
|
new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
||||||
cluster = new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs,
|
||||||
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs, enableAHS);
|
enableAHS)) {
|
||||||
|
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
cluster.start();
|
cluster.start();
|
||||||
|
|
||||||
|
@ -52,11 +54,6 @@ public class TestMiniYarnCluster {
|
||||||
Assert.assertNull("Timeline Service should not have been started",
|
Assert.assertNull("Timeline Service should not have been started",
|
||||||
cluster.getApplicationHistoryServer());
|
cluster.getApplicationHistoryServer());
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
if(cluster != null) {
|
|
||||||
cluster.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Timeline service should start if TIMELINE_SERVICE_ENABLED == true
|
* Timeline service should start if TIMELINE_SERVICE_ENABLED == true
|
||||||
|
@ -64,10 +61,10 @@ public class TestMiniYarnCluster {
|
||||||
*/
|
*/
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||||
enableAHS = false;
|
enableAHS = false;
|
||||||
cluster = null;
|
try (MiniYARNCluster cluster =
|
||||||
try {
|
new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
||||||
cluster = new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs,
|
||||||
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs, enableAHS);
|
enableAHS)) {
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
|
|
||||||
// Verify that the timeline-service starts on ephemeral ports by default
|
// Verify that the timeline-service starts on ephemeral ports by default
|
||||||
|
@ -87,21 +84,16 @@ public class TestMiniYarnCluster {
|
||||||
Assert.assertNotNull("Timeline Service should have been started",
|
Assert.assertNotNull("Timeline Service should have been started",
|
||||||
cluster.getApplicationHistoryServer());
|
cluster.getApplicationHistoryServer());
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
if(cluster != null) {
|
|
||||||
cluster.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Timeline service should start if TIMELINE_SERVICE_ENABLED == false
|
* Timeline service should start if TIMELINE_SERVICE_ENABLED == false
|
||||||
* and enableAHS == true
|
* and enableAHS == true
|
||||||
*/
|
*/
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
||||||
enableAHS = true;
|
enableAHS = true;
|
||||||
cluster = null;
|
try (MiniYARNCluster cluster =
|
||||||
try {
|
new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
||||||
cluster = new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
|
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs,
|
||||||
numNodeManagers, numLocalDirs, numLogDirs, numLogDirs, enableAHS);
|
enableAHS)) {
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
cluster.start();
|
cluster.start();
|
||||||
|
|
||||||
|
@ -115,15 +107,10 @@ public class TestMiniYarnCluster {
|
||||||
Assert.assertNotNull("Timeline Service should have been started",
|
Assert.assertNotNull("Timeline Service should have been started",
|
||||||
cluster.getApplicationHistoryServer());
|
cluster.getApplicationHistoryServer());
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
if(cluster != null) {
|
|
||||||
cluster.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiRMConf() {
|
public void testMultiRMConf() throws IOException {
|
||||||
String RM1_NODE_ID = "rm1", RM2_NODE_ID = "rm2";
|
String RM1_NODE_ID = "rm1", RM2_NODE_ID = "rm2";
|
||||||
int RM1_PORT_BASE = 10000, RM2_PORT_BASE = 20000;
|
int RM1_PORT_BASE = 10000, RM2_PORT_BASE = 20000;
|
||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
|
@ -137,23 +124,28 @@ public class TestMiniYarnCluster {
|
||||||
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
|
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true);
|
conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_USE_RPC, true);
|
||||||
|
|
||||||
MiniYARNCluster cluster =
|
try (MiniYARNCluster cluster =
|
||||||
new MiniYARNCluster(TestMiniYarnCluster.class.getName(),
|
new MiniYARNCluster(TestMiniYarnCluster.class.getName(),
|
||||||
2, 0, 1, 1);
|
2, 0, 1, 1)) {
|
||||||
cluster.init(conf);
|
cluster.init(conf);
|
||||||
Configuration conf1 = cluster.getResourceManager(0).getConfig(),
|
Configuration conf1 = cluster.getResourceManager(0).getConfig(),
|
||||||
conf2 = cluster.getResourceManager(1).getConfig();
|
conf2 = cluster.getResourceManager(1).getConfig();
|
||||||
Assert.assertFalse(conf1 == conf2);
|
Assert.assertFalse(conf1 == conf2);
|
||||||
Assert.assertEquals("0.0.0.0:18032",
|
Assert.assertEquals("0.0.0.0:18032",
|
||||||
conf1.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM1_NODE_ID)));
|
conf1.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS,
|
||||||
|
RM1_NODE_ID)));
|
||||||
Assert.assertEquals("0.0.0.0:28032",
|
Assert.assertEquals("0.0.0.0:28032",
|
||||||
conf1.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM2_NODE_ID)));
|
conf1.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS,
|
||||||
|
RM2_NODE_ID)));
|
||||||
Assert.assertEquals("rm1", conf1.get(YarnConfiguration.RM_HA_ID));
|
Assert.assertEquals("rm1", conf1.get(YarnConfiguration.RM_HA_ID));
|
||||||
|
|
||||||
Assert.assertEquals("0.0.0.0:18032",
|
Assert.assertEquals("0.0.0.0:18032",
|
||||||
conf2.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM1_NODE_ID)));
|
conf2.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS,
|
||||||
|
RM1_NODE_ID)));
|
||||||
Assert.assertEquals("0.0.0.0:28032",
|
Assert.assertEquals("0.0.0.0:28032",
|
||||||
conf2.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM2_NODE_ID)));
|
conf2.get(HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS,
|
||||||
|
RM2_NODE_ID)));
|
||||||
Assert.assertEquals("rm2", conf2.get(YarnConfiguration.RM_HA_ID));
|
Assert.assertEquals("rm2", conf2.get(YarnConfiguration.RM_HA_ID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue