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

(cherry picked from commit bbe80cdc7b)
This commit is contained in:
Jason Lowe 2014-10-13 15:12:05 +00:00
parent 752f724d52
commit 5dbbabe85f
2 changed files with 23 additions and 8 deletions

View File

@ -189,6 +189,9 @@ Release 2.6.0 - UNRELEASED
MAPREDUCE-6123. TestCombineFileInputFormat incorrectly starts 2
MiniDFSCluster instances. (cnauroth)
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.never;
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 class TestContainerLauncherImpl {
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 class TestContainerLauncherImpl {
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 class TestContainerLauncherImpl {
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 class TestContainerLauncherImpl {
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 class TestContainerLauncherImpl {
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 @@ public class TestContainerLauncherImpl {
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 class TestContainerLauncherImpl {
GetContainerStatusesRequest request) throws IOException {
return null;
}
@Override
public void close() throws IOException {
}
}
@SuppressWarnings("serial")