MAPREDUCE-6333. TestEvents,TestAMWebServicesTasks,TestAppController are broken due to MAPREDUCE-6297. (Siqi Li via gera)

This commit is contained in:
Gera Shegalov 2015-04-24 09:21:44 -07:00
parent 2f82ae042a
commit 78c6b46241
4 changed files with 41 additions and 27 deletions

View File

@ -343,6 +343,9 @@ Release 2.8.0 - UNRELEASED
MAPREDUCE-6330. Fix typo in Task Attempt API's URL in documentations. MAPREDUCE-6330. Fix typo in Task Attempt API's URL in documentations.
(Ryu Kobayashi via ozawa) (Ryu Kobayashi via ozawa)
MAPREDUCE-6333. TestEvents,TestAMWebServicesTasks,TestAppController are
broken due to MAPREDUCE-6297. (Siqi Li via gera)
Release 2.7.1 - UNRELEASED Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -39,6 +39,7 @@ import org.junit.Test;
public class TestEvents { public class TestEvents {
private static final String taskId = "task_1_2_r_3";
/** /**
* test a getters of TaskAttemptFinishedEvent and TaskAttemptFinished * test a getters of TaskAttemptFinishedEvent and TaskAttemptFinished
* *
@ -131,7 +132,7 @@ public class TestEvents {
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
@ -141,42 +142,42 @@ public class TestEvents {
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptStarted) e.getDatum()).taskid.toString()); ((TaskAttemptStarted) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptFinished) e.getDatum()).taskid.toString()); ((TaskAttemptFinished) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_STARTED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptStarted) e.getDatum()).taskid.toString()); ((TaskAttemptStarted) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_FINISHED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptFinished) e.getDatum()).taskid.toString()); ((TaskAttemptFinished) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString());
e = reader.getNextEvent(); e = reader.getNextEvent();
assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED)); assertTrue(e.getEventType().equals(EventType.REDUCE_ATTEMPT_KILLED));
assertEquals("task_1_2_r03_4", assertEquals(taskId,
((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString()); ((TaskAttemptUnsuccessfulCompletion) e.getDatum()).taskid.toString());
reader.close(); reader.close();
@ -234,7 +235,7 @@ public class TestEvents {
datum.hostname = "hostname"; datum.hostname = "hostname";
datum.rackname = "rackname"; datum.rackname = "rackname";
datum.physMemKbytes = Arrays.asList(1000, 2000, 3000); datum.physMemKbytes = Arrays.asList(1000, 2000, 3000);
datum.taskid = "task_1_2_r03_4"; datum.taskid = taskId;
datum.port = 1000; datum.port = 1000;
datum.taskType = "REDUCE"; datum.taskType = "REDUCE";
datum.status = "STATUS"; datum.status = "STATUS";
@ -260,7 +261,7 @@ public class TestEvents {
datum.hostname = "hostname"; datum.hostname = "hostname";
datum.rackname = "rackName"; datum.rackname = "rackName";
datum.state = "state"; datum.state = "state";
datum.taskid = "task_1_2_r03_4"; datum.taskid = taskId;
datum.taskStatus = "taskStatus"; datum.taskStatus = "taskStatus";
datum.taskType = "REDUCE"; datum.taskType = "REDUCE";
result.setDatum(datum); result.setDatum(datum);
@ -278,7 +279,7 @@ public class TestEvents {
datum.locality = "locality"; datum.locality = "locality";
datum.shufflePort = 10001; datum.shufflePort = 10001;
datum.startTime = 1; datum.startTime = 1;
datum.taskid = "task_1_2_r03_4"; datum.taskid = taskId;
datum.taskType = "taskType"; datum.taskType = "taskType";
datum.trackerName = "trackerName"; datum.trackerName = "trackerName";
result.setDatum(datum); result.setDatum(datum);
@ -308,7 +309,7 @@ public class TestEvents {
datum.hostname = "hostname"; datum.hostname = "hostname";
datum.rackname = "rackname"; datum.rackname = "rackname";
datum.state = "state"; datum.state = "state";
datum.taskid = "task_1_2_r03_4"; datum.taskid = taskId;
datum.taskStatus = "taskStatus"; datum.taskStatus = "taskStatus";
datum.taskType = "REDUCE"; datum.taskType = "REDUCE";
result.setDatum(datum); result.setDatum(datum);
@ -325,7 +326,7 @@ public class TestEvents {
datum.locality = "locality"; datum.locality = "locality";
datum.shufflePort = 10001; datum.shufflePort = 10001;
datum.startTime = 1; datum.startTime = 1;
datum.taskid = "task_1_2_r03_4"; datum.taskid = taskId;
datum.taskType = "taskType"; datum.taskType = "taskType";
datum.trackerName = "trackerName"; datum.trackerName = "trackerName";
result.setDatum(datum); result.setDatum(datum);

View File

@ -31,6 +31,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.hadoop.conf.Configuration; 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.JobId;
import org.apache.hadoop.mapreduce.v2.api.records.TaskId; import org.apache.hadoop.mapreduce.v2.api.records.TaskId;
import org.apache.hadoop.mapreduce.v2.api.records.TaskReport; import org.apache.hadoop.mapreduce.v2.api.records.TaskReport;
@ -355,9 +356,11 @@ public class TestAMWebServicesTasks extends JerseyTest {
String message = exception.getString("message"); String message = exception.getString("message");
String type = exception.getString("exception"); String type = exception.getString("exception");
String classname = exception.getString("javaClassName"); String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception message", WebServicesTestUtils.checkStringEqual("exception message",
"java.lang.Exception: TaskId string : " "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", WebServicesTestUtils.checkStringMatch("exception type",
"NotFoundException", type); "NotFoundException", type);
WebServicesTestUtils.checkStringMatch("exception classname", WebServicesTestUtils.checkStringMatch("exception classname",
@ -419,9 +422,11 @@ public class TestAMWebServicesTasks extends JerseyTest {
String message = exception.getString("message"); String message = exception.getString("message");
String type = exception.getString("exception"); String type = exception.getString("exception");
String classname = exception.getString("javaClassName"); String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception message", WebServicesTestUtils.checkStringEqual("exception message",
"java.lang.Exception: Bad TaskType identifier. TaskId string : " "java.lang.Exception: TaskId string : "
+ "task_0_0000_d_000000 is not properly formed.", message); + "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", WebServicesTestUtils.checkStringMatch("exception type",
"NotFoundException", type); "NotFoundException", type);
WebServicesTestUtils.checkStringMatch("exception classname", WebServicesTestUtils.checkStringMatch("exception classname",
@ -451,9 +456,11 @@ public class TestAMWebServicesTasks extends JerseyTest {
String message = exception.getString("message"); String message = exception.getString("message");
String type = exception.getString("exception"); String type = exception.getString("exception");
String classname = exception.getString("javaClassName"); String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception message", WebServicesTestUtils.checkStringEqual("exception message",
"java.lang.Exception: TaskId string : " "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", WebServicesTestUtils.checkStringMatch("exception type",
"NotFoundException", type); "NotFoundException", type);
WebServicesTestUtils.checkStringMatch("exception classname", WebServicesTestUtils.checkStringMatch("exception classname",
@ -483,9 +490,11 @@ public class TestAMWebServicesTasks extends JerseyTest {
String message = exception.getString("message"); String message = exception.getString("message");
String type = exception.getString("exception"); String type = exception.getString("exception");
String classname = exception.getString("javaClassName"); String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception message", WebServicesTestUtils.checkStringEqual("exception message",
"java.lang.Exception: TaskId string : " "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", WebServicesTestUtils.checkStringMatch("exception type",
"NotFoundException", type); "NotFoundException", type);
WebServicesTestUtils.checkStringMatch("exception classname", WebServicesTestUtils.checkStringMatch("exception classname",

View File

@ -45,6 +45,7 @@ public class TestAppController {
private AppControllerForTest appController; private AppControllerForTest appController;
private RequestContext ctx; private RequestContext ctx;
private Job job; private Job job;
private static final String taskId = "task_01_01_m_01";
@Before @Before
public void setUp() throws IOException { public void setUp() throws IOException {
@ -70,7 +71,7 @@ public class TestAppController {
appController = new AppControllerForTest(app, configuration, ctx); appController = new AppControllerForTest(app, configuration, ctx);
appController.getProperty().put(AMParams.JOB_ID, "job_01_01"); 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", "Access denied: User user does not have permission to view job job_01_01missing task ID",
appController.getData()); appController.getData());
appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01"); appController.getProperty().put(AMParams.TASK_ID, taskId);
appController.taskCounters(); appController.taskCounters();
assertEquals(CountersPage.class, appController.getClazz()); assertEquals(CountersPage.class, appController.getClazz());
} }
@ -247,7 +248,7 @@ public class TestAppController {
public void testTask() { public void testTask() {
appController.task(); appController.task();
assertEquals("Attempts for task_01_01_m01_01" , assertEquals("Attempts for " + taskId ,
appController.getProperty().get("title")); appController.getProperty().get("title"));
assertEquals(TaskPage.class, appController.getClazz()); 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", "Access denied: User user does not have permission to view job job_01_01",
appController.getData()); appController.getData());
appController.getProperty().put(AMParams.TASK_ID, "task_01_01_m01_01"); appController.getProperty().put(AMParams.TASK_ID, taskId);
appController.attempts(); appController.attempts();
assertEquals("Bad request: missing task-type.", appController.getProperty() assertEquals("Bad request: missing task-type.", appController.getProperty()
.get("title")); .get("title"));