forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·99 lines (81 loc) · 2.42 KB
/
run
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
#!/bin/bash
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
ROOT=$(cd $HERE/../..; pwd)
READIES=$ROOT/deps/readies
(( VERBOSE > 1 )) && { set -x; PS4='$LINENO: '; }
if [[ $1 == --help || $1 == help ]]; then
cat <<-END
Invoke QA Automation tests
[ARGVARS...] run [--help|help]
Argument variables:
QA_AUTOMATION_TOKEN=token QA automation (Opereto) token
TEST=name Name of .json parameters file
MODULE_VERSION=ver Module version to test. Default: master
NOP=1 Do not execute automation command
VERBOSE=N Set verbosity level (N=1,2)
QUICK=1 Only test one RS version
Other configuration:
RS_VERSIONS file includes Redis Enterprive versions for release tests.
END
exit 0
fi
export RS_MODULE=ReJSON
export RS_MODULE_FILE_PREFIX=rejson
if [[ -z $QA_AUTOMATION_TOKEN && $NOP != 1 ]]; then
echo "Variable QA_AUTOMATION_TOKEN is undefined." >&2
exit 1
fi
export TEST=${TEST:-release}
if [[ ! -f $HERE/$TEST.json ]]; then
echo "Invalid TEST name: $TEST" >&2
exit 1
fi
run_test() {
export RS_VERSION=$1
if [[ -z $MODULE_VERSION ]]; then
export MODULE_VERSION=master
else
export MODULE_VERSION=$(echo "$MODULE_VERSION" | sed 's/^v\(.*\)/\1/')
fi
results() {
echo "$JSON" | jq "$1" | cut -d\" -f2
}
cd $HERE
json_in=$(mktemp /tmp/$TEST.json.XXXX)
$READIES/bin/xtx -e RS_MODULE -e RS_MODULE_FILE_PREFIX -e MODULE_VERSION -e RS_VERSION $TEST.json > $json_in
(( VERBOSE >= 1 )) && cat $json_in
if [[ $NOP == 1 ]]; then
echo "Testing RS $RS_VERSION"
return 0
fi
OPERETO3_URL="opereto.qa.redislabs.com"
JSON=$(curl -sk \
-X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer $QA_AUTOMATION_TOKEN" \
-d @$json_in \
https://$OPERETO3_URL/processes 2>&1)
rc=$?
rm $json_in
status=$(results .status)
if [[ $rc == 0 && $status == success ]]; then
id=$(results .data[0])
echo "Tests running on $MODULE_VERSION for RS $RS_VERSION"
echo "Results: https://$OPERETO3_URL/ui#dashboard/flow/$id"
return 0
else
err=$(results .message)
echo "Failed to run tests on $MODULE_VERSION for RS $RS_VERSION: $err"
return 1
fi
}
rc=0
if [[ $QUICK == 1 ]]; then
RS_VERSIONS=$(cat $HERE/RS_VERSIONS | head -1)
else
RS_VERSIONS=$(cat $HERE/RS_VERSIONS)
fi
for RS_VERSION in $RS_VERSIONS; do
run_test $RS_VERSION
[[ $? != 0 && $rc == 0 ]] && rc=$?
done
exit $rc