forked from gussy-dre/TuningContest2024inHiroshima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·47 lines (39 loc) · 1.39 KB
/
run.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
#!/bin/bash
# ==================================
# リストア・マイグレーション・e2eテスト・負荷試験・採点の順で実施してくれるスクリプト。
# ==================================
(cd benchmarker && bash restore_and_migration.sh)
if [ $? -ne 0 ]; then
echo "採点フローを中断します。"
exit 1
fi
# e2eテスト
if [[ $HOSTNAME == env-* ]]; then
(cd benchmarker && ./e2e.sh)
if [ $? -ne 0 ]; then
echo "採点フローを中断します。"
exit 1
fi
fi
fileName=`date "+%Y%m%d_%H%M%S"`
# 負荷試験 & 採点開始
(cd benchmarker && ./run_k6_and_score.sh $fileName)
if [ $? -ne 0 ]; then
echo "採点フローを中断します。"
exit 1
fi
if [[ $HOSTNAME != env-* ]]; then
exit 0
fi
echo "サーバーへスコアを送信します。"
requestBody=`cat ./benchmarker/score/${fileName}.json | awk '{print substr($0, 2, length($0)-2)}'`
key=`cat ./.da/funcKey`
repo=`cat /.da/cloneUrl`
version="v2"
statusCode=`curl -o /dev/null -w '%{http_code}\n' -s -X POST -d '{"hostname": "'$HOSTNAME'", "repo": "'$repo'","version": "'$version'", '$requestBody'}' "https://ftt2306.azurewebsites.net/api/HttpTrigger1?code=${key}"`
if [ $statusCode = "200" ]; then
echo "スコアの送信に成功しました。"
else
echo "スコアの送信に失敗しました。メンターに報告してください。"
exit 1
fi