Changeset 991df6a in flex_extract.git for python/testsuite.py
- Timestamp:
- May 14, 2018, 10:11:29 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 812283d
- Parents:
- efdb01a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/testsuite.py
refdb01a r991df6a 1 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #************************************************************************ 4 # TODO AP 5 # 6 # - provide more tests 7 # - provide more documentation 8 # - 9 #************************************************************************ 2 10 3 # This software is licensed under the terms of the Apache Licence Version 2.04 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.11 #******************************************************************************* 12 # @Author: Leopold Haimberger (University of Vienna) 5 13 # 6 # Leopold Haimberger, Dec201514 # @Date: December 2015 7 15 # 8 # Functionality provided: This script triggers the ECMWFDATA test suite. Call with 9 # testsuite.py [test group] 16 # @Change History: 10 17 # 18 # February 2018 - Anne Philipp (University of Vienna): 19 # - applied PEP8 style guide 20 # - added documentation 11 21 # 12 # Further documentation may be obtained from www.flexpart.eu 22 # @License: 23 # (C) Copyright 2015-2018. 13 24 # 14 # Test groups are specified in testsuite.json 15 # in addition to a standard python 2.6 or 2.7 installation the following packages need to be installed 16 # ECMWF WebMARS, gribAPI with python enabled, emoslib, ecaccess web toolkit, all available from https://software.ecmwf.int/ 17 # dateutils 18 # matplotlib (optional, for debugging) 25 # This software is licensed under the terms of the Apache Licence Version 2.0 26 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 27 # 28 # @Program Functionality: 29 # This script triggers the ECMWFDATA test suite. Call with 30 # testsuite.py [test group] 31 # 32 # @Program Content: 33 # 34 #******************************************************************************* 19 35 20 import os,sys 36 # ------------------------------------------------------------------------------ 37 # MODULES 38 # ------------------------------------------------------------------------------ 39 import os 40 import sys 21 41 import json 22 42 import subprocess 23 43 44 # ------------------------------------------------------------------------------ 45 # PROGRAM 46 # ------------------------------------------------------------------------------ 24 47 try: 25 taskfile =open('testsuite.json')48 taskfile = open('testsuite.json') 26 49 except: 27 50 print 'could not open suite definition file testsuite.json' … … 33 56 exit() 34 57 35 fprs =os.getenv('FLEXPART_ROOT_SCRIPTS')58 fprs = os.getenv('FLEXPART_ROOT_SCRIPTS') 36 59 if fprs is None: 37 60 print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail' 38 61 39 tasks =json.load(taskfile,encoding='latin-1')62 tasks = json.load(taskfile, encoding='latin-1') 40 63 taskfile.close() 41 64 if not os.path.exists('../test'): 42 65 os.makedirs('../test') 43 if len(sys.argv) >1:44 groups =sys.argv[1:]66 if len(sys.argv) > 1: 67 groups = sys.argv[1:] 45 68 else: 46 groups =['xinstall','default','ops','work','cv','fc']#,'hires']47 jobcounter =048 jobfailed =069 groups = ['xinstall', 'default', 'ops', 'work', 'cv', 'fc']#,'hires'] 70 jobcounter = 0 71 jobfailed = 0 49 72 for g in groups: 50 73 try: 51 tk, tv=g,tasks[g]74 tk, tv = g, tasks[g] 52 75 except: 53 76 continue 54 garglist =[]55 for ttk, ttv in tv.iteritems():56 if isinstance(ttv, basestring):57 if ttk !='script':58 garglist.append('--' +ttk)59 if '$' ==ttv[0]:77 garglist = [] 78 for ttk, ttv in tv.iteritems(): 79 if isinstance(ttv, basestring): 80 if ttk != 'script': 81 garglist.append('--' + ttk) 82 if '$' == ttv[0]: 60 83 garglist.append(os.path.expandvars(ttv)) 61 84 else: 62 85 garglist.append(ttv) 63 for ttk, ttv in tv.iteritems():64 if isinstance(ttv, dict):65 arglist =[]66 for tttk, tttv in ttv.iteritems():67 if isinstance(tttv, basestring):68 arglist.append('--' +tttk)86 for ttk, ttv in tv.iteritems(): 87 if isinstance(ttv, dict): 88 arglist = [] 89 for tttk, tttv in ttv.iteritems(): 90 if isinstance(tttv, basestring): 91 arglist.append('--' + tttk) 69 92 if '$' in tttv[0]: 70 93 arglist.append(os.path.expandvars(tttv)) 71 94 else: 72 95 arglist.append(tttv) 73 print 'Command: ', ' '.join([tv['script']]+garglist+arglist)74 o ='../test/'+tk+'_'+ttk+'_'+'_'.join(ttv.keys())75 print 'Output will be sent to ', o76 f =open(o,'w')96 print 'Command: ', ' '.join([tv['script']] + garglist + arglist) 97 o = '../test/' + tk + '_' + ttk + '_' + '_'.join(ttv.keys()) 98 print 'Output will be sent to ', o 99 f = open(o, 'w') 77 100 try: 78 p=subprocess.check_call([tv['script']]+garglist+arglist,stdout=f,stderr=f) 101 p = subprocess.check_call([tv['script']] + garglist + arglist, 102 stdout=f, stderr=f) 79 103 except: 80 104 f.write('\nFAILED\n') 81 105 print 'FAILED' 82 jobfailed +=183 jobcounter +=1106 jobfailed += 1 107 jobcounter += 1 84 108 f.close() 85 109 86 110 print 'Test suite tasks completed' 87 print str(jobcounter-jobfailed) +' successful, '+str(jobfailed)+' failed'111 print str(jobcounter-jobfailed) + ' successful, ' + str(jobfailed) + ' failed' 88 112 print 'If tasks have been submitted via ECACCESS please check emails' 89 113
Note: See TracChangeset
for help on using the changeset viewer.