Skip to content

Commit 8c067af

Browse files
committed
Moves all integration test setup logic to Maven and scripts.
The Kubernetes integration tests now always expect an image to be pre-built, so we no longer build images with Scala code. Maven's pre-integration-test invokes a single script to bootstrap the environment with the built images, etc. In the transition we try to keep as much of the same semantics as possible.
1 parent 1d7f36c commit 8c067af

29 files changed

+527
-462
lines changed

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
.idea/
22
spark/
3-
spark
4-
integration-test/target/
3+
spark-dist
4+
target/
5+
build/*.jar
6+
build/apache-maven*
7+
build/scala*
8+
build/zinc*
59
*.class
610
*.log
711
*.iml
12+
*.swp

build/mvn

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# Determine the current working directory
21+
_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22+
# Preserve the calling directory
23+
_CALLING_DIR="$(pwd)"
24+
# Options used during compilation
25+
_COMPILE_JVM_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m"
26+
27+
# Installs any application tarball given a URL, the expected tarball name,
28+
# and, optionally, a checkable binary path to determine if the binary has
29+
# already been installed
30+
## Arg1 - URL
31+
## Arg2 - Tarball Name
32+
## Arg3 - Checkable Binary
33+
install_app() {
34+
local remote_tarball="$1/$2"
35+
local local_tarball="${_DIR}/$2"
36+
local binary="${_DIR}/$3"
37+
38+
# setup `curl` and `wget` silent options if we're running on Jenkins
39+
local curl_opts="-L"
40+
local wget_opts=""
41+
if [ -n "$AMPLAB_JENKINS" ]; then
42+
curl_opts="-s ${curl_opts}"
43+
wget_opts="--quiet ${wget_opts}"
44+
else
45+
curl_opts="--progress-bar ${curl_opts}"
46+
wget_opts="--progress=bar:force ${wget_opts}"
47+
fi
48+
49+
if [ -z "$3" -o ! -f "$binary" ]; then
50+
# check if we already have the tarball
51+
# check if we have curl installed
52+
# download application
53+
[ ! -f "${local_tarball}" ] && [ $(command -v curl) ] && \
54+
echo "exec: curl ${curl_opts} ${remote_tarball}" 1>&2 && \
55+
curl ${curl_opts} "${remote_tarball}" > "${local_tarball}"
56+
# if the file still doesn't exist, lets try `wget` and cross our fingers
57+
[ ! -f "${local_tarball}" ] && [ $(command -v wget) ] && \
58+
echo "exec: wget ${wget_opts} ${remote_tarball}" 1>&2 && \
59+
wget ${wget_opts} -O "${local_tarball}" "${remote_tarball}"
60+
# if both were unsuccessful, exit
61+
[ ! -f "${local_tarball}" ] && \
62+
echo -n "ERROR: Cannot download $2 with cURL or wget; " && \
63+
echo "please install manually and try again." && \
64+
exit 2
65+
cd "${_DIR}" && tar -xzf "$2"
66+
rm -rf "$local_tarball"
67+
fi
68+
}
69+
70+
# Determine the Maven version from the root pom.xml file and
71+
# install maven under the build/ folder if needed.
72+
install_mvn() {
73+
local MVN_VERSION=`grep "<maven.version>" "${_DIR}/../pom.xml" | head -n1 | awk -F '[<>]' '{print $3}'`
74+
echo $MVN_VERSION
75+
MVN_BIN="$(command -v mvn)"
76+
if [ "$MVN_BIN" ]; then
77+
local MVN_DETECTED_VERSION="$(mvn --version | head -n1 | awk '{print $3}')"
78+
fi
79+
# See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
80+
function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
81+
if [ $(version $MVN_DETECTED_VERSION) -lt $(version $MVN_VERSION) ]; then
82+
local APACHE_MIRROR=${APACHE_MIRROR:-'https://www.apache.org/dyn/closer.lua?action=download&filename='}
83+
84+
install_app \
85+
"${APACHE_MIRROR}/maven/maven-3/${MVN_VERSION}/binaries" \
86+
"apache-maven-${MVN_VERSION}-bin.tar.gz" \
87+
"apache-maven-${MVN_VERSION}/bin/mvn"
88+
89+
MVN_BIN="${_DIR}/apache-maven-${MVN_VERSION}/bin/mvn"
90+
fi
91+
}
92+
93+
# Install zinc under the build/ folder
94+
install_zinc() {
95+
local zinc_path="zinc-0.3.15/bin/zinc"
96+
[ ! -f "${_DIR}/${zinc_path}" ] && ZINC_INSTALL_FLAG=1
97+
local TYPESAFE_MIRROR=${TYPESAFE_MIRROR:-https://downloads.typesafe.com}
98+
99+
install_app \
100+
"${TYPESAFE_MIRROR}/zinc/0.3.15" \
101+
"zinc-0.3.15.tgz" \
102+
"${zinc_path}"
103+
ZINC_BIN="${_DIR}/${zinc_path}"
104+
}
105+
106+
# Determine the Scala version from the root pom.xml file, set the Scala URL,
107+
# and, with that, download the specific version of Scala necessary under
108+
# the build/ folder
109+
install_scala() {
110+
# determine the Scala version used in Spark
111+
local scala_version=`grep "scala.version" "${_DIR}/../pom.xml" | head -n1 | awk -F '[<>]' '{print $3}'`
112+
local scala_bin="${_DIR}/scala-${scala_version}/bin/scala"
113+
local TYPESAFE_MIRROR=${TYPESAFE_MIRROR:-https://downloads.typesafe.com}
114+
115+
install_app \
116+
"${TYPESAFE_MIRROR}/scala/${scala_version}" \
117+
"scala-${scala_version}.tgz" \
118+
"scala-${scala_version}/bin/scala"
119+
120+
SCALA_COMPILER="$(cd "$(dirname "${scala_bin}")/../lib" && pwd)/scala-compiler.jar"
121+
SCALA_LIBRARY="$(cd "$(dirname "${scala_bin}")/../lib" && pwd)/scala-library.jar"
122+
}
123+
124+
# Setup healthy defaults for the Zinc port if none were provided from
125+
# the environment
126+
ZINC_PORT=${ZINC_PORT:-"3030"}
127+
128+
# Remove `--force` for backward compatibility.
129+
if [ "$1" == "--force" ]; then
130+
echo "WARNING: '--force' is deprecated and ignored."
131+
shift
132+
fi
133+
134+
# Install the proper version of Scala, Zinc and Maven for the build
135+
install_zinc
136+
install_scala
137+
install_mvn
138+
139+
# Reset the current working directory
140+
cd "${_CALLING_DIR}"
141+
142+
# Now that zinc is ensured to be installed, check its status and, if its
143+
# not running or just installed, start it
144+
if [ -n "${ZINC_INSTALL_FLAG}" -o -z "`"${ZINC_BIN}" -status -port ${ZINC_PORT}`" ]; then
145+
export ZINC_OPTS=${ZINC_OPTS:-"$_COMPILE_JVM_OPTS"}
146+
"${ZINC_BIN}" -shutdown -port ${ZINC_PORT}
147+
"${ZINC_BIN}" -start -port ${ZINC_PORT} \
148+
-scala-compiler "${SCALA_COMPILER}" \
149+
-scala-library "${SCALA_LIBRARY}" &>/dev/null
150+
fi
151+
152+
# Set any `mvn` options if not already present
153+
export MAVEN_OPTS=${MAVEN_OPTS:-"$_COMPILE_JVM_OPTS"}
154+
155+
echo "Using \`mvn\` from path: $MVN_BIN" 1>&2
156+
157+
# Last, call the `mvn` command as usual
158+
${MVN_BIN} -DzincPort=${ZINC_PORT} "$@"

e2e/e2e-prow.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

e2e/runner.sh

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)