-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
run_test.sh
executable file
·58 lines (51 loc) · 1.24 KB
/
run_test.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
if [ -z "$1" ]; then
echo "Specify watch name e.g. run_test.sh <foldername>"
exit 1
fi
username=elastic
if [ "$2" ] ; then
username="$2"
fi
password=changeme
if [ "$3" ] ; then
password="$3"
fi
port=9200
endpoint=localhost
if [ "$4" ] ; then
if ":" in "$4"; then
endpoint=${4%":"*} # extract the host value from the provided endpoint
port=${4#*":"} # extract the port value if provided in endpoint:port format
if [ "$port" == "" ]; then
# if port is blank, due to endpoint provided as localhost: or no port provided then use default port
port=9200
fi
else
endpoint=$4
fi
fi
protocol=http
if [ "$5" ] ; then
protocol=$5
fi
num_tests=0
pass=0
fails=0
echo "--------------------------------------------------"
# shellcheck disable=SC2231
for test in $1/tests/*.json; do
echo "Running test $test"
if python3 run_test.py --user "$username" --password "$password" --endpoint "$endpoint" --port "$port" --protocol "$protocol" --test_file "$test"; then
pass=$(( pass+1 ))
else
fails=$(( fails+1 ))
fi
num_tests=$(( num_tests+1 ))
echo "--------------------------------------------------"
done
echo "$num_tests tests run: $pass passed. $fails failed."
if [ $fails -eq 0 ]; then
exit 0
else
exit 1
fi