Changes between Version 8 and Version 9 of SysAdmin/ContinuousIntegration


Ignore:
Timestamp:
03/06/13 21:34:56 (12 years ago)
Author:
Fran Boon
Comment:

Cleanup

Legend:

Unmodified
Added
Removed
Modified
  • SysAdmin/ContinuousIntegration

    v8 v9  
    1 == EDEN CONTINUOUS INTEGRATION ==
     1= Continuous Integration ==
     2[[TOC]]
    23
    3 CI Server results:
     4== Current Setup ==
     5CI Server runs the tests every 6 hours (crontab -e currently)
     6* Using Trunk Web2Py
     7* Using Trunk Eden
     8* Using IFRC template
     9* Using PostgreSQL
     10* Using Chrome
     11
     12Results are stored as HTML files in the filesystem which can be accessed via the Eden instance under test:
    413* http://82.71.213.53/eden/admin/result
    514
    6 Setup Notes & Discussions (to be ported to Wiki):
    7 * https://docs.google.com/document/d/1T29cF3kkK4lIAVdiATfE8a-tLm_Tyh3_dIh6FJWY7sU/edit
     15{{{/etc/cron.custom/testsuite}}}
     16 * Prepares Server (?)
     17 * Updates Web2Py to current Trunk (from github.com/web2py/web2py)
     18 * Updates Eden to current Trunk (from github.com/flavour/eden)
     19 * Deletes prepopulated data
     20 * Loads all models
     21 * Fixes permissions of the web2py folder
     22 * Runs Functional Tests (Selenium)
     23 * Runs Smoke Tests
     24 * Runs Roles Tests (Disabled for some reason)
     25 * Mails out test results (using /usr/local/bin/mailTestResults.sh)
    826
    927To run the test suite manually:
    1028{{{
    11 sudo sh /etc/cron.custom/web2pystarter
     29sudo sh /usr/local/bin/web2pystarter
    1230}}}
    1331Open another console then:
     
    1533sudo sh /etc/cron.custom/testsuite
    1634}}}
    17 This first updates Eden and Web2py from Github, then runs the functional tests followed by smoke tests.
    1835
    1936To just run smoke tests:
     
    2340}}}
    2441
    25 The Mailing script is located at : /home/mohanty/mailTestResults.sh
     42Start Window based applications (x11):
     43* If the GUI window of the application is of no interest to you:
     44{{{#!sh
     45xvfb-run -a *test commands here*
     46}}}
     47  For example :
     48{{{#!sh
     49xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A -V 2
     50}}}
     51  '''Note''': Xvfb basically makes a virtual display which isn't displayed anywhere. Xserver itself actually requires a real display
     52* If you want to see the GUI interface of the application
     53 * If the machine you use to ssh into the server, has X Server installed, then you can access the GUI window by using the -X flag when loggin into the server
     54{{{#!sh
     55ssh -X youraccount@82.71.213.53
     56}}}
     57   And now, if you simply execute any application which has a Xserver attached to it, it will be displayed on your screen.
    2658
    27 We also have an install of [SysAdmin/Jenkins Jenkins] which could be configured to run this.
    28 - or we could setup an Eden instance to manage this via Scheduler for more control & storing results in a database for graphical reports
    29 === COMPLETE DISCUSSIONS AND BACKLOG OF THE CI SERVER ===
    30 https://docs.google.com/document/d/1T29cF3kkK4lIAVdiATfE8a-tLm_Tyh3_dIh6FJWY7sU/edit
     59== Plans for Future ==
     60* ~~Move mailing script out of a personal user directory~~
     61* ~~Move cron commands to system /etc/crontab rather than root's crontab~~
     62* More templates
     63* More databases
     64* More browsers
     65* Install an Eden instance to act as a CI server
     66 * Move the cron scripts to being run by Eden Scheduler
     67 * Have Eden manage the mailing of results & manage subscriptions
     68 * Have Eden store the results in the database for Graphical analysis
    3169
     70We also have an install of [SysAdmin/Jenkins Jenkins] which could be configured to run these scripts & report results.
    3271
    33 === URL TO ACCESS RESULTS ===
    34 http://82.71.213.53/RESULTS
    35 
    36 === LOGIN DETAILS ===
    37 
    38 ssh youraccount@82.71.213.53
    39 
    40 Password: *****
    41 
    42 === Location of Cron Job Automation file to run Test Framework: ===
    43 
    44 /etc/cron.custom/testsuite
    45 
    46 * What this does currently :
    47   * Prepares Server
    48   * Pulls latest codes from web2py/web2py (update  web2py)
    49   * Pulls latest codes from flavour/eden (update Eden)
    50   * Deletes prepopulated data
    51   * Loads all models
    52   * Fixes permissions of the web2py folder
    53   * Runs Automated Test Suite
    54   * Runs Smoke Tests
    55   * Runs Roles Tests
    56 
    57 === Edit cron times: ===
    58  (Currently set to run Test Suite every 6 hours every day of every week of every month of every year)
    59 {{{#!sh
    60 crontab -e
    61 }}}
    62 
    63 === Location of Web2Py and Eden Directory ===
    64 *  web2py
    65   * /home/web2py
    66 * Eden
    67   * /home/web2py/applications/eden
    68 
    69 === Overall Restart ===
    70 If 82.71.213.53 goes down with these errors:
    71 
    72     * Internal Error
    73     * Server Maintenance
    74     * Connection Timeout by every web browser
    75     * Unresolvable Ticket Error
    76 
    77 Simply type these services restart commands in consoles:
    78 
    79 * Server Reboot :
    80    {{{#!sh
    81    sudo /sbin/reboot
    82    }}}
    83    '''Note''' : There will be a downtime of a few minutes after you execute this command
    84 * Cherokee Restart
    85    {{{#!sh
    86    sudo /etc/init.d/cherokee restart
    87    }}}
    88 * Web2Py SSL Restart
    89    {{{#!sh
    90    sudo /etc/init.d/uwsgi start
    91    }}}
    92 
    93 === Start Test Suite Manually On the CI Server===
    94 
    95 {{{#!sh
    96 sudo sh /etc/cron.custom/web2pystarter
    97 }}}
    98 Open another console then:
    99 {{{#!sh
    100 sudo sh /etc/cron.custom/testsuite
    101 }}}
    102 This first updates Eden and Web2py from Github, then runs the functional tests followed by smoke tests.
    103 
    104 To just run smoke tests:
    105 {{{#!sh
    106 cd /home/web2py
    107 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --html-path /home/web2py/applications/eden/static/test_smoke/ --suite smoke --force-debug --link-depth 16 -V 4
    108 }}}
    109 
    110 We also have an install of [SysAdmin/Jenkins Jenkins] which should ideally be configured to run this.
    111 ==== Shell Script to Start The Test Suite On The CI Server ====
    112 
    113 Simply run this shell script to start Functional selenium test, followed by Smoke test and then finally the Role test.
    114 You can comment out the lines you don't want to run.
    115 * Save the Code given below in a file (say, named as startSuite)
    116 * Add Execution permission to the file
    117   * chmod +x /location/to/script/startSuite
    118 * Execute the shell script
    119   * sudo sh /location/to/script/startSuite
    120 
    121 {{{
    122 #!div style="font-size: 80%"
    123 {{{#!sh
    124 #!/bin/sh
    125 ########
    126 # Cron Script to run Sahana Eden Test Suite
    127 ########
    128 #Server preparation
    129 sudo /etc/init.d/cherokee restart
    130 sudo /etc/init.d/uwsgi start
    131 
    132 # Pull latest codes from web2py/web2py (update  web2py)
    133 cd /home/web2py
    134 sudo git stash
    135 sudo git pull upstream master
    136 
    137 # Pull latest codes from flavour/eden (update Eden)
    138 cd /home/web2py/applications/eden
    139 sudo git stash
    140 sudo git pull upstream master
    141 
    142 # Delete prepopulated data
    143 rm -f /home/web2py/applications/eden/databases/*
    144 
    145 # Re pre pop db and fix permissions
    146 cd /home/web2py
    147 python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    148 chown -R web2py /home/web2py
    149 
    150 # Run Automated Test Suite
    151 cd /home/web2py
    152 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --html-path /home/web2py/applications/eden/static/test_automated/ -V 2
    153 
    154 # Run Smoke Test (on linkdepth 16)
    155 cd /home/web2py
    156 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --html-path /home/web2py/applications/eden/static/test_smoke/ --suite smoke --force-debug --link-depth 16 -V 3
    157 
    158 # Run Roles Test
    159 cd /home/web2py
    160 xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A --suite roles --html-path /home/web2py/applications/eden/static/test_roles/
    161 }}}
    162 }}}
    163 
    164 === Postgresql Instance Details for CI Server ===
    165 
    166 '''Database name''': sahana
    167 
    168 '''Database user''': kunal
    169 
    170 '''Database user password''': eden
    171 
    172 '''Host''': localhost
    173 
    174 '''Port''': 5432
    175 
    176 
    177 ==== How to Connect to Sahana Database from the console ====
    178 {{{#!sh
    179 psql -d sahana -U kunal
    180 }}}
    181 
    182 ==== How to Restart Postgresql Server (You can give it a shot, if psql fails to connect) ====
    183 {{{#!sh
    184 sudo su - postgres
    185 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
    186 }}}
    187 
    188 ===  Other Useful Linux command sets ===
    189 
    190 * '''Pre-populate database (any type of db)''' :
    191 {{{#!sh
    192 cd ~web2py
    193 sudo python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    194 }}}
    195 * '''chmod directory recursively (chmod everything inside dir with -R):'''
    196 {{{#!sh
    197 chmod -R 777 /home/web2py
    198 }}}
    199 * '''start web2py'''
    200 {{{#!sh
    201 cd ~web2py
    202 python web2py.py -a root
    203 }}}
    204 * '''reboot server'''
    205 {{{#!sh
    206 sudo /sbin/reboot
    207 }}}
    208 * '''Restart Cherokee'''
    209    {{{#!sh
    210    sudo /etc/init.d/cherokee restart
    211    }}}
    212 * '''Restart Web2Py SSL'''
    213    {{{#!sh
    214    sudo /etc/init.d/uwsgi start
    215    }}}
    216 * '''Recreate Sahana DB''' :
    217 {{{#!sh
    218 psql -U postgres -c "drop database sahana"
    219 psql -U postgres -c "create database sahana"
    220 psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE sahana to kunal" #Assuming kunal is the name of the postgresql username which will be used by Sahana Eden instance
    221 psql -d sahana -U kunal
    222 }}}
    223 * '''Setup Cron''' :
    224 {{{#!sh
    225 crontab -e
    226 }}}
    227 '''Note''' : You can refer to examples of crontab expressions here : http://code.google.com/p/ncrontab/wiki/CrontabExamples
    228 * '''start Window based applications (x11)''':
    229   * If the GUI window of the application is of no intrest to you
    230   {{{#!sh
    231   xvfb-run -a *test commands here*
    232   }}}
    233   For example :
    234   {{{#!sh
    235   xvfb-run -a python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A -V 2
    236   }}}
    237   '''Note''': Xvfb basically makes a virtual display which isn't displayed anywhere. Xserver itself actually requires a real display
    238   * If you want to see the GUI interface of the application
    239     * If your machine you use to ssh into the server, has X Server installed, then you can access the GUI window by using the -X flag when loggin into the server
    240     {{{#!sh
    241     ssh -X youraccount@82.71.213.53
    242     }}}
    243     And now, if you simply execute any application which has a Xserver attached to it, it will be displayed on your screen.
     72Setup Notes & Discussions (to be ported to Wiki):
     73* https://docs.google.com/document/d/1T29cF3kkK4lIAVdiATfE8a-tLm_Tyh3_dIh6FJWY7sU/edit