Changes between Version 2 and Version 3 of Testing_Quickstart

Show
Ignore:
Timestamp:
10/01/08 13:35:49 (16 years ago)
Author:
blyth (IP: 140.112.102.77)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Testing_Quickstart

    v2 v3  
    1717   ||  bitten-slave  from [http://bitten.edgewall.org/ bitten]  ||   automated build/test runner,  pure python  ||  
    1818 
     19 
     20Which provide command line tools: 
     21   || nosetests ||   test running entry point || 
     22   || easy_install ||   install python packages into NuWa python || 
     23   || bitten-slave ||  communicates with bitten-master for instructions on tests (or builds) to be performed || 
     24 
    1925== Installation of '''nosebit''' into Nuwa python == 
    2026 
     
    2228(if you find otherwise check ticket #19 ).   
    2329 
    24  
    2530If '''which nosetests''' draws a blank when you are in your CMT environment then you(or your administrator) will  
    2631need to rerun [db:Offline_Software_Installation  dybinst] with commands like : 
     
    2934./dybinst trunk external nosebit 
    3035}}} 
    31 to get uptodate and install the currently non-default '''nosebit''' external. Which provides the tools :   
    32    || nosetests ||   test running entry point || 
    33    || easy_install ||   install python packages into NuWa python || 
    34    || bitten-slave ||  communicates with bitten-master for instructions on tests (or builds) to be performed ||   
    35  
    36 Check your installation by getting into the CMT controlled environment of your default package, and trying these 
     36to get uptodate and install the '''nosebit''' external.   
     37  
     38== Check the '''nosebit''' installation == 
     39 
     40Check your installation by getting into the CMT controlled environment of any package that uses python, and trying these 
    3741tools: 
    3842{{{ 
     
    5761the below called from your $HOME/.bash_profile   
    5862{{{ 
    59 . $NUWA_HOME/dybgaudi/DybTest/scripts/dyb__.sh 
     63. $NUWA_HOME/../installation/trunk/dybtest/scripts/dyb__.sh 
    6064}}} 
    6165 
     
    141145    * name the test functions test_*  
    142146 
    143 See the example of the '''gentools''' tests in  
    144    *  dybsvn:/dybgaudi/trunk/Simulation/GenTools/tests 
     147See the examples of tests in  
     148   *  i:source:dybgaudi/trunk/Simulation/GenTools/tests 
     149   *  i:source:dybgaudi/trunk/RootIO/RootIOTest/tests 
    145150 
    146151You can also run the tests from specific directories or modules with eg  
     
    173178 
    174179 
    175 = Automated Test Running = 
     180= Automated Build/Test Running = 
     181 
     182The results of automated testing are reported by the Bitten Trac plugin at  
     183  * i:build summary of all configurations  
     184  * i:build/dybinst  details for the '''dybinst''' configuration  
     185 
     186Some documentation on test triggering criteria are given on the above pages.  
     187 
     188== Adding a script to automated testing == 
     189 
     190=== Create the test === 
     191 
     192 * Create a '''tests''' directory as sibling to the cmt directory of the project  
     193 * Add a interface script at path {{{tests/test_myscript.py}}} 
     194    * NB the directory must be called '''tests''' and the filename must be of form  '''test_*.py''' 
     195  
     196Example of  {{{tests/test_myscript.py}}} :    
     197{{{ 
     198#!py 
     199from dybtest import Matcher, Run 
     200""" 
     201  Example of interfacing :  
     202       "python share/myscript.py myarg1 myarg2"   
     203  into the automated testing system, without modifcation to the script. 
     204 
     205  The script is run in a subprocess and the stdout/stderr is piped out and examined by the  
     206  matcher using python regular expressions that are matched against every line of output  
     207  providing line return codes when a match is found. 
     208  The maximum return code from all the lines of output is the matcher return code,  
     209  which if greater than zero causes the test to fail 
     210 
     211  If the running time of subprocess script exceeds the configured maxtime (in seconds),  
     212  the subprocess is killed. 
     213 
     214""" 
     215 
     216checks = { 
     217  '.*FATAL':2, 
     218  '.*ERROR':1, 
     219  '.*\*\*\* Break \*\*\* segmentation violation':3,  
     220  '^\#\d':None  
     221} 
     222 
     223m = Matcher( checks, verbose=False ) 
     224         
     225opts = { 'maxtime':300 } 
     226         
     227def test_myscript(): 
     228   Run( "python share/myscript.py myarg1 myarg2"  , parser=m , opts=opts )().assert_()  
     229 
     230if __name__=='__main__': 
     231        test_myscript()  
     232}}} 
     233 
     234This uses functionality provided in i:source:installation/trunk/dybtest/python/dybtest  which is  
     235made globally available via '''nosebit_dybtest'''. 
     236  
     237 
     238=== Introduce the test to the automated testing system === 
     239 
     240 * Add a '''step''' element to the relevant recipes : 
     241   * i:source:installation/trunk/dybtest/recipes/dybinst.xml 
     242 
     243{{{ 
     244#!xml    
     245<step id="test-myproject" description="test-myproject" onerror="continue" > 
     246     <sh:exec executable="bash"  output="test-myproject.out" 
     247           args=" -c &quot;  &env; export BUILD_TEST=myproject   ; export BUILD_PATH=dybgaudi/trunk/Simulation/MyProject   ; &test; &quot; " /> 
     248     <python:unittest file="test-myproject.xml" />  
     249</step>    
     250}}} 
     251 
     252Note that two variables must be exported :   
     253   * BUILD_TEST : name of test that must match that used in the '''python:unittest''' element 
     254   * BUILD_PATH : repository path (including the trunk) of your project  
     255 
     256To follow what is happening examine the entity definitions at the top of the recipe. 
     257 
     258After committing the updated recipe, all the slaves should being to perform your additional tests. 
     259 
     260 
    176261 
    177262== Bitten recipes == 
     
    182267 
    183268An example of a recipe : 
    184   * dybsvn:/dybgaudi/trunk/DybTest/recipes/nosetests.xml 
     269  * i:source:installation/trunk/dybtest/recipes/dybinst.xml 
    185270 
    186271{{{ 
     
    188273 
    189274<!DOCTYPE build [ 
    190   <!ENTITY  slav " export BUILD_PATH=${path} ; export BUILD_CONFIG=${config} ; export BUILD_REVISION=${revision} ; export BUILD_NUMBER=${build} ; " >  
     275  <!ENTITY  slav " export BUILD_PATH=${path} ; export BUILD_CONFIG_PATH=${path} ; export BUILD_CONFIG=${config} ; export BUILD_REVISION=${revision} ; export BUILD_NUMBER=${build} ; " >  
    191276  <!ENTITY  nuwa " export NUWA_HOME=${nuwa.home} ; export NUWA_VERSION=${nuwa.version} ; export NUWA_SCRIPT=${nuwa.script} ;  " > 
    192   <!ENTITY  scpt  " pwd ; iwd=$PWD ; . $NUWA_HOME/$NUWA_SCRIPT ; "  > 
     277  <!ENTITY  scpt  "export BUILD_PWD=$PWD ; . $NUWA_HOME/$NUWA_SCRIPT ; "  > 
    193278  <!ENTITY  env  " &slav;  &nuwa;  &scpt; " >  
     279  <!ENTITY test  "dyb__test --with-xml-output --xml-outfile=$BUILD_PWD/test-${test}.xml --xml-baseprefix=$(dyb__relativeto $BUILD_PATH $BUILD_CONFIG_PATH)/ ; "  > 
    194280]> 
    195281 
     
    201287  > 
    202288 
    203   <!-- 
    204     the NUWA_HOME is needed to work with older bash that does not have BASH_SOURCE 
    205   --> 
    206  
    207 <step id="update" description="dybinst checkout and rebuild " onerror="continue" > 
    208       <sh:exec executable="bash" output="hello.out"   
    209            args=" -c &quot; &env;  dyb__hello  ; echo it returned $?  &quot; " /> 
    210       <sh:exec executable="bash" output="update.out"   
    211            args=" -c &quot; &env;  dyb__update ; echo it returned $?  &quot; " /> 
    212 </step> 
    213  
    214 <step id="txttest" description="Run tests with txt output " onerror="continue"  > 
    215      <sh:exec executable="bash"   output="txttest.out"  
    216            args=" -c  &quot; &env; dyb__test &quot;  "  /> 
    217 </step> 
    218  
    219 <step id="xmltest" description="Run tests with xml output " onerror="continue" > 
    220      <sh:exec executable="bash"  output="xmltest.out" 
    221            args=" -c &quot;  &env; dyb__test --with-xml-output --xml-outfile=$iwd/nosetests.xml   &quot;  "  /> 
    222      <python:unittest file="nosetests.xml" /> 
    223 </step> 
     289<step id="checkout" description="checkout" onerror="continue" > <sh:exec executable="bash" output="checkout.out"  args=" -c &quot; &env;  dyb__checkout          &quot; " /> </step>    
     290<step id="external" description="external" onerror="continue" > <sh:exec executable="bash" output="external.out"  args=" -c &quot; &env;  dyb__external          &quot; " /> </step>    
     291<step id="relax"    description="relax"    onerror="continue" > <sh:exec executable="bash" output="relax.out"     args=" -c &quot; &env;  dyb__projects relax    &quot; " /> </step>    
     292<step id="gaudi"    description="gaudi"    onerror="continue" > <sh:exec executable="bash" output="gaudi.out"     args=" -c &quot; &env;  dyb__projects gaudi    &quot; " /> </step>    
     293<step id="lhcb"     description="lhcb"     onerror="continue" > <sh:exec executable="bash" output="lhcb.out"      args=" -c &quot; &env;  dyb__projects lhcb     &quot; " /> </step>    
     294<step id="dybgaudi" description="dybgaudi" onerror="continue" > <sh:exec executable="bash" output="dybgaudi.out"  args=" -c &quot; &env;  dyb__projects dybgaudi &quot; " /> </step>    
     295 
     296 
     297<step id="test-gentools" description="test-gentools" onerror="continue" > 
     298     <sh:exec executable="bash"  output="test-gentools.out" 
     299           args=" -c &quot;  &env; test=gentools ; export BUILD_PATH=dybgaudi/trunk/Simulation/GenTools ; &test; &quot; " /> 
     300     <python:unittest file="test-gentools.xml" />  
     301</step>    
     302 
     303<step id="test-rootio" description="test-rootio" onerror="continue" > 
     304     <sh:exec executable="bash"  output="test-rootio.out" 
     305           args=" -c &quot;  &env; test=rootio   ; export BUILD_PATH=dybgaudi/trunk/RootIO/RootIOTest   ; &test; &quot; " /> 
     306     <python:unittest file="test-rootio.xml" />  
     307</step>    
     308 
    224309 
    225310</build> 
     311 
     312 
     313 
    226314 
    227315}}} 
     
    235323Define some functions for configuration/control of the slave  
    236324{{{ 
    237 . $NUWA_HOME/dybgaudi/DybTest/scripts/bitrun.sh 
    238 }}} 
    239  
    240 {{{ 
    241 bitrun-usage 
     325. $NUWA_HOME/../installation/trunk/dybtest/scripts/slave.bash 
     326}}} 
     327 
     328{{{ 
     329slave-usage 
    242330}}} 
    243331 
    244332The slave is configured using two files, one for the credentials/url  with which  to connect to  
    245 the master $HOME/.bitrunrc : 
    246 {{{ 
    247 # 
    248 # name used for logfile and tmp directory identification   
    249 # 
    250 local name=trialrun    
     333the master $HOME/.slaverc : 
     334{{{ 
     335 
     336# 
     337#           generated on : Thu Sep 11 17:39:04 CST 2008 
     338#            by function : slave-demorc  
     339#            from script : /data/env/local/dyb/trunk_dbg/installation/trunk/dybtest/scripts/slave.bash 
     340# 
     341# 
     342# name used for logfile and tmp directory identification  and identification of the  
     343# slave on the server ... convention is to use the NEWCMTCONFIG string  
     344# 
     345local name=i686-slc46-gcc346    
    251346        
    252347# 
    253348#  "builds" url of the master trac instance and credentials with which to connect 
    254 #     
    255 local url=http://dayabay.ihep.ac.cn/tracs/dybsvn/builds    
     349# 
     350#local url=http://dayabay.phys.ntu.edu.tw/tracs/dybsvn/builds       
     351local url=http://dayabay.ihep.ac.cn/tracs/dybsvn/builds       
    256352local user=slave 
    257353local pass=youknowit 
    258354 
    259355# 
     356# absolute path to directory containing dybinst exported script 
     357# 
     358local home=/data/env/local/dyb/trunk_dbg 
     359 
     360# 
    260361# absolute path to slave config file 
    261362# 
    262 local cfg=/disk/d3/dayabay/local/dyb/trunk_dbg/NuWa-trunk/dybgaudi/DybTest/recipes/grid1.cfg    
     363local cfg=$home/installation/trunk/dybtest/recipes/cms01.cfg    
     364 
    263365 
    264366}}} 
    265367 
    266368And a second defining the characteristics of the !NuWa installation  
    267    * dybsvn:/dybgaudi/trunk/DybTest/recipes/grid1.cfg    
     369   * i:source:installation/trunk/dybtest/recipes/cms01.cfg    
    268370 
    269371{{{ 
     
    274376#  the "trunk" to get to working copy paths 
    275377#  
     378 
    276379[nuwa] 
    277 home = /disk/d3/dayabay/local/dyb/trunk_dbg/NuWa-trunk 
     380home = /data/env/local/dyb/trunk_dbg/NuWa-trunk 
    278381version = trunk 
    279 script = dybgaudi/DybTest/scripts/dyb__.sh 
     382script = ../installation/trunk/dybtest/scripts/dyb__.sh 
     383 
    280384}}} 
    281385 
     
    295399To start the slave: 
    296400{{{ 
    297 bitrun-start [options-passed-to-slave] 
     401slave-start [options-passed-to-slave] 
    298402}}} 
    299403 
     
    305409   ||  -n, --dry-run  ||     do not report results back to master || 
    306410   ||  -i SECONDS, --interval=SECONDS  ||   time to wait between requesting builds, poll interval  (default 300 s) || 
     411 
     412 
     413For long term slave running, a detached '''screen''' can be used, started with : 
     414{{{ 
     415slave-screen-start 
     416}}} 
     417 
     418 
    307419 
    308420