Skip to content

Commit 8ea40d9

Browse files
committed
test-this-patch-over-trunk
Change-Id: I3171a295aae81eae001661a4851ddf839a1db05a
1 parent 2406530 commit 8ea40d9

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void setUp() throws IOException {
283283
setupDispatcher(rmContext, conf);
284284
}
285285

286-
private static PlacementManager createMockPlacementManager(
286+
public static PlacementManager createMockPlacementManager(
287287
String userRegex, String placementQueue, String placementParentQueue
288288
) throws YarnException {
289289
PlacementManager placementMgr = mock(PlacementManager.class);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestWorkPreservingRMRestart.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,94 @@ public void testUAMRecoveryOnRMWorkPreservingRestart() throws Exception {
16511651
assertUnmanagedAMQueueMetrics(qm2, 1, 0, 0, 1);
16521652
}
16531653

1654+
// Test behavior of an app if two same name leaf queue with different queuePath
1655+
// during work preserving rm restart with %specified mapping Placement Rule.
1656+
// Test case does following:
1657+
//1. Submit an apps to queue root.p1.test.
1658+
//2. During the applications is running, restart the rm and
1659+
// check whether the app submitted to the queue it was submitted initially.
1660+
//3. Verify that application running successfully.
1661+
@Test(timeout = 60000)
1662+
public void testQueueRecoveryOnRMWorkPreservingRestart() throws Exception {
1663+
CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);
1664+
1665+
csConf.setQueues(
1666+
CapacitySchedulerConfiguration.ROOT, new String[] { "default", "joe", "john" });
1667+
csConf.setCapacity(
1668+
CapacitySchedulerConfiguration.ROOT + "." + "joe", 25);
1669+
csConf.setCapacity(
1670+
CapacitySchedulerConfiguration.ROOT + "." + "john", 25);
1671+
csConf.setCapacity(
1672+
CapacitySchedulerConfiguration.ROOT + "." + "default", 50);
1673+
1674+
final String q1 = CapacitySchedulerConfiguration.ROOT + "." + "joe";
1675+
final String q2 = CapacitySchedulerConfiguration.ROOT + "." + "john";
1676+
csConf.setQueues(q1, new String[] {"test"});
1677+
csConf.setQueues(q2, new String[] {"test"});
1678+
csConf.setCapacity(
1679+
CapacitySchedulerConfiguration.ROOT + "." + "joe.test", 100);
1680+
csConf.setCapacity(
1681+
CapacitySchedulerConfiguration.ROOT + "." + "john.test", 100);
1682+
1683+
csConf.set(CapacitySchedulerConfiguration.MAPPING_RULE_JSON,
1684+
"{\"rules\" : [{\"type\": \"user\", \"policy\" : \"specified\", " +
1685+
"\"fallbackResult\" : \"skip\", \"matches\" : \"*\"}]}");
1686+
1687+
// start RM
1688+
rm1 = new MockRM(csConf);
1689+
rm1.start();
1690+
MockMemoryRMStateStore memStore =
1691+
(MockMemoryRMStateStore) rm1.getRMStateStore();
1692+
MockNM nm1 =
1693+
new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
1694+
nm1.registerNode();
1695+
1696+
RMContext newMockRMContext = rm1.getRMContext();
1697+
newMockRMContext.setQueuePlacementManager(TestAppManager.createMockPlacementManager(
1698+
"user1|user2", "test", "root.joe"));
1699+
1700+
MockRMAppSubmissionData data =
1701+
MockRMAppSubmissionData.Builder.createWithMemory(1024, rm1)
1702+
.withAppName("app")
1703+
.withQueue("root.joe.test")
1704+
.withUser("user1")
1705+
.withAcls(null)
1706+
.build();
1707+
1708+
RMApp app = MockRMAppSubmitter.submit(rm1, data);
1709+
MockAM am = MockRM.launchAndRegisterAM(app, rm1, nm1);
1710+
rm1.waitForState(app.getApplicationId(), RMAppState.RUNNING);
1711+
1712+
MockRM rm2 = new MockRM(csConf, memStore) {
1713+
@Override
1714+
protected RMAppManager createRMAppManager() {
1715+
return new RMAppManager(this.rmContext, this.scheduler,
1716+
this.masterService, this.applicationACLsManager, conf) {
1717+
@Override
1718+
ApplicationPlacementContext placeApplication(
1719+
PlacementManager placementManager,
1720+
ApplicationSubmissionContext context, String user,
1721+
boolean isRecovery) throws YarnException {
1722+
return super
1723+
.placeApplication(newMockRMContext.getQueuePlacementManager(), context, user, isRecovery);
1724+
}
1725+
};
1726+
}
1727+
};
1728+
1729+
nm1.setResourceTrackerService(rm2.getResourceTrackerService());
1730+
rm2.start();
1731+
RMApp recoveredApp0 =
1732+
rm2.getRMContext().getRMApps().get(app.getApplicationId());
1733+
1734+
rm2.waitForState(recoveredApp0.getApplicationId(), RMAppState.ACCEPTED);
1735+
am.setAMRMProtocol(rm2.getApplicationMasterService(), rm2.getRMContext());
1736+
am.registerAppAttempt(true);
1737+
rm2.waitForState(recoveredApp0.getApplicationId(), RMAppState.RUNNING);
1738+
1739+
Assert.assertEquals("root.joe.test", recoveredApp0.getQueue());
1740+
}
1741+
16541742
private void assertUnmanagedAMQueueMetrics(QueueMetrics qm, int appsSubmitted,
16551743
int appsPending, int appsRunning, int appsCompleted) {
16561744
Assert.assertEquals(appsSubmitted, qm.getUnmanagedAppsSubmitted());

0 commit comments

Comments
 (0)