|
| 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 | + |
| 117 | +echo "TEST SUITE FINISHED" |
0 commit comments