-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default job name length for DistributedLzoIndexer #117
Changes from 4 commits
5f2098a
b0ec116
a786db7
9b10fe7
d6c7468
33f09d2
4a964cf
1bc619c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.hadoop.compression.lzo; | ||
|
||
import junit.framework.TestCase; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.mapreduce.Job; | ||
|
||
public class TestDistLzoIndexerJobName extends TestCase { | ||
|
||
public void testDefaultName() throws Exception { | ||
String[] args = new String[]{ | ||
"hdfs://cluster/user/test/output/file-m-00000.lzo", | ||
}; | ||
|
||
Job job = new Job(new Configuration(false)); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
String expected = "Distributed Lzo Indexer [hdfs://cluster/user/test/output/file-m-00000.lzo]"; | ||
|
||
assertEquals(expected, job.getJobName()); | ||
} | ||
|
||
public void testCustomeName() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: CustomeName -> CustomName |
||
String[] args = new String[]{ | ||
"ignored", | ||
}; | ||
String customName = "-<Custom Job Name>-"; | ||
|
||
Configuration conf = new Configuration(false); | ||
conf.set("lzo.indexer.distributed.job.name", customName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the constant. |
||
Job job = new Job(conf); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
assertEquals(customName, job.getJobName()); | ||
} | ||
|
||
public void testCustomeNameTruncation() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same typo |
||
String[] args = new String[]{ | ||
"ignored", | ||
}; | ||
|
||
Configuration conf = new Configuration(false); | ||
conf.set("lzo.indexer.distributed.job.name", "123456789"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use the constants in these 2 lines. |
||
conf.setInt("lzo.indexer.distributed.job.name.max.length", 5); | ||
Job job = new Job(conf); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
assertEquals("12345...", job.getJobName()); | ||
} | ||
|
||
public void testDefaultLengthTruncation() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really think it's important to test the default length. It should be sufficient between the custom name test and custom length test IMO. I'm OK with dropping this test. The fact that this test needs to rely on the default value (200) implicitly is also bit of a drawback (should the default change in the future). |
||
String[] args = new String[]{ | ||
"hdfs://cluster/user/test/output/file-m-00000.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00001.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00002.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
}; | ||
|
||
Job job = new Job(new Configuration(false)); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
String expected = "Distributed Lzo Indexer [hdfs://cluster/user/test/output/file-m-00000.lzo, hdfs://cluster/user/test/output/file-m-00001.lzo, hdfs://cluster/user/test/output/file-m-00002.lzo, hdfs://cluster/user/test/..."; | ||
// Truncated length should be 200 + 3 for the "..." | ||
assertEquals(203, expected.length()); | ||
|
||
assertEquals(expected, job.getJobName()); | ||
} | ||
|
||
public void testCustomLengthTruncation() throws Exception { | ||
String[] args = new String[]{ | ||
"hdfs://cluster/user/test/output/file-m-00000.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00001.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00002.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
}; | ||
|
||
Configuration conf = new Configuration(false); | ||
conf.setInt("lzo.indexer.distributed.job.name.max.length", 50); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the constant. |
||
Job job = new Job(conf); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
String expected = "Distributed Lzo Indexer [hdfs://cluster/user/test/..."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use the constant here too. |
||
// Truncated length should be 50 + 3 for the "..." | ||
assertEquals(53, expected.length()); | ||
|
||
assertEquals(expected, job.getJobName()); | ||
} | ||
|
||
public void testDisabledTruncation() throws Exception { | ||
String[] args = new String[]{ | ||
"hdfs://cluster/user/test/output/file-m-00000.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00001.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00002.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
"hdfs://cluster/user/test/output/file-m-00003.lzo", | ||
}; | ||
|
||
Configuration conf = new Configuration(false); | ||
conf.setInt("lzo.indexer.distributed.job.name.max.length", 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the constant. |
||
Job job = new Job(conf); | ||
DistributedLzoIndexer.setJobName(job, args); | ||
|
||
String expected = "Distributed Lzo Indexer [hdfs://cluster/user/test/output/file-m-00000.lzo, hdfs://cluster/user/test/output/file-m-00001.lzo, hdfs://cluster/user/test/output/file-m-00002.lzo, hdfs://cluster/user/test/output/file-m-00003.lzo, hdfs://cluster/user/test/output/file-m-00003.lzo]"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
assertEquals(expected, job.getJobName()); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define a constant for "Distributed Lzo Indexer" so that it can be reused by the test?