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

ctbtodev
Last change on this file since efdb01a was efdb01a, checked in by Anne Philipp <anne.philipp@…>, 6 years ago

whole bunch of modifications due to new structure of ECMWFDATA, added basics of documentation, minor programming corrections

  • Property mode set to 100755
File size: 2.9 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 ECMWFDATA 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
23
24try:
25    taskfile=open('testsuite.json')
26except:
27    print 'could not open suite definition file testsuite.json'
28    exit()
29
30if not os.path.isfile('../src/CONVERT2'):
31    print '../src/CONVERT2 could not be found'
32    print 'please run "install.py --target=local" first'
33    exit()
34
35fprs=os.getenv('FLEXPART_ROOT_SCRIPTS')
36if fprs is None:
37    print 'FLEXPART_ROOT_SCRIPTS not set .. some test jobs may fail'
38
39tasks=json.load(taskfile,encoding='latin-1')
40taskfile.close()
41if not os.path.exists('../test'):
42    os.makedirs('../test')
43if len(sys.argv)>1:
44    groups=sys.argv[1:]
45else:
46    groups=['xinstall','default','ops','work','cv','fc']#,'hires']
47jobcounter=0
48jobfailed=0
49for g in groups:
50    try:
51        tk,tv=g,tasks[g]
52    except:
53        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]:
60                    garglist.append(os.path.expandvars(ttv))
61                else:
62                    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)
69                        if '$' in tttv[0]:
70                            arglist.append(os.path.expandvars(tttv))
71                        else:
72                            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 ',o
76            f=open(o,'w')
77            try:
78                p=subprocess.check_call([tv['script']]+garglist+arglist,stdout=f,stderr=f)
79            except:
80                f.write('\nFAILED\n')
81                print 'FAILED'
82                jobfailed+=1
83            jobcounter+=1
84            f.close()
85
86print 'Test suite tasks completed'
87print str(jobcounter-jobfailed)+' successful, '+str(jobfailed)+' failed'
88print 'If tasks have been submitted via ECACCESS please check emails'
89
90#print tasks
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG