From 9cf436aef51fb14ebd4fe2952a3db2dfa35e8fa9 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Sun, 19 May 2013 21:15:11 +0000 Subject: [PATCH] MAPREDUCE-5257. Fix issues in TestContainerLauncherImpl after YARN-617. Contributed by Omkar Vinit Joshi. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1484349 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../launcher/TestContainerLauncherImpl.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 337144af92f..8e9435e11d7 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -429,6 +429,9 @@ Release 2.0.5-beta - UNRELEASED MAPREDUCE-4927. Historyserver 500 error due to NPE when accessing specific counters page for failed job. (Ashwin Shankar via jlowe) + MAPREDUCE-5257. Fix issues in TestContainerLauncherImpl after YARN-617. + (Omkar Vinit Joshi via vinodkv) + Release 2.0.4-alpha - 2013-04-25 INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java index 0fef82632ab..bfbc70a39c0 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java @@ -55,12 +55,14 @@ import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerToken; import org.apache.hadoop.yarn.event.Event; import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.exceptions.YarnRemoteException; import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; import org.apache.hadoop.yarn.ipc.YarnRPC; +import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; import org.apache.hadoop.yarn.util.BuilderUtils; import org.junit.Before; import org.junit.Test; @@ -172,6 +174,8 @@ public class TestContainerLauncherImpl { when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId); when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress); when(mockCM.startContainer(any(StartContainerRequest.class))).thenReturn(startResp); + when(mockLaunchEvent.getContainerToken()).thenReturn( + createNewContainerToken(contId, cmAddress)); ut.handle(mockLaunchEvent); ut.waitForPoolToIdle(); @@ -250,6 +254,8 @@ public class TestContainerLauncherImpl { when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId); when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress); when(mockCM.startContainer(any(StartContainerRequest.class))).thenReturn(startResp); + when(mockLaunchEvent.getContainerToken()).thenReturn( + createNewContainerToken(contId, cmAddress)); ut.handle(mockLaunchEvent); ut.waitForPoolToIdle(); @@ -299,6 +305,8 @@ public class TestContainerLauncherImpl { when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId); when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress); when(mockCM.startContainer(any(StartContainerRequest.class))).thenReturn(startResp); + when(mockLaunchEvent.getContainerToken()).thenReturn( + createNewContainerToken(contId, cmAddress)); ut.handle(mockLaunchEvent); ut.waitForPoolToIdle(); @@ -356,6 +364,8 @@ public class TestContainerLauncherImpl { .thenReturn(contId); when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId); when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress); + when(mockLaunchEvent.getContainerToken()).thenReturn( + createNewContainerToken(contId, cmAddress)); ut.handle(mockLaunchEvent); startLaunchBarrier.await(); @@ -394,6 +404,15 @@ public class TestContainerLauncherImpl { } } + private ContainerToken createNewContainerToken(ContainerId contId, + String containerManagerAddr) { + return BuilderUtils.newContainerToken(BuilderUtils.newNodeId("127.0.0.1", + 1234), "password".getBytes(), new ContainerTokenIdentifier( + contId, containerManagerAddr, "user", + BuilderUtils.newResource(1024, 1), + System.currentTimeMillis() + 10000L, 123)); + } + private static class ContainerManagerForTest implements ContainerManager { private CyclicBarrier startLaunchBarrier;