YARN-8344. Missing nm.stop() in TestNodeManagerResync to fix testKillContainersOnResync. Contributed by Giovanni Matteo Fumarola.
This commit is contained in:
parent
cddbbe5f69
commit
e99e5bf104
@ -150,7 +150,6 @@ public void testPreserveContainersOnResyncKeepingContainers() throws
|
||||
testContainerPreservationOnResyncImpl(nm, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void testContainerPreservationOnResyncImpl(TestNodeManager1 nm,
|
||||
boolean isWorkPreservingRestartEnabled)
|
||||
throws IOException, YarnException, InterruptedException {
|
||||
@ -186,12 +185,13 @@ protected void testContainerPreservationOnResyncImpl(TestNodeManager1 nm,
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("resource")
|
||||
@Test(timeout=10000)
|
||||
public void testNMshutdownWhenResyncThrowException() throws IOException,
|
||||
InterruptedException, YarnException {
|
||||
NodeManager nm = new TestNodeManager3();
|
||||
YarnConfiguration conf = createNMConfig();
|
||||
try {
|
||||
nm.init(conf);
|
||||
nm.start();
|
||||
Assert.assertEquals(1, ((TestNodeManager3) nm).getNMRegistrationCount());
|
||||
@ -199,7 +199,7 @@ public void testNMshutdownWhenResyncThrowException() throws IOException,
|
||||
.handle(new NodeManagerEvent(NodeManagerEventType.RESYNC));
|
||||
|
||||
synchronized (isNMShutdownCalled) {
|
||||
while (isNMShutdownCalled.get() == false) {
|
||||
while (!isNMShutdownCalled.get()) {
|
||||
try {
|
||||
isNMShutdownCalled.wait();
|
||||
} catch (InterruptedException e) {
|
||||
@ -207,11 +207,13 @@ public void testNMshutdownWhenResyncThrowException() throws IOException,
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue("NM shutdown not called.",isNMShutdownCalled.get());
|
||||
Assert.assertTrue("NM shutdown not called.", isNMShutdownCalled.get());
|
||||
} finally {
|
||||
nm.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("resource")
|
||||
@Test(timeout=60000)
|
||||
public void testContainerResourceIncreaseIsSynchronizedWithRMResync()
|
||||
throws IOException, InterruptedException, YarnException {
|
||||
@ -219,28 +221,32 @@ public void testContainerResourceIncreaseIsSynchronizedWithRMResync()
|
||||
YarnConfiguration conf = createNMConfig();
|
||||
conf.setBoolean(
|
||||
YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true);
|
||||
try {
|
||||
nm.init(conf);
|
||||
nm.start();
|
||||
// Start a container and make sure it is in RUNNING state
|
||||
((TestNodeManager4)nm).startContainer();
|
||||
((TestNodeManager4) nm).startContainer();
|
||||
// Simulate a container resource increase in a separate thread
|
||||
((TestNodeManager4)nm).updateContainerResource();
|
||||
((TestNodeManager4) nm).updateContainerResource();
|
||||
// Simulate RM restart by sending a RESYNC event
|
||||
LOG.info("Sending out RESYNC event");
|
||||
nm.getNMDispatcher().getEventHandler().handle(
|
||||
new NodeManagerEvent(NodeManagerEventType.RESYNC));
|
||||
nm.getNMDispatcher().getEventHandler()
|
||||
.handle(new NodeManagerEvent(NodeManagerEventType.RESYNC));
|
||||
try {
|
||||
syncBarrier.await();
|
||||
} catch (BrokenBarrierException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertFalse(assertionFailedInThread.get());
|
||||
} finally {
|
||||
nm.stop();
|
||||
}
|
||||
}
|
||||
|
||||
// This is to test when NM gets the resync response from last heart beat, it
|
||||
// should be able to send the already-sent-via-last-heart-beat container
|
||||
// statuses again when it re-register with RM.
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testNMSentContainerStatusOnResync() throws Exception {
|
||||
final ContainerStatus testCompleteContainer =
|
||||
@ -323,6 +329,7 @@ public NodeHeartbeatResponse nodeHeartbeat(
|
||||
}
|
||||
};
|
||||
YarnConfiguration conf = createNMConfig();
|
||||
try {
|
||||
nm.init(conf);
|
||||
nm.start();
|
||||
|
||||
@ -331,8 +338,10 @@ public NodeHeartbeatResponse nodeHeartbeat(
|
||||
} catch (BrokenBarrierException e) {
|
||||
}
|
||||
Assert.assertFalse(assertionFailedInThread.get());
|
||||
} finally {
|
||||
nm.stop();
|
||||
}
|
||||
}
|
||||
|
||||
// This can be used as a common base class for testing NM resync behavior.
|
||||
class TestNodeStatusUpdaterResync extends MockNodeStatusUpdater {
|
||||
|
Loading…
Reference in New Issue
Block a user