YARN-5622. TestYarnCLI.testGetContainers fails due to mismatched date formats. Contributed by Eric Badger.

(cherry picked from commit 6e849cb658)
This commit is contained in:
Kihwal Lee 2016-09-23 14:15:31 -05:00
parent 20540df80d
commit 9269225522
1 changed files with 4 additions and 6 deletions

View File

@ -34,8 +34,6 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.EnumSet; import java.util.EnumSet;
@ -80,6 +78,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Records;
import org.apache.hadoop.yarn.util.Times;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -298,7 +297,6 @@ public class TestYarnCLI {
reports.add(container); reports.add(container);
reports.add(container1); reports.add(container1);
reports.add(container2); reports.add(container2);
DateFormat dateFormat=new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
when(client.getContainers(any(ApplicationAttemptId.class))).thenReturn( when(client.getContainers(any(ApplicationAttemptId.class))).thenReturn(
reports); reports);
sysOutStream.reset(); sysOutStream.reset();
@ -312,13 +310,13 @@ public class TestYarnCLI {
pw.printf(ApplicationCLI.CONTAINER_PATTERN, "Container-Id", "Start Time", pw.printf(ApplicationCLI.CONTAINER_PATTERN, "Container-Id", "Start Time",
"Finish Time", "State", "Host", "Node Http Address", "LOG-URL"); "Finish Time", "State", "Host", "Node Http Address", "LOG-URL");
pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000001", pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000001",
dateFormat.format(new Date(time1)), dateFormat.format(new Date(time2)), Times.format(time1), Times.format(time2),
"COMPLETE", "host:1234", "http://host:2345", "logURL"); "COMPLETE", "host:1234", "http://host:2345", "logURL");
pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000002", pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000002",
dateFormat.format(new Date(time1)), dateFormat.format(new Date(time2)), Times.format(time1), Times.format(time2),
"COMPLETE", "host:1234", "http://host:2345", "logURL"); "COMPLETE", "host:1234", "http://host:2345", "logURL");
pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000003", pw.printf(ApplicationCLI.CONTAINER_PATTERN, "container_1234_0005_01_000003",
dateFormat.format(new Date(time1)), "N/A", "RUNNING", "host:1234", Times.format(time1), "N/A", "RUNNING", "host:1234",
"http://host:2345", ""); "http://host:2345", "");
pw.close(); pw.close();
String appReportStr = baos.toString("UTF-8"); String appReportStr = baos.toString("UTF-8");