|
@@ -18,13 +18,10 @@
|
|
|
|
|
|
package org.apache.hadoop.mapred;
|
|
|
|
|
|
-import static org.junit.Assert.*;
|
|
|
-
|
|
|
-import java.net.InetSocketAddress;
|
|
|
-
|
|
|
import org.apache.hadoop.mapreduce.MRConfig;
|
|
|
-import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
public class TestMaster {
|
|
@@ -33,13 +30,6 @@ public class TestMaster {
|
|
|
public void testGetMasterAddress() {
|
|
|
YarnConfiguration conf = new YarnConfiguration();
|
|
|
|
|
|
- // Default is yarn framework
|
|
|
- String masterHostname = Master.getMasterAddress(conf).getHostName();
|
|
|
-
|
|
|
- // no address set so should default to default rm address
|
|
|
- InetSocketAddress rmAddr = NetUtils.createSocketAddr(YarnConfiguration.DEFAULT_RM_ADDRESS);
|
|
|
- assertEquals(masterHostname, rmAddr.getHostName());
|
|
|
-
|
|
|
// Trying invalid master address for classic
|
|
|
conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.CLASSIC_FRAMEWORK_NAME);
|
|
|
conf.set(MRConfig.MASTER_ADDRESS, "local:invalid");
|
|
@@ -55,47 +45,7 @@ public class TestMaster {
|
|
|
|
|
|
// Change master address to a valid value
|
|
|
conf.set(MRConfig.MASTER_ADDRESS, "bar.com:8042");
|
|
|
- masterHostname = Master.getMasterAddress(conf).getHostName();
|
|
|
+ String masterHostname = Master.getMasterAddress(conf);
|
|
|
assertEquals(masterHostname, "bar.com");
|
|
|
-
|
|
|
- // change framework to yarn
|
|
|
- conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
|
|
|
- conf.set(YarnConfiguration.RM_ADDRESS, "foo1.com:8192");
|
|
|
- masterHostname = Master.getMasterAddress(conf).getHostName();
|
|
|
- assertEquals(masterHostname, "foo1.com");
|
|
|
-
|
|
|
- // change framework to yarn and enable HA
|
|
|
- conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
|
|
|
- conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
|
|
|
- conf.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
|
|
|
- conf.set(YarnConfiguration.RM_ADDRESS + ".rm1", "rm1.com:8192");
|
|
|
- conf.set(YarnConfiguration.RM_ADDRESS + ".rm2", "rm2.com:8192");
|
|
|
- masterHostname = Master.getMasterAddress(conf).getHostName();
|
|
|
- // If RM_HA_ID is not configured, the first one in RM_HA_IDS will be used.
|
|
|
- assertEquals(masterHostname, "rm1.com");
|
|
|
- conf.set(YarnConfiguration.RM_HA_ID, "rm2");
|
|
|
- masterHostname = Master.getMasterAddress(conf).getHostName();
|
|
|
- // If RM_HA_ID is configured, use the given RM_HA_ID.
|
|
|
- assertEquals(masterHostname, "rm2.com");
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testGetMasterUser() {
|
|
|
- YarnConfiguration conf = new YarnConfiguration();
|
|
|
- conf.set(MRConfig.MASTER_USER_NAME, "foo");
|
|
|
- conf.set(YarnConfiguration.RM_PRINCIPAL, "bar");
|
|
|
-
|
|
|
- // default is yarn framework
|
|
|
- assertEquals(Master.getMasterUserName(conf), "bar");
|
|
|
-
|
|
|
- // set framework name to classic
|
|
|
- conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.CLASSIC_FRAMEWORK_NAME);
|
|
|
- assertEquals(Master.getMasterUserName(conf), "foo");
|
|
|
-
|
|
|
- // change framework to yarn
|
|
|
- conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
|
|
|
- assertEquals(Master.getMasterUserName(conf), "bar");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|