source: flex_extract.git/python/testsuite.py @ e18f4b5

ctbtodev
Last change on this file since e18f4b5 was e18f4b5, checked in by skomo <p.skomorowski@…>, 6 years ago

initial git repo of version 7.0.3

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/usr/bin/env python
2
3# This software is licensed under the terms of the Apache Licence Version 2.0
4# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5#
6# Leopold Haimberger, Dec 2015
7#
8# Functionality provided: This script triggers the flex_extract test suite. Call with
9# testsuite.py [test group]
10#
11#
12# Further documentation may be obtained from www.flexpart.eu
13#
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)
19
20import os,sys
21import json
22import subprocess
23try:
24    taskfile=open('testsuite.json')
25except:
26    print 'could not open suite definition file testsuite.json'
27    exit()
28
29if not os.path.isfile('../src/CONVERT2'):
30    print '../src/CONVERT2 could not be found'
31    print 'please run "install.py --target=local" first'
32    exit()
33
34fprs=os.getenv('FLEXPART_ROOT_SCRIPTS')
35if fprs is None:
36    print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail'
37
38tasks=json.load(taskfile,encoding='latin-1')
39taskfile.close()
40if not os.path.exists('../test'):
41    os.makedirs('../test')
42if len(sys.argv)>1:
43    groups=sys.argv[1:]
44else:
45    groups=['xinstall','default','ops','work','cv','fc']#,'hires']
46jobcounter=0
47jobfailed=0
48for g in groups:
49    try:
50        tk,tv=g,tasks[g]
51    except:
52        continue
53    garglist=[]
54    for ttk,ttv in tv.iteritems():
55        if isinstance(ttv,basestring):
56            if ttk!='script':
57                garglist.append('--'+ttk)
58                if '$'==ttv[0]:
59                    garglist.append(os.path.expandvars(ttv))
60                else:
61                    garglist.append(ttv)
62    for ttk,ttv in tv.iteritems():
63        if isinstance(ttv,dict):
64            arglist=[]
65            for tttk,tttv in ttv.iteritems():
66                if isinstance(tttv,basestring):
67                    arglist.append('--'+tttk)
68                    if '$' in tttv[0]:
69                        arglist.append(os.path.expandvars(tttv))
70                    else:
71                        arglist.append(tttv)
72            print 'Command: ',' '.join([tv['script']]+garglist+arglist)
73            o='../test/'+tk+'_'+ttk+'_'+'_'.join(ttv.keys())
74            print 'Output will be sent to ',o
75            f=open(o,'w')
76            try:
77                p=subprocess.check_call([tv['script']]+garglist+arglist,stdout=f,stderr=f)
78            except:
79                f.write('\nFAILED\n')
80                print 'FAILED'
81                jobfailed+=1
82            jobcounter+=1
83            f.close()
84
85print 'Test suite tasks completed'
86print str(jobcounter-jobfailed)+' successful, '+str(jobfailed)+' failed'
87print 'If tasks have been submitted via ECACCESS please check emails'
88
89#print tasks
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG