MAPREDUCE-6125. TestContainerLauncherImpl sometimes fails. Contributed by Mit Desai

This commit is contained in:
Jason Lowe 2014-10-13 15:08:23 +00:00
parent e8a31f2e1c
commit bbe80cdc7b
2 changed files with 23 additions and 8 deletions

View File

@ -423,6 +423,9 @@ Release 2.6.0 - UNRELEASED
MAPREDUCE-5875. Make Counter limits consistent across JobClient,
MRAppMaster, and YarnChild. (Gera Shegalov via kasha)
MAPREDUCE-6125. TestContainerLauncherImpl sometimes fails (Mit Desai via
jlowe)
Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES

View File

@ -24,6 +24,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashMap;
@ -83,6 +84,13 @@ public void setup() throws IOException {
serviceResponse.put(ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID,
ShuffleHandler.serializeMetaData(80));
}
// tests here mock ContainerManagementProtocol which does not have close
// method. creating an interface that implements ContainerManagementProtocol
// and Closeable so the tests does not fail with NoSuchMethodException
private static interface ContainerManagementProtocolClient extends
ContainerManagementProtocol, Closeable {
}
private static class ContainerLauncherImplUnderTest extends
ContainerLauncherImpl {
@ -152,8 +160,8 @@ public void testHandle() throws Exception {
EventHandler mockEventHandler = mock(EventHandler.class);
when(mockContext.getEventHandler()).thenReturn(mockEventHandler);
String cmAddress = "127.0.0.1:8000";
ContainerManagementProtocol mockCM =
mock(ContainerManagementProtocol.class);
ContainerManagementProtocolClient mockCM =
mock(ContainerManagementProtocolClient.class);
ContainerLauncherImplUnderTest ut =
new ContainerLauncherImplUnderTest(mockContext, mockCM);
@ -213,8 +221,8 @@ public void testOutOfOrder() throws Exception {
EventHandler mockEventHandler = mock(EventHandler.class);
when(mockContext.getEventHandler()).thenReturn(mockEventHandler);
ContainerManagementProtocol mockCM =
mock(ContainerManagementProtocol.class);
ContainerManagementProtocolClient mockCM =
mock(ContainerManagementProtocolClient.class);
ContainerLauncherImplUnderTest ut =
new ContainerLauncherImplUnderTest(mockContext, mockCM);
@ -275,8 +283,8 @@ public void testMyShutdown() throws Exception {
EventHandler mockEventHandler = mock(EventHandler.class);
when(mockContext.getEventHandler()).thenReturn(mockEventHandler);
ContainerManagementProtocol mockCM =
mock(ContainerManagementProtocol.class);
ContainerManagementProtocolClient mockCM =
mock(ContainerManagementProtocolClient.class);
ContainerLauncherImplUnderTest ut =
new ContainerLauncherImplUnderTest(mockContext, mockCM);
@ -330,7 +338,7 @@ public void testContainerCleaned() throws Exception {
EventHandler mockEventHandler = mock(EventHandler.class);
when(mockContext.getEventHandler()).thenReturn(mockEventHandler);
ContainerManagementProtocol mockCM =
ContainerManagementProtocolClient mockCM =
new ContainerManagerForTest(startLaunchBarrier, completeLaunchBarrier);
ContainerLauncherImplUnderTest ut =
new ContainerLauncherImplUnderTest(mockContext, mockCM);
@ -406,7 +414,7 @@ private Token createNewContainerToken(ContainerId contId,
currentTime + 10000L, 123, currentTime, Priority.newInstance(0), 0));
}
private static class ContainerManagerForTest implements ContainerManagementProtocol {
private static class ContainerManagerForTest implements ContainerManagementProtocolClient {
private CyclicBarrier startLaunchBarrier;
private CyclicBarrier completeLaunchBarrier;
@ -444,6 +452,10 @@ public GetContainerStatusesResponse getContainerStatuses(
GetContainerStatusesRequest request) throws IOException {
return null;
}
@Override
public void close() throws IOException {
}
}
@SuppressWarnings("serial")