Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / hadoop / wordcount.sh
1 #!/bin/bash
2
3 set -e
4 set -x
5
6 WC_INPUT=/wc_input
7 WC_OUTPUT=/wc_output
8 DATA_INPUT=$(mktemp -d)
9
10 echo "starting hadoop-wordcount test"
11
12 # bail if $TESTDIR is not set as this test will fail in that scenario
13 [ -z $TESTDIR ] && { echo "\$TESTDIR needs to be set, but is not. Exiting."; exit 1; }
14
15 # if HADOOP_PREFIX is not set, use default
16 [ -z $HADOOP_PREFIX ] && { HADOOP_PREFIX=$TESTDIR/hadoop; }
17
18 # Nuke hadoop directories
19 $HADOOP_PREFIX/bin/hadoop fs -rm -r $WC_INPUT $WC_OUTPUT || true
20
21 # Fetch and import testing data set
22 curl http://download.ceph.com/qa/hadoop_input_files.tar | tar xf - -C $DATA_INPUT
23 $HADOOP_PREFIX/bin/hadoop fs -copyFromLocal $DATA_INPUT $WC_INPUT
24 rm -rf $DATA_INPUT
25
26 # Run the job
27 $HADOOP_PREFIX/bin/hadoop jar \
28   $HADOOP_PREFIX/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar \
29   wordcount $WC_INPUT $WC_OUTPUT
30
31 # Cleanup
32 $HADOOP_PREFIX/bin/hadoop fs -rm -r $WC_INPUT $WC_OUTPUT || true
33
34 echo "completed hadoop-wordcount test"
35 exit 0