2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-02-12 00:02:49 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
WC_INPUT=/wc_input
|
|
|
|
WC_OUTPUT=/wc_output
|
|
|
|
DATA_INPUT=$(mktemp -d)
|
2013-02-18 23:46:20 +00:00
|
|
|
|
|
|
|
echo "starting hadoop-wordcount test"
|
|
|
|
|
|
|
|
# bail if $TESTDIR is not set as this test will fail in that scenario
|
2014-07-15 11:39:32 +00:00
|
|
|
[ -z $TESTDIR ] && { echo "\$TESTDIR needs to be set, but is not. Exiting."; exit 1; }
|
|
|
|
|
2014-08-29 12:29:22 +00:00
|
|
|
# if HADOOP_PREFIX is not set, use default
|
2015-02-12 00:02:49 +00:00
|
|
|
[ -z $HADOOP_PREFIX ] && { HADOOP_PREFIX=$TESTDIR/hadoop; }
|
2013-02-18 23:46:20 +00:00
|
|
|
|
2015-02-12 00:02:49 +00:00
|
|
|
# Nuke hadoop directories
|
|
|
|
$HADOOP_PREFIX/bin/hadoop fs -rm -r $WC_INPUT $WC_OUTPUT || true
|
|
|
|
|
|
|
|
# Fetch and import testing data set
|
2015-09-24 22:10:46 +00:00
|
|
|
curl http://download.ceph.com/qa/hadoop_input_files.tar | tar xf - -C $DATA_INPUT
|
2015-02-12 00:02:49 +00:00
|
|
|
$HADOOP_PREFIX/bin/hadoop fs -copyFromLocal $DATA_INPUT $WC_INPUT
|
|
|
|
rm -rf $DATA_INPUT
|
|
|
|
|
|
|
|
# Run the job
|
|
|
|
$HADOOP_PREFIX/bin/hadoop jar \
|
|
|
|
$HADOOP_PREFIX/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar \
|
|
|
|
wordcount $WC_INPUT $WC_OUTPUT
|
2014-08-29 12:29:22 +00:00
|
|
|
|
2015-02-12 00:02:49 +00:00
|
|
|
# Cleanup
|
|
|
|
$HADOOP_PREFIX/bin/hadoop fs -rm -r $WC_INPUT $WC_OUTPUT || true
|
2013-02-18 23:46:20 +00:00
|
|
|
|
|
|
|
echo "completed hadoop-wordcount test"
|
|
|
|
exit 0
|