YARN-8344. Missing nm.stop() in TestNodeManagerResync to fix testKillContainersOnResync. Contributed by Giovanni Matteo Fumarola.

(cherry picked from commit e99e5bf104)
This commit is contained in:
Inigo Goiri 2018-05-23 14:15:26 -07:00
parent f57e91a348
commit 61b5b2f4f7
1 changed files with 47 additions and 38 deletions

View File

@ -150,7 +150,6 @@ public class TestNodeManagerResync {
testContainerPreservationOnResyncImpl(nm, true); testContainerPreservationOnResyncImpl(nm, true);
} }
@SuppressWarnings("unchecked")
protected void testContainerPreservationOnResyncImpl(TestNodeManager1 nm, protected void testContainerPreservationOnResyncImpl(TestNodeManager1 nm,
boolean isWorkPreservingRestartEnabled) boolean isWorkPreservingRestartEnabled)
throws IOException, YarnException, InterruptedException { throws IOException, YarnException, InterruptedException {
@ -186,12 +185,13 @@ public class TestNodeManagerResync {
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("resource")
@Test(timeout=10000) @Test(timeout=10000)
public void testNMshutdownWhenResyncThrowException() throws IOException, public void testNMshutdownWhenResyncThrowException() throws IOException,
InterruptedException, YarnException { InterruptedException, YarnException {
NodeManager nm = new TestNodeManager3(); NodeManager nm = new TestNodeManager3();
YarnConfiguration conf = createNMConfig(); YarnConfiguration conf = createNMConfig();
try {
nm.init(conf); nm.init(conf);
nm.start(); nm.start();
Assert.assertEquals(1, ((TestNodeManager3) nm).getNMRegistrationCount()); Assert.assertEquals(1, ((TestNodeManager3) nm).getNMRegistrationCount());
@ -199,7 +199,7 @@ public class TestNodeManagerResync {
.handle(new NodeManagerEvent(NodeManagerEventType.RESYNC)); .handle(new NodeManagerEvent(NodeManagerEventType.RESYNC));
synchronized (isNMShutdownCalled) { synchronized (isNMShutdownCalled) {
while (isNMShutdownCalled.get() == false) { while (!isNMShutdownCalled.get()) {
try { try {
isNMShutdownCalled.wait(); isNMShutdownCalled.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -208,10 +208,12 @@ public class TestNodeManagerResync {
} }
Assert.assertTrue("NM shutdown not called.", isNMShutdownCalled.get()); Assert.assertTrue("NM shutdown not called.", isNMShutdownCalled.get());
} finally {
nm.stop(); nm.stop();
} }
}
@SuppressWarnings("unchecked") @SuppressWarnings("resource")
@Test(timeout=60000) @Test(timeout=60000)
public void testContainerResourceIncreaseIsSynchronizedWithRMResync() public void testContainerResourceIncreaseIsSynchronizedWithRMResync()
throws IOException, InterruptedException, YarnException { throws IOException, InterruptedException, YarnException {
@ -219,6 +221,7 @@ public class TestNodeManagerResync {
YarnConfiguration conf = createNMConfig(); YarnConfiguration conf = createNMConfig();
conf.setBoolean( conf.setBoolean(
YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true); YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true);
try {
nm.init(conf); nm.init(conf);
nm.start(); nm.start();
// Start a container and make sure it is in RUNNING state // Start a container and make sure it is in RUNNING state
@ -227,20 +230,23 @@ public class TestNodeManagerResync {
((TestNodeManager4) nm).updateContainerResource(); ((TestNodeManager4) nm).updateContainerResource();
// Simulate RM restart by sending a RESYNC event // Simulate RM restart by sending a RESYNC event
LOG.info("Sending out RESYNC event"); LOG.info("Sending out RESYNC event");
nm.getNMDispatcher().getEventHandler().handle( nm.getNMDispatcher().getEventHandler()
new NodeManagerEvent(NodeManagerEventType.RESYNC)); .handle(new NodeManagerEvent(NodeManagerEventType.RESYNC));
try { try {
syncBarrier.await(); syncBarrier.await();
} catch (BrokenBarrierException e) { } catch (BrokenBarrierException e) {
e.printStackTrace(); e.printStackTrace();
} }
Assert.assertFalse(assertionFailedInThread.get()); Assert.assertFalse(assertionFailedInThread.get());
} finally {
nm.stop(); nm.stop();
} }
}
// This is to test when NM gets the resync response from last heart beat, it // 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 // should be able to send the already-sent-via-last-heart-beat container
// statuses again when it re-register with RM. // statuses again when it re-register with RM.
@SuppressWarnings("resource")
@Test @Test
public void testNMSentContainerStatusOnResync() throws Exception { public void testNMSentContainerStatusOnResync() throws Exception {
final ContainerStatus testCompleteContainer = final ContainerStatus testCompleteContainer =
@ -323,6 +329,7 @@ public class TestNodeManagerResync {
} }
}; };
YarnConfiguration conf = createNMConfig(); YarnConfiguration conf = createNMConfig();
try {
nm.init(conf); nm.init(conf);
nm.start(); nm.start();
@ -331,8 +338,10 @@ public class TestNodeManagerResync {
} catch (BrokenBarrierException e) { } catch (BrokenBarrierException e) {
} }
Assert.assertFalse(assertionFailedInThread.get()); Assert.assertFalse(assertionFailedInThread.get());
} finally {
nm.stop(); nm.stop();
} }
}
// This can be used as a common base class for testing NM resync behavior. // This can be used as a common base class for testing NM resync behavior.
class TestNodeStatusUpdaterResync extends MockNodeStatusUpdater { class TestNodeStatusUpdaterResync extends MockNodeStatusUpdater {