forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_env.sh
executable file
·89 lines (74 loc) · 2.39 KB
/
setup_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
set -o verbose
MINIKDC_VERSION=2.7.1
HADOOP_DISTRO=${HADOOP_DISTRO:-"hdp"}
ONLY_DOWNLOAD=${ONLY_DOWNLOAD:-false}
ONLY_EXTRACT=${ONLY_EXTRACT:-false}
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "Setup environment for airflow tests"
echo " "
echo "options:"
echo -e "\t-h, --help show brief help"
echo -e "\t-o, --only-download just download hadoop tar(s)"
echo -e "\t-e, --only-extract just extract hadoop tar(s)"
echo -e "\t-d, --distro select distro (hdp|cdh)"
exit 0
;;
-o|--only-download)
shift
ONLY_DOWNLOAD=true
;;
-e|--only-extract)
shift
ONLY_EXTRACT=true
;;
-d|--distro)
shift
if test $# -gt 0; then
HADOOP_DISTRO=$1
else
echo "No Hadoop distro specified - abort" >&2
exit 1
fi
shift
;;
*)
echo "Unknown options: $1" >&2
exit 1
;;
esac
done
HADOOP_HOME=/tmp/hadoop-${HADOOP_DISTRO}
if $ONLY_DOWNLOAD && $ONLY_EXTRACT; then
echo "Both only-download and only-extract specified - abort" >&2
exit 1
fi
mkdir -p ${HADOOP_HOME}
mkdir -p ${TRAVIS_CACHE}/${HADOOP_DISTRO}
if [ $HADOOP_DISTRO = "cdh" ]; then
URL="http://archive.cloudera.com/cdh5/cdh/5/hadoop-latest.tar.gz"
elif [ $HADOOP_DISTRO = "hdp" ]; then
URL="http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0/tars/hadoop-2.2.0.2.0.6.0-76.tar.gz"
else
echo "No/bad HADOOP_DISTRO='${HADOOP_DISTRO}' specified" >&2
exit 1
fi
if ! $ONLY_EXTRACT; then
echo "Downloading Hadoop from $URL to ${TRAVIS_CACHE}/${HADOOP_DISTRO}/hadoop.tar.gz"
curl -z ${TRAVIS_CACHE}/${HADOOP_DISTRO}/hadoop.tar.gz -o ${TRAVIS_CACHE}/${HADOOP_DISTRO}/hadoop.tar.gz -L $URL
if [ $? != 0 ]; then
echo "Failed to download Hadoop from $URL - abort" >&2
exit 1
fi
fi
if $ONLY_DOWNLOAD; then
exit 0
fi
echo "Extracting ${HADOOP_HOME}/hadoop.tar.gz into $HADOOP_HOME"
tar zxf ${TRAVIS_CACHE}/${HADOOP_DISTRO}/hadoop.tar.gz --strip-components 1 -C $HADOOP_HOME
if [ $? != 0 ]; then
echo "Failed to extract Hadoop from ${HADOOP_HOME}/hadoop.tar.gz to ${HADOOP_HOME} - abort" >&2
exit 1
fi