-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparallelBehat.sh
More file actions
executable file
·70 lines (59 loc) · 2.33 KB
/
Copy pathparallelBehat.sh
File metadata and controls
executable file
·70 lines (59 loc) · 2.33 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
#!/usr/bin/env bash
echo "============================================="
echo "| BEHAT PARALLELISM TEST DISPATCHER SCRIPT |"
echo "============================================="
echo "by Leny Bernard (Troopers) |"
echo ""
if [ -z "$TEST_PARALLELISM_CONTAINER_TOTAL" ]; then
echo "No parrallelism found, setting defaults to run all tests."
TEST_PARALLELISM_CONTAINER_TOTAL=1
fi
if [ -z $1 ] || [ $1 -le 0 ]
then
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "TO MAKE PARRALELISM WORK, YOU NEED TO PASS THE CONTAINER ID (integer)"
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
containerIndex=1
TEST_PARALLELISM_CONTAINER_TOTAL=1
else
containerIndex=$1
fi
echo "Container $containerIndex/$TEST_PARALLELISM_CONTAINER_TOTAL"
# Don't rely on default order
# http://serverfault.com/questions/181787/find-command-default-sorting-order/181815#181815
availableScenarios=($(cat var/scenarios))
let "scenarioCount = ${#availableScenarios[@]}"
echo "$scenarioCount features found"
let "scenariosToRunCount = scenarioCount / TEST_PARALLELISM_CONTAINER_TOTAL"
let "modulo = scenarioCount % TEST_PARALLELISM_CONTAINER_TOTAL"
if [ "$modulo" -ne 0 ]; then
let "scenariosToRunCount += 1"
fi
fromScenarioIndex=1
let "toScenarioIndex = (scenariosToRunCount) * containerIndex - 1"
let "fromScenarioIndex = toScenarioIndex - scenariosToRunCount + 1"
echo "$scenariosToRunCount features to run here [$fromScenarioIndex-$toScenarioIndex]"
echo "scenarios:"
scenariosToRun=()
for ((i=0; i < ${#availableScenarios[@]}; i++)); do
if [ "$i" -ge $fromScenarioIndex ] && [ "$i" -le $toScenarioIndex ]; then
echo "- ${availableScenarios[$i]}"
scenariosToRun+=(${availableScenarios[$i]})
fi
done
# Calculate sum of return codes in order to detect errors
# http://stackoverflow.com/questions/6348902/how-can-i-add-numbers-in-a-bash-script/6348945#6348945
sum=0
if [ "${#scenariosToRun[@]}" -gt 0 ]; then
for ((i=0; i < ${#scenariosToRun[@]}; i++)); do
echo "bin/behat -vv ${scenariosToRun[$i]}"
time bin/behat -vv ${scenariosToRun[$i]}
return=$?
echo "return code = ${return}"
sum=$(( $sum + $return ))
done
else
echo "No test to run (issue related to modulo)"
fi
echo "sum of Behat return codes = ${sum}"
exit $sum