SysAdmin/ContinuousIntegration: testsuite

File testsuite, 5.2 KB (added by somayjain, 11 years ago)

The testsuite script run on the CI Server

Line 
1#!/bin/bash
2########
3# Cron Script to run Sahana Eden Test Suite
4########
5
6function repop_database
7{
8 template1=$1
9 # Setting the template
10 echo "`date` Setting the template as "$template1"....." >> /tmp/CRON_RUN
11 sed -i "s/settings.base.template = \".*\"/settings.base.template = \""$template1"\" /" /home/web2py/applications/eden/models/000_config.py
12
13 # Delete prepopulated data
14 echo "`date` databases Deleted....." >> /tmp/CRON_RUN
15 rm -rf /home/web2py/applications/eden/databases/*
16
17 echo "`date` Repopulating the databases......" >> /tmp/CRON_RUN
18 # Prepop database
19 cd /home/web2py
20 python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
21 chown -R web2py /home/web2py
22
23 # Kill the current instance of web2py
24 echo "`date` Killing the current instance of web2py....." >> /tmp/CRON_RUN
25 kill -9 `ps uax | grep "python /home/web2py/web2py.py -a iiit123" | awk '{print $2;}'`
26}
27
28function run_selenium_tests
29{
30 template=$1
31 echo "`date` Template is "$template" " >> /tmp/CRON_RUN
32 # Repoulate the database and start a w2p instance.
33 repop_database IFRC
34
35 # Setting the template
36 echo "`date` Setting the template as "$template"....." >> /tmp/CRON_RUN
37 sed -i "s/settings.base.template = \".*\"/settings.base.template = \""$template"\" /" /home/web2py/applications/eden/models/000_config.py
38
39 ## Start a custom web2py server
40 echo "`date` Restarting a custom web2py server....." >> /tmp/CRON_RUN
41 python /home/web2py/web2py.py -a iiit123 &
42 echo "Sleeping for 5 seconds....."
43 sleep 5
44
45 # Run Selenium Test Suite on template
46 echo "`date` Running Selenium Tests on "$template" template......" >> /tmp/CRON_RUN
47 cd /home/web2py
48 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --html-path /var/spool/RESULTS/SELENIUM/$template -V 2 --browser chrome >> /tmp/CRON_RUN
49}
50
51function run_roles_tests
52{
53 template=$1
54
55 echo "`date` Template is "$template" " >> /tmp/CRON_RUN
56 # Repoulate the database and start a w2p instance.
57 repop_database $template
58
59 # Setting the template
60 echo "`date` Setting the template as "$template"....." >> /tmp/CRON_RUN
61 sed -i "s/settings.base.template = \".*\"/settings.base.template = \""$template"\" /" /home/web2py/applications/eden/models/000_config.py
62
63 ## Start a custom web2py server
64 echo "`date` Restarting a custom web2py server....." >> /tmp/CRON_RUN
65 python /home/web2py/web2py.py -a iiit123 &
66 echo "Sleeping for 5 seconds....."
67 sleep 5
68
69 # Run Roles Test Suite on template
70 echo "`date` Running Roles Tests on "$template" template......" >> /tmp/CRON_RUN
71 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --suite roles --browser=chrome --html-path /var/spool/RESULTS/ROLES/$template >> /tmp/CRON_RUN
72
73}
74
75function run_smoke_tests
76{
77 template=$1
78
79 if [ $template == "default" ] || [ $template == "SandyRelief" ]
80 then
81 repop_database IFRC
82 else
83 repop_database $template
84 fi
85
86 # Setting the template
87 echo "`date` Setting the template as "$template"....." >> /tmp/CRON_RUN
88 sed -i "s/settings.base.template = \".*\"/settings.base.template = \""$template"\" /" /home/web2py/applications/eden/models/000_config.py
89
90 ## Start a custom web2py server
91 echo "`date` Restarting a custom web2py server....." >> /tmp/CRON_RUN
92 python /home/web2py/web2py.py -a iiit123 &
93 echo "Sleeping for 5 seconds....."
94 sleep 5
95
96 # Run Smoke Test on template (on linkdepth max)
97 echo "`date` Running Smoke Tests on "$template" template......" >> /tmp/CRON_RUN
98 cd /home/web2py
99 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A -V 2 --suite smoke --html-path /var/spool/RESULTS/SMOKE/$template --browser chrome >> /tmp/CRON_RUN
100}
101
102# Initialise Log
103echo "Started running at : `date`" >> /tmp/CRON_RUN
104echo "`whoami`" >> /tmp/CRON_RUN
105echo "`which python`" >> /tmp/CRON_RUN
106
107# Kill any previous web2py instance running
108kill -9 `ps uax | grep "python /home/web2py/web2py.py -a iiit123" | awk '{print $2;}'`
109
110# Update web2py
111# DISABLED
112#cd /home/web2py
113#git reset --hard HEAD
114#git checkout master
115#git pull
116
117# Update Eden to current Trunk
118cd /home/web2py/applications/eden
119git reset --hard HEAD
120git checkout master
121git pull upstream master
122
123## use the python from pythonbrew
124[[ -s "$HOME/.pythonbrew/etc/bashrc" ]] && source "$HOME/.pythonbrew/etc/bashrc"
125/root/.pythonbrew/bin/pythonbrew switch 2.7.2
126
127echo "`which python`" >> /tmp/CRON_RUN
128
129###################################################################################
130# Run tests
131
132run_selenium_tests IFRC
133run_smoke_tests IFRC
134run_roles_tests IFRC
135run_selenium_tests default
136run_smoke_tests default
137run_selenium_tests SandyRelief
138run_smoke_tests SandyRelief
139run_selenium_tests DRMP
140run_smoke_tests DRMP
141run_selenium_tests CRMT
142run_smoke_tests CRMT
143run_smoke_tests DRRPP
144run_roles_tests DRRPP
145
146###################################################################################
147
148# Mail results and a brief summary to the mailinglist
149/usr/local/bin/mailTestResults.sh
150
151# Kill any previous web2py instance running
152kill -9 `ps uax | grep "python /home/web2py/web2py.py -a iiit123" | awk '{print $2;}'`
153
154# Kill the instance of chromedriver
155killall -9 chromedriver
156
157echo "Stopped running at : `date`" >> /tmp/CRON_RUN
158
159# Save the last 2000 lines in CRON_RUN, so that file size does not keep growing
160tail -2000 /tmp/CRON_RUN > /tmp/temp
161mv /tmp/temp /tmp/CRON_RUN