MAPREDUCE-3795. "job -status" command line output is malformed. (vinodkv via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1240593 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mahadev Konar 2012-02-04 19:32:10 +00:00
parent caed1cfaf9
commit f2280f612c
3 changed files with 19 additions and 8 deletions

View File

@ -693,6 +693,9 @@ Release 0.23.1 - Unreleased
incorrectly asserting tests (Bhallamudi Venkata Siva Kamesh incorrectly asserting tests (Bhallamudi Venkata Siva Kamesh
via mahadev) via mahadev)
MAPREDUCE-3795. "job -status" command line output is malformed.
(vinodkv via mahadev)
Release 0.23.0 - 2011-11-01 Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -472,8 +472,8 @@ public String toString() {
sb.append("Job Tracking URL : ").append(status.getTrackingUrl()); sb.append("Job Tracking URL : ").append(status.getTrackingUrl());
sb.append("\n"); sb.append("\n");
sb.append("Uber job : ").append(status.isUber()).append("\n"); sb.append("Uber job : ").append(status.isUber()).append("\n");
sb.append("Number of maps: ").append(numMaps); sb.append("Number of maps: ").append(numMaps).append("\n");
sb.append("Number of reduces: ").append(numReduces); sb.append("Number of reduces: ").append(numReduces).append("\n");
sb.append("map() completion: "); sb.append("map() completion: ");
sb.append(status.getMapProgress()).append("\n"); sb.append(status.getMapProgress()).append("\n");
sb.append("reduce() completion: "); sb.append("reduce() completion: ");

View File

@ -21,7 +21,9 @@
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -34,6 +36,7 @@
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.TaskReport;
import org.apache.hadoop.mapreduce.JobStatus.State; import org.apache.hadoop.mapreduce.JobStatus.State;
import org.apache.hadoop.mapreduce.protocol.ClientProtocol; import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
import org.apache.log4j.Layout; import org.apache.log4j.Layout;
@ -88,6 +91,7 @@ public TaskCompletionEvent[] answer(InvocationOnMock invocation)
} }
).when(job).getTaskCompletionEvents(anyInt(), anyInt()); ).when(job).getTaskCompletionEvents(anyInt(), anyInt());
doReturn(new TaskReport[5]).when(job).getTaskReports(isA(TaskType.class));
when(clientProtocol.getJobStatus(any(JobID.class))).thenReturn(jobStatus_1, jobStatus_2); when(clientProtocol.getJobStatus(any(JobID.class))).thenReturn(jobStatus_1, jobStatus_2);
// setup the logger to capture all logs // setup the logger to capture all logs
Layout layout = Layout layout =
@ -106,21 +110,25 @@ public TaskCompletionEvent[] answer(InvocationOnMock invocation)
boolean foundHundred = false; boolean foundHundred = false;
boolean foundComplete = false; boolean foundComplete = false;
boolean foundUber = false; boolean foundUber = false;
String match_1 = "uber mode : true"; String uberModeMatch = "uber mode : true";
String match_2 = "map 100% reduce 100%"; String progressMatch = "map 100% reduce 100%";
String match_3 = "completed successfully"; String completionMatch = "completed successfully";
while ((line = r.readLine()) != null) { while ((line = r.readLine()) != null) {
if (line.contains(match_1)) { if (line.contains(uberModeMatch)) {
foundUber = true; foundUber = true;
} }
foundHundred = line.contains(match_2); foundHundred = line.contains(progressMatch);
if (foundHundred) if (foundHundred)
break; break;
} }
line = r.readLine(); line = r.readLine();
foundComplete = line.contains(match_3); foundComplete = line.contains(completionMatch);
assertTrue(foundUber); assertTrue(foundUber);
assertTrue(foundHundred); assertTrue(foundHundred);
assertTrue(foundComplete); assertTrue(foundComplete);
System.out.println("The output of job.toString() is : \n" + job.toString());
assertTrue(job.toString().contains("Number of maps: 5\n"));
assertTrue(job.toString().contains("Number of reduces: 5\n"));
} }
} }