|
@@ -29,6 +29,16 @@ import org.junit.Test;
|
|
|
|
|
|
public class TestFileNameIndexUtils {
|
|
|
|
|
|
+ private static final String OLD_JOB_HISTORY_FILE_FORMATTER = "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + JobHistoryUtils.JOB_HISTORY_FILE_EXTENSION;
|
|
|
+
|
|
|
private static final String JOB_HISTORY_FILE_FORMATTER = "%s"
|
|
|
+ FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ FileNameIndexUtils.DELIMITER + "%s"
|
|
@@ -37,6 +47,7 @@ public class TestFileNameIndexUtils {
|
|
|
+ FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ + FileNameIndexUtils.DELIMITER + "%s"
|
|
|
+ JobHistoryUtils.JOB_HISTORY_FILE_EXTENSION;
|
|
|
|
|
|
private static final String JOB_ID = "job_1317928501754_0001";
|
|
@@ -55,9 +66,48 @@ public class TestFileNameIndexUtils {
|
|
|
private static final String NUM_MAPS = "1";
|
|
|
private static final String NUM_REDUCES = "1";
|
|
|
private static final String JOB_STATUS = "SUCCEEDED";
|
|
|
+ private static final String QUEUE_NAME = "default";
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testEncodingDecodingEquivalence() throws IOException {
|
|
|
+ JobIndexInfo info = new JobIndexInfo();
|
|
|
+ JobID oldJobId = JobID.forName(JOB_ID);
|
|
|
+ JobId jobId = TypeConverter.toYarn(oldJobId);
|
|
|
+ info.setJobId(jobId);
|
|
|
+ info.setSubmitTime(Long.parseLong(SUBMIT_TIME));
|
|
|
+ info.setUser(USER_NAME);
|
|
|
+ info.setJobName(JOB_NAME);
|
|
|
+ info.setFinishTime(Long.parseLong(FINISH_TIME));
|
|
|
+ info.setNumMaps(Integer.parseInt(NUM_MAPS));
|
|
|
+ info.setNumReduces(Integer.parseInt(NUM_REDUCES));
|
|
|
+ info.setJobStatus(JOB_STATUS);
|
|
|
+ info.setQueueName(QUEUE_NAME);
|
|
|
+
|
|
|
+ String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info);
|
|
|
+ JobIndexInfo parsedInfo = FileNameIndexUtils.getIndexInfo(jobHistoryFile);
|
|
|
+
|
|
|
+ Assert.assertEquals("Job id different after encoding and decoding",
|
|
|
+ info.getJobId(), parsedInfo.getJobId());
|
|
|
+ Assert.assertEquals("Submit time different after encoding and decoding",
|
|
|
+ info.getSubmitTime(), parsedInfo.getSubmitTime());
|
|
|
+ Assert.assertEquals("User different after encoding and decoding",
|
|
|
+ info.getUser(), parsedInfo.getUser());
|
|
|
+ Assert.assertEquals("Job name different after encoding and decoding",
|
|
|
+ info.getJobName(), parsedInfo.getJobName());
|
|
|
+ Assert.assertEquals("Finish time different after encoding and decoding",
|
|
|
+ info.getFinishTime(), parsedInfo.getFinishTime());
|
|
|
+ Assert.assertEquals("Num maps different after encoding and decoding",
|
|
|
+ info.getNumMaps(), parsedInfo.getNumMaps());
|
|
|
+ Assert.assertEquals("Num reduces different after encoding and decoding",
|
|
|
+ info.getNumReduces(), parsedInfo.getNumReduces());
|
|
|
+ Assert.assertEquals("Job status different after encoding and decoding",
|
|
|
+ info.getJobStatus(), parsedInfo.getJobStatus());
|
|
|
+ Assert.assertEquals("Queue name different after encoding and decoding",
|
|
|
+ info.getQueueName(), parsedInfo.getQueueName());
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
- public void testUserNamePercentEncoding() throws IOException{
|
|
|
+ public void testUserNamePercentEncoding() throws IOException {
|
|
|
JobIndexInfo info = new JobIndexInfo();
|
|
|
JobID oldJobId = JobID.forName(JOB_ID);
|
|
|
JobId jobId = TypeConverter.toYarn(oldJobId);
|
|
@@ -69,6 +119,7 @@ public class TestFileNameIndexUtils {
|
|
|
info.setNumMaps(Integer.parseInt(NUM_MAPS));
|
|
|
info.setNumReduces(Integer.parseInt(NUM_REDUCES));
|
|
|
info.setJobStatus(JOB_STATUS);
|
|
|
+ info.setQueueName(QUEUE_NAME);
|
|
|
|
|
|
String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info);
|
|
|
Assert.assertTrue("User name not encoded correctly into job history file",
|
|
@@ -85,7 +136,8 @@ public class TestFileNameIndexUtils {
|
|
|
FINISH_TIME,
|
|
|
NUM_MAPS,
|
|
|
NUM_REDUCES,
|
|
|
- JOB_STATUS);
|
|
|
+ JOB_STATUS,
|
|
|
+ QUEUE_NAME);
|
|
|
|
|
|
JobIndexInfo info = FileNameIndexUtils.getIndexInfo(jobHistoryFile);
|
|
|
Assert.assertEquals("User name doesn't match",
|
|
@@ -105,6 +157,7 @@ public class TestFileNameIndexUtils {
|
|
|
info.setNumMaps(Integer.parseInt(NUM_MAPS));
|
|
|
info.setNumReduces(Integer.parseInt(NUM_REDUCES));
|
|
|
info.setJobStatus(JOB_STATUS);
|
|
|
+ info.setQueueName(QUEUE_NAME);
|
|
|
|
|
|
String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info);
|
|
|
Assert.assertTrue("Job name not encoded correctly into job history file",
|
|
@@ -121,10 +174,52 @@ public class TestFileNameIndexUtils {
|
|
|
FINISH_TIME,
|
|
|
NUM_MAPS,
|
|
|
NUM_REDUCES,
|
|
|
- JOB_STATUS);
|
|
|
+ JOB_STATUS,
|
|
|
+ QUEUE_NAME);
|
|
|
|
|
|
JobIndexInfo info = FileNameIndexUtils.getIndexInfo(jobHistoryFile);
|
|
|
Assert.assertEquals("Job name doesn't match",
|
|
|
JOB_NAME_WITH_DELIMITER, info.getJobName());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testJobHistoryFileNameBackwardsCompatible() throws IOException {
|
|
|
+ JobID oldJobId = JobID.forName(JOB_ID);
|
|
|
+ JobId jobId = TypeConverter.toYarn(oldJobId);
|
|
|
+
|
|
|
+ long submitTime = Long.parseLong(SUBMIT_TIME);
|
|
|
+ long finishTime = Long.parseLong(FINISH_TIME);
|
|
|
+ int numMaps = Integer.parseInt(NUM_MAPS);
|
|
|
+ int numReduces = Integer.parseInt(NUM_REDUCES);
|
|
|
+
|
|
|
+ String jobHistoryFile = String.format(OLD_JOB_HISTORY_FILE_FORMATTER,
|
|
|
+ JOB_ID,
|
|
|
+ SUBMIT_TIME,
|
|
|
+ USER_NAME,
|
|
|
+ JOB_NAME,
|
|
|
+ FINISH_TIME,
|
|
|
+ NUM_MAPS,
|
|
|
+ NUM_REDUCES,
|
|
|
+ JOB_STATUS);
|
|
|
+
|
|
|
+ JobIndexInfo info = FileNameIndexUtils.getIndexInfo(jobHistoryFile);
|
|
|
+ Assert.assertEquals("Job id incorrect after decoding old history file",
|
|
|
+ jobId, info.getJobId());
|
|
|
+ Assert.assertEquals("Submit time incorrect after decoding old history file",
|
|
|
+ submitTime, info.getSubmitTime());
|
|
|
+ Assert.assertEquals("User incorrect after decoding old history file",
|
|
|
+ USER_NAME, info.getUser());
|
|
|
+ Assert.assertEquals("Job name incorrect after decoding old history file",
|
|
|
+ JOB_NAME, info.getJobName());
|
|
|
+ Assert.assertEquals("Finish time incorrect after decoding old history file",
|
|
|
+ finishTime, info.getFinishTime());
|
|
|
+ Assert.assertEquals("Num maps incorrect after decoding old history file",
|
|
|
+ numMaps, info.getNumMaps());
|
|
|
+ Assert.assertEquals("Num reduces incorrect after decoding old history file",
|
|
|
+ numReduces, info.getNumReduces());
|
|
|
+ Assert.assertEquals("Job status incorrect after decoding old history file",
|
|
|
+ JOB_STATUS, info.getJobStatus());
|
|
|
+ Assert.assertNull("Queue name incorrect after decoding old history file",
|
|
|
+ info.getQueueName());
|
|
|
+ }
|
|
|
}
|