|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2,T>
public abstract class TestDriver<K1,V1,K2,V2,T extends TestDriver<K1,V1,K2,V2,T>>
Field Summary | |
---|---|
protected org.apache.hadoop.mrunit.internal.counters.CounterWrapper |
counterWrapper
|
protected List<Pair<Enum<?>,Long>> |
expectedEnumCounters
|
protected List<Pair<K2,V2>> |
expectedOutputs
|
protected List<Pair<Pair<String,String>,Long>> |
expectedStringCounters
|
static org.apache.commons.logging.Log |
LOG
|
Constructor Summary | |
---|---|
TestDriver()
|
Method Summary | ||
---|---|---|
void |
addAllOutput(List<Pair<K2,V2>> outputRecords)
Adds output (k, v)* pairs we expect |
|
void |
addCacheArchive(String path)
Adds an archive to be put on the distributed cache. |
|
void |
addCacheArchive(URI uri)
Adds an archive to be put on the distributed cache. |
|
void |
addCacheFile(String path)
Adds a file to be put on the distributed cache. |
|
void |
addCacheFile(URI uri)
Adds a file to be put on the distributed cache. |
|
void |
addOutput(K2 key,
V2 val)
Adds a (k, v) pair we expect as output |
|
void |
addOutput(Pair<K2,V2> outputRecord)
Adds an output (k, v) pair we expect |
|
void |
addOutputFromString(String output)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
|
protected void |
cleanupDistributedCache()
Cleans up the distributed cache test by deleting the temporary directory and any extracted cache archives contained within |
|
protected
|
copy(E object)
|
|
protected
|
copyPair(S first,
E second)
|
|
protected static void |
formatValueList(List<?> values,
StringBuilder sb)
|
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
|
|
List<Pair<Enum<?>,Long>> |
getExpectedEnumCounters()
|
|
List<Pair<K2,V2>> |
getExpectedOutputs()
|
|
List<Pair<Pair<String,String>,Long>> |
getExpectedStringCounters()
|
|
org.apache.hadoop.conf.Configuration |
getOutputSerializationConfiguration()
Get the Configuration to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat. |
|
protected void |
initDistributedCache()
Initialises the test distributed cache if required. |
|
protected static List<org.apache.hadoop.io.Text> |
parseCommaDelimitedList(String commaDelimList)
Split "val,val,val,val..." into a List of Text(val) objects. |
|
static Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> |
parseTabbedPair(String tabSeparatedPair)
Split "key \t val" into Pair(Text(key), Text(val)) |
|
protected void |
printPreTestDebugLog()
Overridable hook for printing pre-test debug information |
|
void |
resetExpectedCounters()
Clears the list of expected counters from this driver |
|
void |
resetOutput()
Clears the list of outputs expected from this driver |
|
abstract List<Pair<K2,V2>> |
run()
Runs the test but returns the result set instead of validating it (ignores any addOutput(), etc calls made before this) |
|
List<Pair<K2,V2>> |
run(boolean validateCounters)
Runs the test but returns the result set instead of validating it (ignores any addOutput(), etc calls made before this). |
|
void |
runTest()
Runs the test and validates the results |
|
void |
runTest(boolean orderMatters)
Runs the test and validates the results |
|
void |
setCacheArchives(URI[] archives)
Set the list of archives to put on the distributed cache |
|
void |
setCacheFiles(URI[] files)
Set the list of files to put on the distributed cache |
|
void |
setConfiguration(org.apache.hadoop.conf.Configuration configuration)
Deprecated. Use getConfiguration() to set configuration items as opposed to overriding the entire configuration object as it's used internally. |
|
void |
setOutputSerializationConfiguration(org.apache.hadoop.conf.Configuration configuration)
Set the Configuration to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat. |
|
protected T |
thisAsTestDriver()
|
|
protected void |
validate(org.apache.hadoop.mrunit.internal.counters.CounterWrapper counterWrapper)
Check counters. |
|
protected void |
validate(List<Pair<K2,V2>> outputs,
boolean orderMatters)
check the outputs against the expected inputs in record |
|
T |
withAllOutput(List<Pair<K2,V2>> outputRecords)
Functions like addAllOutput() but returns self for fluent programming style |
|
T |
withCacheArchive(String archive)
Adds an archive to be put on the distributed cache. |
|
T |
withCacheArchive(URI archive)
Adds an archive to be put on the distributed cache. |
|
T |
withCacheFile(String file)
Adds a file to be put on the distributed cache. |
|
T |
withCacheFile(URI file)
Adds a file to be put on the distributed cache. |
|
T |
withConfiguration(org.apache.hadoop.conf.Configuration configuration)
Deprecated. Use getConfiguration() to set configuration items as opposed to overriding the entire configuration object as it's used internally. |
|
T |
withCounter(Enum<?> e,
long expectedValue)
Register expected enumeration based counter value |
|
T |
withCounter(String group,
String name,
long expectedValue)
Register expected name based counter value |
|
T |
withOutput(K2 key,
V2 val)
Works like addOutput() but returns self for fluent programming style |
|
T |
withOutput(Pair<K2,V2> outputRecord)
Works like addOutput(), but returns self for fluent style |
|
T |
withOutputFromString(String output)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
|
T |
withOutputSerializationConfiguration(org.apache.hadoop.conf.Configuration configuration)
Set the Configuration to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat. |
|
T |
withStrictCounterChecking()
Change counter checking. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
protected List<Pair<K2,V2>> expectedOutputs
protected List<Pair<Enum<?>,Long>> expectedEnumCounters
protected List<Pair<Pair<String,String>,Long>> expectedStringCounters
protected org.apache.hadoop.mrunit.internal.counters.CounterWrapper counterWrapper
Constructor Detail |
---|
public TestDriver()
Method Detail |
---|
public void addAllOutput(List<Pair<K2,V2>> outputRecords)
outputRecords
- The (k, v)* pairs to addpublic T withAllOutput(List<Pair<K2,V2>> outputRecords)
outputRecords
-
public void addOutput(Pair<K2,V2> outputRecord)
outputRecord
- The (k, v) pair to addpublic void addOutput(K2 key, V2 val)
key
- the keyval
- the valuepublic T withOutput(Pair<K2,V2> outputRecord)
outputRecord
-
public T withOutput(K2 key, V2 val)
@Deprecated public void addOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.@Deprecated public T withOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.
public List<Pair<K2,V2>> getExpectedOutputs()
public void resetOutput()
public List<Pair<Enum<?>,Long>> getExpectedEnumCounters()
public List<Pair<Pair<String,String>,Long>> getExpectedStringCounters()
public void resetExpectedCounters()
protected T thisAsTestDriver()
public T withCounter(Enum<?> e, long expectedValue)
e
- Enumeration based counterexpectedValue
- Expected value
public T withCounter(String group, String name, long expectedValue)
group
- Counter groupname
- Counter nameexpectedValue
- Expected value
public T withStrictCounterChecking()
public org.apache.hadoop.conf.Configuration getConfiguration()
@Deprecated public void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
configuration
- The configuration object that will given to the mapper and/or
reducer associated with the driver. This method should only be
called directly after the constructor as the internal state
of the driver depends on the configuration object@Deprecated public T withConfiguration(org.apache.hadoop.conf.Configuration configuration)
configuration
- The configuration object that will given to the mapper associated
with the driver. This method should only be called directly after
the constructor as the internal state of the driver depends on the
configuration object
public org.apache.hadoop.conf.Configuration getOutputSerializationConfiguration()
Configuration
to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat.
public void setOutputSerializationConfiguration(org.apache.hadoop.conf.Configuration configuration)
Configuration
to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat. When this configuration is not set, MRUnit will use the
configuration set with withConfiguration(Configuration)
or
setConfiguration(Configuration)
configuration
- public T withOutputSerializationConfiguration(org.apache.hadoop.conf.Configuration configuration)
Configuration
to use when copying output for use with run*
methods or for the InputFormat when reading output back in when setting a
real OutputFormat. When this configuration is not set, MRUnit will use the
configuration set with withConfiguration(Configuration)
or
setConfiguration(Configuration)
configuration
-
public void addCacheFile(String path)
path
- path to the filepublic void addCacheFile(URI uri)
uri
- uri of the filepublic void setCacheFiles(URI[] files)
files
- list of URIspublic void addCacheArchive(String path)
path
- path to the archivepublic void addCacheArchive(URI uri)
uri
- uri of the archivepublic void setCacheArchives(URI[] archives)
archives
- list of URIspublic T withCacheFile(String file)
file
- path to the file
public T withCacheFile(URI file)
file
- uri of the file
public T withCacheArchive(String archive)
archive
- path to the archive
public T withCacheArchive(URI archive)
file
- uri of the archive
public List<Pair<K2,V2>> run(boolean validateCounters) throws IOException
validateCounters
- whether to run automatic counter validation
IOException
protected void initDistributedCache() throws IOException
IOException
protected void cleanupDistributedCache() throws IOException
IOException
- if the local fs handle cannot be retrievedpublic abstract List<Pair<K2,V2>> run() throws IOException
IOException
public void runTest() throws IOException
IOException
public void runTest(boolean orderMatters) throws IOException
orderMatters
- Whether or not output ordering is important
IOException
protected void printPreTestDebugLog()
public static Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> parseTabbedPair(String tabSeparatedPair)
tabSeparatedPair
-
protected static List<org.apache.hadoop.io.Text> parseCommaDelimitedList(String commaDelimList)
commaDelimList
- A list of values separated by commasprotected <E> E copy(E object)
protected <S,E> Pair<S,E> copyPair(S first, E second)
protected void validate(List<Pair<K2,V2>> outputs, boolean orderMatters)
outputs
- The actual output (k, v) pairsorderMatters
- Whether or not output ordering is important when validating test
resultprotected void validate(org.apache.hadoop.mrunit.internal.counters.CounterWrapper counterWrapper)
protected static void formatValueList(List<?> values, StringBuilder sb)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |