This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbehatcloud.sh
executable file
·78 lines (59 loc) · 2.73 KB
/
behatcloud.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
#!/bin/bash
source envrc
WORKSPACE=/mnt/ramdisk/code
#check if this version has behat
moodleversion=$(grep "\$release" $WORKSPACE/version.php | awk '{print $3}' | sed "s/'//g")
if [[ $moodleversion < 2.5 ]]
then
echo "No behat for this version of Moodle/Totara, so nothing to do :)"
exit
fi
echo "RUNNING BEHAT TESTS";
##
## SETUP
##
mkdir -p /mnt/ramdisk/sitedata/behat
mkdir -p /mnt/ramdisk/sitedata/site # some fake shiz that's needed
dropdb db-7000 > /dev/null 2>&1 # just in case ;)
createdb -E utf8 db-7000
#add selenium - no way to get most current version yet :( #todo
#wget --no-verbose http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar -O selenium-server-standalone.jar
#add composer
cd $WORKSPACE
curl http://getcomposer.org/installer | php
php composer.phar config github-oauth.github.com $GITHUB_TOKEN # to deal with github limits
#add config
cp $HOME/config.php $WORKSPACE/.
#set up behat
php $WORKSPACE/admin/tool/behat/cli/init.php || exit 1
###
### Start services
###
# start selenium server
# use xvfb for running selenium/browser headlessly on a specified display
# fire up the hub
nohup java -jar $HOME/selenium-server-standalone.jar -role hub -browserTimeout 1000 > /dev/null 2>&1 & echo $!
sleep 15
# fire up the nodes
NODECOUNT=`nproc`
HUB='http://localhost:4444/grid/register'
for node in $(seq 1 $NODECOUNT); do
NUMDISPLAY=$((10 + $node))
PORT=$((5555 + $node))
echo "Starting Xvfb on display $NUMDISPLAY..."
Xvfb :$NUMDISPLAY -ac > /dev/null 2>&1 & echo $!
echo "Starting selenium node on port $PORT"
# use ramdisk, as this will create the browser profile in ram
#DISPLAY=:$NUMDISPLAY nohup java -Djava.io.tmpdir=/mnt/ramdisk -jar $HOME/selenium-server-standalone.jar -role node -hub $HUB -port $PORT -timeout 0 -maxSession 1 -browserSessionReuse -Dwebdriver.chrome.driver=$HOME/chromedriver > /dev/null 2>&1 & echo $!
DISPLAY=:$NUMDISPLAY nohup java -Djava.io.tmpdir=/mnt/ramdisk -jar $HOME/selenium-server-standalone.jar -role node -hub $HUB -port $PORT -timeout 0 -maxSession 1 -browserTimeout 1000 -browserSessionReuse > /dev/null 2>&1 & echo $!
sleep 5
done
###
### Run tests
###
echo "RUNNING BEHAT TESTS"
# find all feature files - make sure the biggest tests get run first, to ensure max cpu utilisation
#find $WORKSPACE ! -path "$WORKSPACE/vendor/*" -type f -name '*.feature' -printf '%s %p\n' | sort -rn | awk '{print $2}' | parallel --jobs 60% --delay 7 bash $HOME/testbehatfeature.sh {}
# only run the @catalyst tagged tests
find $WORKSPACE ! -path "$WORKSPACE/vendor/*" -type f -name '*.feature' -printf '%s %p\n' | sort -rn | awk '{print $2}' | xargs grep -l "@catalyst" | parallel --jobs 60% --delay 7 bash $HOME/testbehatfeature.sh {}
exit $?