wiki:SysAdmin/Jenkins

Version 13 (modified by Fran Boon, 7 years ago) ( diff )

--

Table of Contents

  1. Update scripts

Jenkins: CI

We use Jenkins to do Continous Integration by running our Selenium functional tests:

There is a Windows 7 slave running:

  • Firefox
  • IE8
  • Chrome
  • Opera

The CI server also hosts the Application. There are 3 separate server environments for Eden, each with it's own Apache virtual host:

Selenium 2.23.1 is installed in /home/selenium (not using the Selenium plugin for Jenkins)

  • Configuration: /home/selenium/grid_configuration.yml

Update scripts

Before each test run, we use scripts to prepare the environments:

  • Update the code
  • Clean the database

sudo -H -u jenkins /home/update_sqlite.sh

cd /home/web2py/applications/sqlite
git pull
rm -rf /home/web2py/applications/sqlite/compiled
rm -rf /home/web2py/applications/sqlite/databases/*
rm -rf /home/web2py/applications/sqlite/errors/*
rm -rf /home/web2py/applications/sqlite/sessions/*
rm -rf /home/web2py/applications/sqlite/tests/selenium/results/*
cp -f /home/web2py/applications/sqlite/modules/templates/default/000_config.py /home/web2py/applications/sqlite/models
sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' /home/web2py/applications/sqlite/models/000_config.py
sed -i 's|settings.base.prepopulate = 1|settings.base.prepopulate = 27|' /home/web2py/applications/sqlite/models/000_config.py
sed -i 's|127.0.0.1:8000|sqlite.eden.sahanafoundation.org|' /home/web2py/applications/sqlite/models/000_config.py
sed -i 's|#settings.ui.navigate_away_confirm = False|settings.ui.navigate_away_confirm = False|' /home/web2py/applications/sqlite/models/000_config.py
cd ~web2py
python web2py.py -S sqlite -M -R applications/sqlite/static/scripts/tools/noop.py
sed -i 's|settings.base.migrate = True|settings.base.migrate = False|' /home/web2py/applications/sqlite/models/000_config.py
sed -i 's|settings.base.prepopulate = 27|settings.base.prepopulate = 0|' /home/web2py/applications/sqlite/models/000_config.py
python web2py.py -S sqlite -R applications/sqlite/static/scripts/tools/compile.py

sudo /etc/init.d/apache2 restart

sudo -H -u jenkins /home/update_mysql.sh

cd /home/web2py/applications/mysql
git pull
rm -rf /home/web2py/applications/mysql/compiled
rm -rf /home/web2py/applications/mysql/databases/*
rm -rf /home/web2py/applications/mysql/errors/*
rm -rf /home/web2py/applications/mysql/sessions/*
rm -rf /home/web2py/applications/mysql/tests/selenium/results/*
sudo /usr/bin/mysqladmin -f drop sahana
sudo /usr/bin/mysqladmin create sahana
cp -f "/home/web2py/applications/mysql/private/template/default/000_config.py" "/home/web2py/applications/mysql/models"
sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|settings.base.prepopulate = 1|settings.base.prepopulate = 27|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|127.0.0.1:8000|mysql.eden.sahanafoundation.org|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|database.db_type = "sqlite"|database.db_type = "mysql"|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|database.username = "sahana"|database.username = "root"|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|database.password = "password"|database.password = "eden"|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|#settings.ui.navigate_away_confirm = False|settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/mysql/models/000_config.py"
cd ~web2py
#sudo -H -u web2py python web2py.py -S mysql -M -R applications/mysql/static/scripts/tools/noop.py
python web2py.py -S mysql -M -R applications/mysql/static/scripts/tools/noop.py
sed -i 's|settings.base.migrate = True|settings.base.migrate = False|' "/home/web2py/applications/mysql/models/000_config.py"
sed -i 's|settings.base.prepopulate = 27|settings.base.prepopulate = 0|' "/home/web2py/applications/mysql/models/000_config.py"
python web2py.py -S mysql -R applications/mysql/static/scripts/tools/compile.py

sudo /etc/init.d/apache2 restart

sudo -H -u jenkins /home/update_postgresql.sh

cd /home/web2py/applications/postgresql
git pull
rm -rf /home/web2py/applications/postgresql/compiled
rm -rf /home/web2py/applications/postgresql/databases/*
rm -rf /home/web2py/applications/postgresql/errors/*
rm -rf /home/web2py/applications/postgresql/sessions/*
rm -rf /home/web2py/applications/postgresql/tests/selenium/results/*
sudo /bin/su -c - postgres "dropdb sahana" && true
sudo /bin/su -c - postgres "createdb -O sahana sahana"
sudo /bin/su -c - postgres "createlang plpgsql -d sahana"
sudo /bin/su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
sudo /bin/su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
cp -f "/home/web2py/applications/postgresql/private/templates/default/000_config.py" "/home/web2py/applications/postgresql/models"
sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|settings.base.prepopulate = 1|settings.base.prepopulate = 27|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|127.0.0.1:8000|postgresql.eden.sahanafoundation.org|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|settings.gis.spatialdb = False|settings.gis.spatialdb = True|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|database.db_type = "sqlite"|database.db_type = "postgres"|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|database.password = "password"|database.password = "eden"|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|#settings.ui.navigate_away_confirm = False|settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/postgresql/models/000_config.py"
cd ~web2py
#sudo -H -u web2py python web2py.py -S postgresql -M -R applications/postgresql/static/scripts/tools/noop.py
python web2py.py -S postgresql -M -R applications/postgresql/static/scripts/tools/noop.py
sed -i 's|settings.base.migrate = True|settings.base.migrate = False|' "/home/web2py/applications/postgresql/models/000_config.py"
sed -i 's|settings.base.prepopulate = 27|settings.base.prepopulate = 0|' "/home/web2py/applications/postgresql/models/000_config.py"
python web2py.py -S postgresql -R applications/postgresql/static/scripts/tools/compile.py

sudo /etc/init.d/apache2 restart

SysAdmin SysAdmin

Note: See TracWiki for help on using the wiki.