This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscaleup.sh
executable file
·105 lines (96 loc) · 3 KB
/
scaleup.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
# RackN Copyright 2020
# Build Manager Demo
set -e
PATH=$PATH:.
export RS_ENDPOINT=$(terraform output drp_manager)
REMOVE="false"
MANAGER="false"
SCALE=10
while getopts ":s:r" CmdLineOpts
do
case $CmdLineOpts in
r) REMOVE="true" ;;
s) SCALE=${OPTARG} ;;
u) usage; exit 0 ;;
\?)
echo "Incorrect usage. Invalid flag '${OPTARG}'."
exit 1
;;
esac
done
icons=$(drpcli version_sets show site-base-tip | jq '.Global["dev/wait-icons"]')
if drpcli profiles set global param "dev/wait-icons" to - <<< $icons > /dev/null ; then
echo "setting icons"
else
echo "icons already set"
fi
if [ "$REMOVE" != "true" ] ; then
echo "First, checking for stuck machines"
stuck=$(drpcli machines list WorkflowComplete=false Runnable=true | jq -r .[].Name)
for x in $stuck; do
echo " poking $x"
drpcli machines meta remove Name:$x param "BaseContext" || true >/dev/null 2>/dev/null
drpcli machines update Name:$x '{"Context":"" }' > /dev/null
drpcli machines update Name:$x '{"Context":"drpcli-runner"}' > /dev/null
done
fi
sites=$(drpcli endpoints list Apply Eq true | jq -r .[].Id)
echo "sites set to: $sites"
echo "create $SCALE load test machines"
i=1
while (( i < SCALE )); do
mc=$(printf "scale-%05d-manager" $i)
if drpcli machines exists Name:$mc &> /dev/null ; then
if [ "$REMOVE" == "true" ] ; then
echo "removing machine $mc."
drpcli machines destroy Name:${mc} >/dev/null
else
echo "machine $mc already exists. restarting load-generator"
drpcli machines workflow Name:${mc} "load-generator" >/dev/null
fi
else
if [ "$REMOVE" != "true" ] ; then
if [ "$MANAGER" == "true" ] ; then
echo "creating $mc in manager"
sleep 1
drpcli machines create "{\"Name\":\"${mc}\", \
\"Workflow\":\"load-generator\", \
\"Description\":\"Load Test $i\", \
\"Meta\":{\"BaseContext\":\"drpcli-runner\", \"icon\":\"cloud\"}}" >/dev/null
else
echo "not creating manager machine $mc (start with -m to include manager)"
fi
else
echo "skipping, $mc does not exist"
fi
fi
for s in $sites;
do
(
mc=$(printf "scale-%05d-$s" $i)
if drpcli -u $s machines exists Name:$mc &> /dev/null ; then
if [ "$REMOVE" == "true" ] ; then
echo "removing machine $mc."
drpcli -u $s machines destroy Name:${mc} >/dev/null
else
echo "machine $mc already exists. restarting load-generator"
drpcli -u $s machines workflow Name:${mc} "load-generator" >/dev/null
fi
else
if [ "$REMOVE" != "true" ] ; then
echo "creating $mc in $s"
sleep 1
drpcli -u $s machines create "{\"Name\":\"${mc}\", \
\"Workflow\":\"load-generator\", \
\"Description\":\"Load Test $i\", \
\"Meta\":{\"BaseContext\":\"drpcli-runner\", \"icon\":\"cloud\"}}" >/dev/null
else
echo "skipping, $mc does not exist"
fi
fi
) &
done
(( i++ ))
done
wait