YARN-3412. RM tests should use MockRM where possible. (kasha)

This commit is contained in:
Karthik Kambatla 2015-03-31 09:14:15 -07:00
parent 859cab2f22
commit 79f7f2aabf
8 changed files with 15 additions and 18 deletions

View File

@ -119,6 +119,8 @@ Release 2.8.0 - UNRELEASED
YARN-3400. [JDK 8] Build Failure due to unreported exceptions in
RPCUtil (rkanter)
YARN-3412. RM tests should use MockRM where possible. (kasha)
Release 2.7.0 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -52,8 +52,7 @@ public class TestMoveApplication {
FifoSchedulerWithMove.class);
conf.set(YarnConfiguration.YARN_ADMIN_ACL, " ");
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
resourceManager = new ResourceManager();
resourceManager.init(conf);
resourceManager = new MockRM(conf);
resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey();
resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey();
resourceManager.start();

View File

@ -212,9 +212,8 @@ public class TestResourceManager {
public void testResourceManagerInitConfigValidation() throws Exception {
Configuration conf = new YarnConfiguration();
conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, -1);
resourceManager = new ResourceManager();
try {
resourceManager.init(conf);
resourceManager = new MockRM(conf);
fail("Exception is expected because the global max attempts" +
" is negative.");
} catch (YarnRuntimeException e) {
@ -229,9 +228,8 @@ public class TestResourceManager {
Configuration conf = new YarnConfiguration();
conf.setLong(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1000);
conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 1001);
resourceManager = new ResourceManager();;
try {
resourceManager.init(conf);
resourceManager = new MockRM(conf);
} catch (YarnRuntimeException e) {
// Exception is expected.
if (!e.getMessage().startsWith("Nodemanager expiry interval should be no"

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.monitor;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy;
import org.junit.Test;
@ -35,7 +36,7 @@ public class TestSchedulingMonitor {
conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
ProportionalCapacityPreemptionPolicy.class.getCanonicalName());
ResourceManager rm = new ResourceManager();
ResourceManager rm = new MockRM();
try {
rm.init(conf);
} catch (Exception e) {

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.recovery;
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@ -224,8 +225,7 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
Configuration conf1 = createHARMConf("rm1,rm2", "rm1", 1234);
conf1.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
ResourceManager rm1 = new ResourceManager();
rm1.init(conf1);
ResourceManager rm1 = new MockRM(conf1);
rm1.start();
rm1.getRMContext().getRMAdminService().transitionToActive(req);
assertEquals("RM with ZKStore didn't start",
@ -236,8 +236,7 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
Configuration conf2 = createHARMConf("rm1,rm2", "rm2", 5678);
conf2.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
ResourceManager rm2 = new ResourceManager();
rm2.init(conf2);
ResourceManager rm2 = new MockRM(conf2);
rm2.start();
rm2.getRMContext().getRMAdminService().transitionToActive(req);
assertEquals("RM with ZKStore didn't start",

View File

@ -117,8 +117,7 @@ public class TestFairScheduler extends FairSchedulerTestBase {
public void setUp() throws IOException {
scheduler = new FairScheduler();
conf = createConfiguration();
resourceManager = new ResourceManager();
resourceManager.init(conf);
resourceManager = new MockRM(conf);
// TODO: This test should really be using MockRM. For now starting stuff
// that is needed at a bare minimum.

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
import org.junit.Assert;
import org.apache.hadoop.conf.Configuration;
@ -48,8 +49,7 @@ public class TestFairSchedulerEventLog {
// All tests assume only one assignment per node update
conf.set(FairSchedulerConfiguration.ASSIGN_MULTIPLE, "false");
resourceManager = new ResourceManager();
resourceManager.init(conf);
resourceManager = new MockRM(conf);
((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start();
scheduler.init(conf);
scheduler.start();

View File

@ -116,11 +116,10 @@ public class TestFifoScheduler {
@Before
public void setUp() throws Exception {
resourceManager = new ResourceManager();
conf = new Configuration();
conf.setClass(YarnConfiguration.RM_SCHEDULER,
conf.setClass(YarnConfiguration.RM_SCHEDULER,
FifoScheduler.class, ResourceScheduler.class);
resourceManager.init(conf);
resourceManager = new MockRM(conf);
}
@After