forked from Ducharme/infraAsCodeShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_perf_test.sh
More file actions
129 lines (106 loc) · 3.99 KB
/
run_perf_test.sh
File metadata and controls
129 lines (106 loc) · 3.99 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
DELETE_REDISEARCH="FALSE"
DELETE_CONSUMER="FALSE"
DEPLOY_REDISEARCH="FALSE"
DEPLOY_CONSUMER="FALSE"
FLUSH_DATA="TRUE"
START_TEST="TRUE"
GET_RESULTS="TRUE"
YML_REDIDEARCH=eks/tmp_redisearch_service.yml
YML_CONSUMER=eks/tmp_sqsconsumers.yml
YML_DEVICE=eks/tmp_devices-extreme_deployment.yml
MAX_TIME=120
create_deployment()
{
NAME=$1
APP=$2
WAIT=$3
YML=$4
echo "Apply $NAME started"
echo "Calling kubectl apply -f $YML"
kubectl apply -f $YML
if [ "$WAIT" = "TRUE" ]; then
echo "Apply request sent, waiting"
kubectl wait pods -n default -l app=$APP --for condition=Ready --timeout=60s
echo "Apply request completed, finished waiting"
fi
echo "Apply $NAME completed"
echo ""
}
delete_deployment()
{
NAME=$1
APP=$2
WAIT=$3
YML=$4
echo "Delete $NAME started"
CMD_OUTPUT=$(kubectl get deploy | grep $NAME)
if [ ! -z "$CMD_OUTPUT" ]; then
echo "Calling kubectl delete -f $YML"
kubectl delete -f $YML
if [ "$WAIT" = "TRUE" ]; then
echo "Delete request sent, waiting"
kubectl wait pods -n default -l app=$APP --for condition=delete --timeout=60s
echo "Delete request completed, finished waiting"
fi
fi
echo "Delete $NAME completed"
echo ""
}
if [ "$DELETE_REDISEARCH" = "TRUE" ]; then
delete_deployment redisearch redisearch "TRUE" $YML_REDIDEARCH
fi
if [ "$DELETE_CONSUMER" = "TRUE" ]; then
delete_deployment lafleet-consumers consumers "TRUE" $YML_CONSUMER
fi
if [ "$DEPLOY_REDISEARCH" = "TRUE" ]; then
create_deployment redisearch redisearch-app "TRUE" $YML_REDIDEARCH
sleep 5
fi
if [ "$DEPLOY_REDISEARCH" = "TRUE" ] || [ "$FLUSH_DATA" = "TRUE" ]; then
echo "Start flushing data from redisearch"
POD_NAME=$(kubectl get pods -o json | jq '.items[] | select(.spec.containers[0].name == "redisearch") | .metadata.name' | tr -d '"')
INDEX_H3="FT.CREATE topic-h3-idx ON HASH PREFIX 1 DEVLOC: SCHEMA topic TEXT h3r0 TAG h3r1 TAG h3r2 TAG h3r3 TAG h3r4 TAG h3r5 TAG h3r6 TAG h3r7 TAG h3r8 TAG h3r9 TAG h3r10 TAG h3r11 TAG h3r12 TAG h3r13 TAG h3r14 TAG h3r15 TAG dts NUMERIC batt NUMERIC fv TEXT"
INDEX_LOC="FT.CREATE topic-lnglat-idx ON HASH PREFIX 1 DEVLOC: SCHEMA topic TEXT lnglat GEO dts NUMERIC batt NUMERIC fv TEXT"
# Note: do not quote the INDEX env var
kubectl exec $POD_NAME -- redis-cli "FLUSHALL"
echo "Start creating redisearch indexes"
kubectl exec $POD_NAME -- redis-cli $INDEX_H3
kubectl exec $POD_NAME -- redis-cli $INDEX_LOC
echo "Finished creating redisearch indexes"
echo ""
fi
if [ "$DEPLOY_CONSUMER" = "TRUE" ]; then
create_deployment lafleet-consumers consumers-app "TRUE" $YML_CONSUMER
fi
if [ "$START_TEST" = "TRUE" ]; then
echo "Starting test"
sleep 5
DEV_INT=$(cat $YML_DEVICE | yq '.spec.template.spec.containers[0].env[] | select (.name == "INTERVAL") | .value')
DEV_CNT=$(cat $YML_DEVICE | yq '.spec.template.spec.containers[0].env[] | select (.name == "COUNT") | .value')
TIME=$(($DEV_INT * $DEV_CNT / 1000))
echo "Expected time to complete: $TIME seconds (0 means infinite)"
echo "Maximum time allowed is: $MAX_TIME seconds"
create_deployment devices devices "TRUE" $YML_DEVICE
if [ "$TIME" = "0" ]; then
echo "Sleeping: $MAX_TIME seconds"
sleep $MAX_TIME
elif [ $TIME -gt $MAX_TIME ]; then
echo "Sleeping: $MAX_TIME seconds"
sleep $MAX_TIME
else
WAIT_TIME=$(($TIME - 20))
echo "Sleeping: $WAIT_TIME seconds (shorter than $TIME to avoid restarts)"
sleep $WAIT_TIME
fi
delete_deployment devices devices "FALSE" $YML_DEVICE
fi
if [ "$GET_RESULTS" = "TRUE" ]; then
NODESELECTOR='{ "apiVersion": "v1", "spec": { "template": { "spec": { "nodeSelector": { "nodegroup-type": "backend-standard" } } } } }'
CMD_OUTPUT=$(kubectl get po | grep curl)
if [ -z "$CMD_OUTPUT" ]; then
kubectl run curl --image=radial/busyboxplus:curl -i --rm --tty --overrides="$NODESELECTOR"
kubectl wait pods -n default -l run=curl --for condition=Ready --timeout=60s
fi
kubectl exec curl -- curl -s -X POST -H "Content-Type: text/html" http://analytics-service/devices/stats
fi