-
-
Save rajeshtaneja/e50e84d29d1d08361e80 to your computer and use it in GitHub Desktop.
Shell script for multiple behat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Number of parallel runs. | |
NUMBEROFPARALLELRUNS=20 | |
# Max parallel install. | |
MAXPARALLELINSTALL=20 | |
MAXDB=5 | |
# Github token to avoid authentication error. | |
GITHUBTOKEN=b19122cc44344bcb9ac5a2efc64efb323f901767 | |
# Moodle specific values | |
dbtype='pgsql' | |
dbhost='172.21.0.70' # 'localhost' | |
dbname='moodle' | |
dbuser='moodle' # 'postgres' | |
dbpass='moodle' # '' | |
wwwroot='http://moodle.test.local/moodle' | |
dataroot=$HOME'/moodledata' | |
behat_wwwroot='http://localhost:8000' | |
behat_dataroot=$HOME'/moodledata_behat' | |
behat_prefix='bht' | |
# Copy config-dist and modify values. | |
cp config-dist.php config.php | |
sed -i s/\'pgsql\'/\'$dbtype\'/ config.php | |
sed -i s/\'localhost\'/\'$dbhost\'/ config.php | |
sed -i s/\'moodle\'/\'$dbname\'/ config.php | |
sed -i s/\'username\'/\'$dbuser\'/ config.php | |
sed -i s/\'password\'/\'$dbpass\'/ config.php | |
sed -i s%\'http://example.com/moodle\'%\'$wwwroot\'% config.php | |
sed -i s%\'/home/example/moodledata\'%\'$dataroot\'% config.php | |
sed -i s/require.*setup.php.*// config.php | |
echo "\$CFG->behat_wwwroot = '$behat_wwwroot';" >> config.php | |
echo "\$CFG->behat_dataroot = '$behat_dataroot';" >> config.php | |
echo "\$CFG->behat_prefix = '$behat_prefix';" >> config.php | |
if [ -n "$NUMBEROFPARALLELRUNS" ]; then echo "\$CFG->behat_parallel_run = array(" >> config.php; fi | |
if [ -n "$NUMBEROFPARALLELRUNS" ]; then for ((i=1;i<=$NUMBEROFPARALLELRUNS;i+=1)); do DBSUFFIX=$(($i%$MAXDB+1)) && echo "array('dbname' => '$dbname$DBSUFFIX', 'behat_prefix' => '$behat_prefix$i')," >> config.php; done; fi | |
if [ -n "$NUMBEROFPARALLELRUNS" ]; then echo ");" >> config.php; fi | |
echo "require_once(dirname(__FILE__) . '/lib/setup.php');" >> config.php | |
cat config.php | |
# Create database | |
if [ -n "$NUMBEROFPARALLELRUNS" ]; then for ((i=1;i<=$MAXDB;i+=1)); do sh -c "psql -c 'create database $dbname$i;' -U $dbuser"; done; else sh -c "psql -c 'create database $dbname;' -U $dbuser"; fi | |
# Create directories | |
if [ -n "$NUMBEROFPARALLELRUNS" ]; then for ((i=1;i<=$NUMBEROFPARALLELRUNS;i+=1)); do mkdir -m777 $behat_dataroot$i; done; else mkdir -m777 $behat_dataroot; fi | |
# echo "{\"config\":{\"github-oauth\":{\"github.com\":\"$GITHUBTOKEN\"}}}" > ~/.composer/config.json | |
php -S localhost:8000 & 2> /dev/null > /dev/null | |
php admin/tool/behat/cli/init.php -j=$NUMBEROFPARALLELRUNS -m=$MAXPARALLELINSTALL | |
wget http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar | |
xvfb-run -a java -jar selenium-server-standalone-2.44.0.jar -maxSession $NUMBEROFPARALLELRUNS -browser "browserName=firefox, maxInstances=$NUMBEROFPARALLELRUNS" | |
sleep 20 | |
php admin/tool/behat/cli/run.php --rerun="$HOME/bht_moodledata{runprocess}/rerun.txt" --replace="{runprocess}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment