forked from kedacore/keda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-all.sh
executable file
·96 lines (82 loc) · 2.23 KB
/
run-all.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
#! /bin/bash
set -eu
DIR=$(dirname "$0")
cd $DIR
concurrent_tests_limit=10
pids=()
lookup=()
failed_count=0
failed_lookup=()
counter=0
function run_setup {
./node_modules/.bin/ava setup.test.ts
}
function run_tests {
counter=0
# randomize tests order using shuf
for test_case in $(find scalers -name "*.test.ts" | shuf)
do
counter=$((counter+1))
./node_modules/.bin/ava $test_case > "${test_case}.log" 2>&1 &
pid=$!
echo "Running $test_case with pid: $pid"
pids+=($pid)
lookup[$pid]=$test_case
# limit concurrent runs
if [[ "$counter" -gt "$concurrent_tests_limit" ]]; then
wait_for_jobs
counter=0
pids=()
fi
done
}
function mark_failed {
failed_lookup[$1]=${lookup[$1]}
let "failed_count+=1"
}
function wait_for_jobs {
for job in "${pids[@]}"; do
wait $job || mark_failed $job
echo "Job $job finished"
done
printf "\n$failed_count jobs failed\n"
printf '%s\n' "${failed_lookup[@]}"
}
function print_logs {
for test_log in $(find scalers -name "*.log")
do
echo ">>> $test_log <<<"
cat $test_log
printf "\n\n##############################################\n"
printf "##############################################\n\n"
done
echo ">>> KEDA Operator log <<<"
kubectl get pods --no-headers -n keda | awk '{print $1}' | grep keda-operator | xargs kubectl -n keda logs
printf "\n\n##############################################\n"
printf "##############################################\n\n"
echo ">>> KEDA Metrics Server log <<<"
kubectl get pods --no-headers -n keda | awk '{print $1}' | grep keda-metrics-apiserver | xargs kubectl -n keda logs
printf "\n\n##############################################\n"
printf "##############################################\n\n"
}
function run_cleanup {
./node_modules/.bin/ava cleanup.test.ts
}
function print_failed {
echo "$failed_count e2e tests failed"
for failed_test in "${failed_lookup[@]}"; do
echo $failed_test
done
}
run_setup
run_tests
wait_for_jobs
print_logs
run_cleanup
if [ "$failed_count" == "0" ];
then
exit 0
else
print_failed
exit 1
fi