Skip to content

Commit 3a2b4d8

Browse files
committed
Merge remote-tracking branch 'origin/master' into 'ifilonenko/master'
2 parents 7369772 + d5e7edb commit 3a2b4d8

File tree

7 files changed

+407
-41
lines changed

7 files changed

+407
-41
lines changed

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,45 @@ title: Spark on Kubernetes Integration Tests
66
# Running the Kubernetes Integration Tests
77

88
Note that the integration test framework is currently being heavily revised and
9-
is subject to change.
9+
is subject to change. Note that currently the integration tests only run with Java 8.
1010

11-
Note that currently the integration tests only run with Java 8.
11+
As shorthand to run the tests against any given cluster, you can use the `e2e/runner.sh` script.
12+
The script assumes that you have a functioning Kubernetes cluster (1.6+) with kubectl
13+
configured to access it. The master URL of the currently configured cluster on your
14+
machine can be discovered as follows:
15+
16+
```
17+
$ kubectl cluster-info
18+
19+
Kubernetes master is running at https://xyz
20+
```
21+
22+
If you want to use a local [minikube](https://github.com/kubernetes/minikube) cluster,
23+
the minimum tested version is 0.23.0, with the kube-dns addon enabled
24+
and the recommended configuration is 3 CPUs and 4G of memory. There is also a wrapper
25+
script for running on minikube, `e2e/e2e-minikube.sh` for testing the apache/spark repo
26+
in specific.
27+
28+
```
29+
$ minikube start --memory 4000 --cpus 3
30+
```
31+
32+
If you're using a non-local cluster, you must provide an image repository
33+
which you have write access to, using the `-i` option, in order to store docker images
34+
generated during the test.
35+
36+
Example usages of the script:
37+
38+
```
39+
$ ./e2e/runner.sh -m https://xyz -i docker.io/foxish -d cloud
40+
$ ./e2e/runner.sh -m https://xyz -i test -d minikube
41+
$ ./e2e/runner.sh -m https://xyz -i test -r https://github.com/my-spark/spark -d minikube
42+
43+
```
44+
45+
# Detailed Documentation
46+
47+
## Running the tests using maven
1248

1349
Integration tests firstly require installing [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/) on
1450
your machine, and for the `Minikube` binary to be on your `PATH`.. Refer to the Minikube documentation for instructions
@@ -44,16 +80,15 @@ $ mvn clean integration-test \
4480
-Dspark-distro-tgz=spark/spark-2.3.0-SNAPSHOT-bin.tgz
4581
```
4682

47-
# Running against an arbitrary cluster
83+
## Running against an arbitrary cluster
4884

4985
In order to run against any cluster, use the following:
5086
```sh
5187
$ mvn clean integration-test \
5288
-Dspark-distro-tgz=spark/spark-2.3.0-SNAPSHOT-bin.tgz \
5389
-DextraScalaTestArgs="-Dspark.kubernetes.test.master=k8s://https://<master>
54-
```
5590
56-
# Specify existing docker images via image:tag
91+
## Reuse the previous Docker images
5792
5893
The integration tests build a number of Docker images, which takes some time.
5994
By default, the images are built every time the tests run. You may want to skip

e2e/e2e-minikube.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
### This script can be used to run integration tests locally on minikube.
19+
### Requirements: minikube v0.23+ with the DNS addon enabled, and kubectl configured to point to it.
20+
21+
set -ex
22+
23+
### Basic Validation ###
24+
if [ ! -d "integration-test" ]; then
25+
echo "This script must be invoked from the top-level directory of the integration-tests repository"
26+
usage
27+
exit 1
28+
fi
29+
30+
# Set up config.
31+
master=$(kubectl cluster-info | head -n 1 | grep -oE "https?://[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]+)?")
32+
repo="https://github.com/apache/spark"
33+
image_repo=test
34+
35+
# Run tests in minikube mode.
36+
./e2e/runner.sh -m $master -r $repo -i $image_repo -d minikube

e2e/e2e-prow.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
### This script is used by Kubernetes Test Infrastructure to run integration tests.
19+
### See documenation at https://github.com/kubernetes/test-infra/tree/master/prow
20+
### To run the integration tests yourself, use e2e/runner.sh.
21+
22+
set -ex
23+
24+
# Install basic dependencies
25+
echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
26+
apt-get update && apt-get install -y curl wget git tar
27+
apt-get install -t jessie-backports -y openjdk-8-jdk
28+
29+
# Set up config.
30+
master=$(kubectl cluster-info | head -n 1 | grep -oE "https?://[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]+)?")
31+
repo="https://github.com/apache/spark"
32+
33+
# Special GCP project for publishing docker images built by test.
34+
image_repo="gcr.io/spark-testing-191023"
35+
cd "$(dirname "$0")"/../
36+
./e2e/runner.sh -m $master -r $repo -i $image_repo -d cloud
37+
38+
# Copy out the junit xml files for consumption by k8s test-infra.
39+
ls -1 ./integration-test/target/surefire-reports/*.xml | cat -n | while read n f; do cp "$f" "/workspace/_artifacts/junit_0$n.xml"; done

e2e/runner.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
usage () {
19+
echo "Usage:"
20+
echo " ./e2e/runner.sh -h Display this help message."
21+
echo " ./e2e/runner.sh -m <master-url> -r <spark-repo> -i <image-repo> -d [minikube|cloud]"
22+
echo " note that you must have kubectl configured to access the specified"
23+
echo " <master-url>. Also you must have access to the <image-repo>. "
24+
echo " The deployment mode can be specified using the 'd' flag."
25+
}
26+
27+
### Basic Validation ###
28+
if [ ! -d "integration-test" ]; then
29+
echo "This script must be invoked from the top-level directory of the integration-tests repository"
30+
usage
31+
exit 1
32+
fi
33+
34+
### Set sensible defaults ###
35+
REPO="https://github.com/apache/spark"
36+
IMAGE_REPO="docker.io/kubespark"
37+
DEPLOY_MODE="minikube"
38+
39+
### Parse options ###
40+
while getopts h:m:r:i:d: option
41+
do
42+
case "${option}"
43+
in
44+
h)
45+
usage
46+
exit 0
47+
;;
48+
m) MASTER=${OPTARG};;
49+
r) REPO=${OPTARG};;
50+
i) IMAGE_REPO=${OPTARG};;
51+
d) DEPLOY_MODE=${OPTARG};;
52+
\? )
53+
echo "Invalid Option: -$OPTARG" 1>&2
54+
exit 1
55+
;;
56+
esac
57+
done
58+
59+
### Ensure cluster is set.
60+
if [ -z "$MASTER" ]
61+
then
62+
echo "Missing master-url (-m) argument."
63+
echo ""
64+
usage
65+
exit
66+
fi
67+
68+
### Ensure deployment mode is minikube/cloud.
69+
if [[ $DEPLOY_MODE != minikube && $DEPLOY_MODE != cloud ]];
70+
then
71+
echo "Invalid deployment mode $DEPLOY_MODE"
72+
usage
73+
exit 1
74+
fi
75+
76+
echo "Running tests on cluster $MASTER against $REPO."
77+
echo "Spark images will be created in $IMAGE_REPO"
78+
79+
set -ex
80+
root=$(pwd)
81+
82+
# clone spark distribution if needed.
83+
if [ -d "spark" ];
84+
then
85+
(cd spark && git pull);
86+
else
87+
git clone $REPO;
88+
fi
89+
90+
cd spark && ./dev/make-distribution.sh --tgz -Phadoop-2.7 -Pkubernetes -DskipTests
91+
tag=$(git rev-parse HEAD | cut -c -6)
92+
echo "Spark distribution built at SHA $tag"
93+
94+
if [[ $DEPLOY_MODE == cloud ]] ;
95+
then
96+
cd dist && ./sbin/build-push-docker-images.sh -r $IMAGE_REPO -t $tag build
97+
if [[ $IMAGE_REPO == gcr.io* ]] ;
98+
then
99+
gcloud docker -- push $IMAGE_REPO/spark-driver:$tag && \
100+
gcloud docker -- push $IMAGE_REPO/spark-executor:$tag && \
101+
gcloud docker -- push $IMAGE_REPO/spark-init:$tag
102+
else
103+
./sbin/build-push-docker-images.sh -r $IMAGE_REPO -t $tag push
104+
fi
105+
else
106+
# -m option for minikube.
107+
cd dist && ./sbin/build-push-docker-images.sh -m -r $IMAGE_REPO -t $tag build
108+
fi
109+
110+
cd $root/integration-test
111+
$root/spark/build/mvn clean -Ddownload.plugin.skip=true integration-test \
112+
-Dspark-distro-tgz=$root/spark/*.tgz \
113+
-DextraScalaTestArgs="-Dspark.kubernetes.test.master=k8s://$MASTER \
114+
-Dspark.docker.test.driverImage=$IMAGE_REPO/spark-driver:$tag \
115+
-Dspark.docker.test.executorImage=$IMAGE_REPO/spark-executor:$tag \
116+
-Dspark.docker.test.initContainerImage=$IMAGE_REPO/spark-init:$tag" || :
117+
118+
echo "TEST SUITE FINISHED"

0 commit comments

Comments
 (0)