MAPREDUCE-3541. Fix broken TestJobQueueClient test. (Ravi Prakash via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1214421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mahadev Konar 2011-12-14 19:45:59 +00:00
parent 2e6c75a062
commit 739f8871f2
4 changed files with 20 additions and 11 deletions

View File

@ -293,6 +293,9 @@ Release 0.23.1 - Unreleased
in the correct directory to work properly in secure mode. (Hitesh Shah via in the correct directory to work properly in secure mode. (Hitesh Shah via
vinodkv) vinodkv)
MAPREDUCE-3541. Fix broken TestJobQueueClient test. (Ravi Prakash via
mahadev)
Release 0.23.0 - 2011-11-01 Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -109,7 +109,14 @@ public int run(String[] argv) throws Exception {
return exitcode; return exitcode;
} }
// format and print information about the passed in job queue.
void printJobQueueInfo(JobQueueInfo jobQueueInfo, Writer writer)
throws IOException {
printJobQueueInfo(jobQueueInfo, writer, "");
}
// format and print information about the passed in job queue. // format and print information about the passed in job queue.
@SuppressWarnings("deprecation")
void printJobQueueInfo(JobQueueInfo jobQueueInfo, Writer writer, void printJobQueueInfo(JobQueueInfo jobQueueInfo, Writer writer,
String prefix) throws IOException { String prefix) throws IOException {
if (jobQueueInfo == null) { if (jobQueueInfo == null) {
@ -136,7 +143,7 @@ void printJobQueueInfo(JobQueueInfo jobQueueInfo, Writer writer,
private void displayQueueList() throws IOException { private void displayQueueList() throws IOException {
JobQueueInfo[] rootQueues = jc.getRootQueues(); JobQueueInfo[] rootQueues = jc.getRootQueues();
for (JobQueueInfo queue : rootQueues) { for (JobQueueInfo queue : rootQueues) {
printJobQueueInfo(queue, new PrintWriter(System.out), ""); printJobQueueInfo(queue, new PrintWriter(System.out));
} }
} }
@ -174,7 +181,7 @@ private void displayQueueInfo(String queue, boolean showJobs)
System.out.println("Queue \"" + queue + "\" does not exist."); System.out.println("Queue \"" + queue + "\" does not exist.");
return; return;
} }
printJobQueueInfo(jobQueueInfo, new PrintWriter(System.out), ""); printJobQueueInfo(jobQueueInfo, new PrintWriter(System.out));
if (showJobs && (jobQueueInfo.getChildren() == null || if (showJobs && (jobQueueInfo.getChildren() == null ||
jobQueueInfo.getChildren().size() == 0)) { jobQueueInfo.getChildren().size() == 0)) {
JobStatus[] jobs = jc.getJobsFromQueue(queue); JobStatus[] jobs = jc.getJobsFromQueue(queue);

View File

@ -45,7 +45,7 @@ public void testPrintJobQueueInfo() throws IOException {
ByteArrayOutputStream bbos = new ByteArrayOutputStream(); ByteArrayOutputStream bbos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(bbos); PrintWriter writer = new PrintWriter(bbos);
queueClient.printJobQueueInfo(parent, writer, ""); queueClient.printJobQueueInfo(parent, writer);
Assert.assertTrue("printJobQueueInfo did not print grandchild's name", Assert.assertTrue("printJobQueueInfo did not print grandchild's name",
bbos.toString().contains("GrandChildQueue")); bbos.toString().contains("GrandChildQueue"));

View File

@ -30,6 +30,8 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import org.apache.hadoop.mapreduce.QueueInfo; import org.apache.hadoop.mapreduce.QueueInfo;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
@ -79,14 +81,11 @@ public void testQueueInfoPrinting() throws Exception {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
client.printJobQueueInfo(root, writer); client.printJobQueueInfo(root, writer);
StringBuffer sb = new StringBuffer(); Assert.assertTrue(writer.toString().contains("Queue Name : q1"));
sb.append("Queue Name : q1 \n"); Assert.assertTrue(writer.toString().contains("Queue State : running"));
sb.append("Queue State : running \n"); Assert.assertTrue(writer.toString().contains("Scheduling Info : q1 scheduling info"));
sb.append("Scheduling Info : q1 scheduling info \n"); Assert.assertTrue(writer.toString().contains("Queue Name : q1:1"));
sb.append("Child Queues : q1:1, q1:2\n"); Assert.assertTrue(writer.toString().contains("Queue Name : q1:2"));
sb.append("======================\n");
assertEquals(sb.toString(), writer.toString());
} }
@Test @Test