From 78c6b462412bbadad4a1a13ed4c597927b0cf188 Mon Sep 17 00:00:00 2001 From: Gera Shegalov Date: Fri, 24 Apr 2015 09:21:44 -0700 Subject: [PATCH] MAPREDUCE-6333. TestEvents,TestAMWebServicesTasks,TestAppController are broken due to MAPREDUCE-6297. (Siqi Li via gera) --- hadoop-mapreduce-project/CHANGES.txt | 3 ++ .../mapreduce/jobhistory/TestEvents.java | 29 ++++++++++--------- .../v2/app/webapp/TestAMWebServicesTasks.java | 27 +++++++++++------ .../v2/app/webapp/TestAppController.java | 9 +++--- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 5b2691096c2..397f94a4d1b 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -343,6 +343,9 @@ Release 2.8.0 - UNRELEASED MAPREDUCE-6330. Fix typo in Task Attempt API's URL in documentations. (Ryu Kobayashi via ozawa) + MAPREDUCE-6333. TestEvents,TestAMWebServicesTasks,TestAppController are + broken due to MAPREDUCE-6297. (Siqi Li via gera) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestEvents.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestEvents.java index 00be4b8b53a..bb9b56b18d1 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestEvents.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestEvents.java @@ -39,6 +39,7 @@ import org.junit.Test; public class TestEvents { + private static final String taskId = "task_1_2_r_3"; /** * test a getters of TaskAttemptFinishedEvent and TaskAttemptFinished * @@ -131,7 +132,7 @@ public class TestEvents { e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); @@ -141,42 +142,42 @@ public class TestEvents { e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptStarted) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptFinished) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptStarted) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptFinished) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); e = reader.getNextEvent(); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); - assertEquals("task_1_2_r03_4", + assertEquals(taskId, ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); reader.close(); @@ -234,7 +235,7 @@ public class TestEvents { datum.hostname = "hostname"; datum.rackname = "rackname"; datum.physMemKbytes = Arrays.asList(1000, 2000, 3000); - datum.taskid = "task_1_2_r03_4"; + datum.taskid = taskId; datum.port = 1000; datum.taskType = "REDUCE"; datum.status = "STATUS"; @@ -260,7 +261,7 @@ public class TestEvents { datum.hostname = "hostname"; datum.rackname = "rackName"; datum.state = "state"; - datum.taskid = "task_1_2_r03_4"; + datum.taskid = taskId; datum.taskStatus = "taskStatus"; datum.taskType = "REDUCE"; result.setDatum(datum); @@ -278,7 +279,7 @@ public class TestEvents { datum.locality = "locality"; datum.shufflePort = 10001; datum.startTime = 1; - datum.taskid = "task_1_2_r03_4"; + datum.taskid = taskId; datum.taskType = "taskType"; datum.trackerName = "trackerName"; result.setDatum(datum); @@ -308,7 +309,7 @@ public class TestEvents { datum.hostname = "hostname"; datum.rackname = "rackname"; datum.state = "state"; - datum.taskid = "task_1_2_r03_4"; + datum.taskid = taskId; datum.taskStatus = "taskStatus"; datum.taskType = "REDUCE"; result.setDatum(datum); @@ -325,7 +326,7 @@ public class TestEvents { datum.locality = "locality"; datum.shufflePort = 10001; datum.startTime = 1; - datum.taskid = "task_1_2_r03_4"; + datum.taskid = taskId; datum.taskType = "taskType"; datum.trackerName = "trackerName"; result.setDatum(datum); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java index 8bf1bb7b752..15ef5ac2c8d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java @@ -31,6 +31,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.mapreduce.TaskID; import org.apache.hadoop.mapreduce.v2.api.records.JobId; import org.apache.hadoop.mapreduce.v2.api.records.TaskId; import org.apache.hadoop.mapreduce.v2.api.records.TaskReport; @@ -355,9 +356,11 @@ public class TestAMWebServicesTasks extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - WebServicesTestUtils.checkStringMatch("exception message", + WebServicesTestUtils.checkStringEqual("exception message", "java.lang.Exception: TaskId string : " - + "bogustaskid is not properly formed", message); + + "bogustaskid is not properly formed" + + "\nReason: java.util.regex.Matcher[pattern=" + + TaskID.TASK_ID_REGEX + " region=0,11 lastmatch=]", message); WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type); WebServicesTestUtils.checkStringMatch("exception classname", @@ -419,9 +422,11 @@ public class TestAMWebServicesTasks extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - WebServicesTestUtils.checkStringMatch("exception message", - "java.lang.Exception: Bad TaskType identifier. TaskId string : " - + "task_0_0000_d_000000 is not properly formed.", message); + WebServicesTestUtils.checkStringEqual("exception message", + "java.lang.Exception: TaskId string : " + + "task_0_0000_d_000000 is not properly formed" + + "\nReason: java.util.regex.Matcher[pattern=" + + TaskID.TASK_ID_REGEX + " region=0,20 lastmatch=]", message); WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type); WebServicesTestUtils.checkStringMatch("exception classname", @@ -451,9 +456,11 @@ public class TestAMWebServicesTasks extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - WebServicesTestUtils.checkStringMatch("exception message", + WebServicesTestUtils.checkStringEqual("exception message", "java.lang.Exception: TaskId string : " - + "task_0_m_000000 is not properly formed", message); + + "task_0_m_000000 is not properly formed" + + "\nReason: java.util.regex.Matcher[pattern=" + + TaskID.TASK_ID_REGEX + " region=0,15 lastmatch=]", message); WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type); WebServicesTestUtils.checkStringMatch("exception classname", @@ -483,9 +490,11 @@ public class TestAMWebServicesTasks extends JerseyTest { String message = exception.getString("message"); String type = exception.getString("exception"); String classname = exception.getString("javaClassName"); - WebServicesTestUtils.checkStringMatch("exception message", + WebServicesTestUtils.checkStringEqual("exception message", "java.lang.Exception: TaskId string : " - + "task_0_0000_m is not properly formed", message); + + "task_0_0000_m is not properly formed" + + "\nReason: java.util.regex.Matcher[pattern=" + + TaskID.TASK_ID_REGEX + " region=0,13 lastmatch=]", message); WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type); WebServicesTestUtils.checkStringMatch("exception classname", diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java index c1bc9ef0739..92786e38e0d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java @@ -45,6 +45,7 @@ public class TestAppController { private AppControllerForTest appController; private RequestContext ctx; private Job job; + private static final String taskId = "task_01_01_m_01"; @Before public void setUp() throws IOException { @@ -70,7 +71,7 @@ public class TestAppController { appController = new AppControllerForTest(app, configuration, ctx); appController.getProperty().put(AMParams.JOB_ID, "job_01_01"); - appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01"); + appController.getProperty().put(AMParams.TASK_ID, taskId); } @@ -205,7 +206,7 @@ public class TestAppController { "Access denied: User user does not have permission to view job job_01_01missing task ID", appController.getData()); - appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01"); + appController.getProperty().put(AMParams.TASK_ID, taskId); appController.taskCounters(); assertEquals(CountersPage.class, appController.getClazz()); } @@ -247,7 +248,7 @@ public class TestAppController { public void testTask() { appController.task(); - assertEquals("Attempts for task_01_01_m01_01" , + assertEquals("Attempts for " + taskId , appController.getProperty().get("title")); assertEquals(TaskPage.class, appController.getClazz()); @@ -290,7 +291,7 @@ public class TestAppController { "Access denied: User user does not have permission to view job job_01_01", appController.getData()); - appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01"); + appController.getProperty().put(AMParams.TASK_ID, taskId); appController.attempts(); assertEquals("Bad request: missing task-type.", appController.getProperty() .get("title"));