forked from camunda/camunda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecreateBenchmark.sh
executable file
·73 lines (60 loc) · 2.39 KB
/
recreateBenchmark.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
#!/bin/bash
set -eo pipefail
# The purpose of this script is to make it easier for developers to recreate benchmarks.
# As input the benchmark name is expected, which is used for the docker image tag and k8 namespace.
# This script does the following:
#
# 1. Build the current branch (zeebe + benchmark-project)
# 2. Build the docker images
# 3. Publish the docker images
# 4. Redeploys the benchmark
# Contains OS specific sed function
source benchmarks/setup/utils.sh
function printUsageAndExit {
printf "\nUsage ./createBenchmark <benchmark-name>\n"
exit 1
}
if [[ -z $1 ]]
then
echo "<benchmark-name> not provided"
printUsageAndExit
fi
benchmark=$1
pwd=$(pwd)
# DNS Label regex, see https://regex101.com/r/vjsrEy/2
if [[ ! $benchmark =~ ^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$ ]]; then
echo "<benchmark-name> '$benchmark' not a valid DNS label"
echo "See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names"
printUsageAndExit
fi
set +e
ns=$(kubectl get namespace "$benchmark")
set -e
if [[ ! "$ns" ]]; then
echo "Perhaps you meant to use ./createBenchmark.sh instead. Or consider switching your k8s context"
exit 1
fi
# Check if docker daemon is running
if ! docker info >/dev/null 2>&1; then
echo "Docker daemon does not seem to be running, make sure it's running and retry"
exit 1
fi
set -x
mvn clean install -DskipTests -DskipChecks -T1C
docker build --build-arg DISTBALL=dist/target/camunda-zeebe-*.tar.gz -t "gcr.io/zeebe-io/zeebe:$benchmark" --target app .
docker push "gcr.io/zeebe-io/zeebe:$benchmark"
cd "$pwd/benchmarks/project"
sed_inplace "s/:SNAPSHOT/:$benchmark/" docker-compose.yml
# Use --no-cache to force rebuild the image for the benchmark application. Without this changes to zeebe-client were not picked up. This can take longer to build.
docker-compose build --no-cache
docker-compose push
git restore -- docker-compose.yml
# Restart the pods by deleting them, this is not a rolling update
# `make update` would not restart the pods, but once they restart the new image will be pulled because of pullPolicy: Always
#
# TODO: apply rolling updates with helm
# see https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
kubectl -n "$benchmark" get pods -l app.kubernetes.io/name=zeebe-cluster-helm -o=jsonpath='{.items..metadata.name}' \
| xargs kubectl -n "$benchmark" delete pod
# Return where you started
cd "$pwd"