|
| 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 | +# 1. Clear the existing CRDs before staring the benchmark |
| 21 | +echo "CLEAN UP NAMESPACE FOR BENCHMARK" |
| 22 | +kubectl get sparkapplications.spark.apache.org -o name | xargs kubectl delete |
| 23 | + |
| 24 | +NUM="${1:-1000}" |
| 25 | +echo "START BENCHMARK WITH $NUM JOBS" |
| 26 | + |
| 27 | +# 2. Creation Benchmark |
| 28 | +filename=$(mktemp) |
| 29 | + |
| 30 | +for i in $(seq -f "%05g" 1 $NUM); do |
| 31 | + cat << EOF >> $filename |
| 32 | +apiVersion: spark.apache.org/v1beta1 |
| 33 | +kind: SparkApplication |
| 34 | +metadata: |
| 35 | + name: test-${i} |
| 36 | +spec: |
| 37 | + mainClass: "org.apache.spark.examples.DriverSubmissionTest" |
| 38 | + jars: "local:///opt/spark/examples/jars/spark-examples.jar" |
| 39 | + driverArgs: ["0"] |
| 40 | + sparkConf: |
| 41 | + spark.kubernetes.driver.request.cores: "100m" |
| 42 | + spark.kubernetes.driver.request.memory: "100Mi" |
| 43 | + spark.kubernetes.driver.master: "local[1]" |
| 44 | + spark.kubernetes.authenticate.driver.serviceAccountName: "spark" |
| 45 | + spark.kubernetes.container.image: "apache/spark:4.0.0" |
| 46 | + runtimeVersions: |
| 47 | + sparkVersion: "4.0.0" |
| 48 | +--- |
| 49 | +EOF |
| 50 | +done |
| 51 | + |
| 52 | +start=`date +%s` |
| 53 | +kubectl apply -f $filename > /dev/null |
| 54 | +while [ $(kubectl get sparkapplications.spark.apache.org | grep ResourceReleased | wc -l) -lt $NUM ] |
| 55 | +do |
| 56 | + sleep 1 |
| 57 | +done |
| 58 | +end=`date +%s` |
| 59 | +completionTime=$((end - start)) |
| 60 | +echo "FINISHED $NUM JOBS IN $completionTime SECONDS." |
| 61 | + |
| 62 | +# 3. Deletion Benchmark |
| 63 | +start=`date +%s` |
| 64 | +kubectl get sparkapplications.spark.apache.org -o name | xargs kubectl delete > /dev/null |
| 65 | +end=`date +%s` |
| 66 | +deletionTime=$((end - start)) |
| 67 | +echo "DELETED $NUM JOBS IN $deletionTime SECONDS." |
0 commit comments