Changeset 97e09f4 in flex_extract.git


Ignore:
Timestamp:
Sep 2, 2018, 12:32:04 PM (10 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
efa05d7
Parents:
f9f7b3f
Message:

completed testing and adaptations of ecacces job-submit and file-put functions

Location:
python
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • python/install.py

    r763fcf6 r97e09f4  
    177177    fortran_executable = 'CONVERT2'
    178178
    179     if c.install_target.lower() != 'local':
     179    if c.install_target.lower() != 'local': # ecgate or cca
    180180
    181181        mk_compilejob(ecd + 'python/compilejob.temp', c.makefile,
     
    195195                             c.ecuid, c.ecgid)
    196196
    197         result_code = submit_job_to_ecserver(ecd + '/python/', c.install_target,
    198                                              'compilejob.ksh')
     197        submit_job_to_ecserver(ecd + '/python/', c.install_target,
     198                               'compilejob.ksh')
    199199
    200200        print 'job compilation script has been submitted to ecgate for ' + \
    201201              'installation in ' + c.flexpart_root_scripts + \
    202202               '/' + target_dir
    203         print 'You should get an email with subject flexcompile within ' + \
     203        print 'You should get an email with subject "flexcompile" within ' + \
    204204              'the next few minutes!'
    205205
  • python/pythontest/.cache/v/cache/lastfailed

    rdda0e9d r97e09f4  
    11{
     2  "TestTools.py": true,
    23  "TestTools.py::TestTools::test_init128": true,
    34  "TestTools.py::TestTools::test_to_param_id": true
  • python/pythontest/TestTools.py

    rf9f7b3f r97e09f4  
    117117        assert True
    118118
    119     @pytest.mark.msuser
     119    def test_fail_put_file_to_ecserver(self):
     120        ecuid=os.environ['ECUID']
     121        ecgid=os.environ['ECGID']
     122        with pytest.raises(SystemExit) as pytest_wrapped_e:
     123            put_file_to_ecserver('TestData/', 'testfil.txt',
     124                                 'ecgate', ecuid, ecgid)
     125        assert pytest_wrapped_e.type == SystemExit
     126        assert pytest_wrapped_e.value.code == '... ECACCESS-FILE-PUT FAILED!'
     127
    120128    def test_success_put_file_to_ecserver(self):
     129        ecuid=os.environ['ECUID']
     130        ecgid=os.environ['ECGID']
     131        result = put_file_to_ecserver('TestData/', 'testfile.txt',
     132                                      'ecgate', ecuid, ecgid)
     133        assert result == ''
     134
     135    @pytest.mark.msuser_pw
     136    def test_fullsuccess_put_file_to_ecserver(self):
    121137        ecuid=os.environ['ECUID']
    122138        ecgid=os.environ['ECGID']
     
    134150    def test_success_submit_job_to_ecserver(self):
    135151        result = submit_job_to_ecserver('ecgate', 'TestData/testfile.txt')
    136         assert result == 0
    137 
     152        assert result.strip().isdigit() == True
    138153
    139154
  • python/pythontest/pytest.ini

    rf9f7b3f r97e09f4  
    22[pytest]
    33markers =
    4     memberstate: Test that can be executed only as a member-state user. Password required.
     4    msuser_pw: Test that can be executed only as a member-state user. Password required.
  • python/tools.py

    r70a0bec r97e09f4  
    446446    '''
    447447    @Description:
    448         Uses the ecaccess command to send a file to the ECMWF servers.
    449         Catches and prints the error if it failed.
     448        Uses the ecaccess-file-put command to send a file to the ECMWF servers.
     449
     450        NOTE:
     451        The return value is just for testing reasons. It does not have
     452        to be used from the calling function since the whole error handling
     453        is done in here.
    450454
    451455    @Input:
    452456        ecd: string
    453             The path were the file is to be stored.
     457            The path were the file is stored.
    454458
    455459        filename: string
     
    457461
    458462        target: string
    459             The target where the file should be sent to, e.g. the queue.
     463            The target queue where the file should be sent to.
    460464
    461465        ecuid: string
     
    466470
    467471    @Return:
    468         <nothing>
     472        rcode: string
     473            Resulting code of command execution. If successful the string
     474            will be empty.
    469475    '''
    470476
    471477    try:
    472         subprocess.check_call(['ecaccess-file-put',
    473                                ecd + '/' + filename,
    474                                target + ':/home/ms/' +
    475                                ecgid + '/' + ecuid +
    476                                '/' + filename])
     478        rcode = subprocess.check_output(['ecaccess-file-put',
     479                                          ecd + '/' + filename,
     480                                          target + ':/home/ms/' +
     481                                          ecgid + '/' + ecuid +
     482                                          '/' + filename],
     483                                         stderr=subprocess.STDOUT)
    477484    except subprocess.CalledProcessError as e:
    478         print 'ERROR:'
    479         print e
    480         sys.exit('ecaccess-file-put failed!\n' + \
    481                  'Probably the eccert key has expired.')
    482 
    483     return
     485        print '... ERROR CODE:\n ... ', e.returncode
     486        print '... ERROR MESSAGE:\n ... ', e
     487        print '... COMMAND MESSAGE:\n ...', e.output
     488
     489        print '\nDo you have a valid eccert key?'
     490        sys.exit('... ECACCESS-FILE-PUT FAILED!')
     491
     492    return rcode
    484493
    485494def submit_job_to_ecserver(target, jobname):
    486495    '''
    487496    @Description:
    488         Uses ecaccess to submit a job to the ECMWF server.
    489         Catches and prints the error if one arise.
     497        Uses ecaccess-job-submit command to submit a job to the ECMWF server.
     498
     499        NOTE:
     500        The return value is just for testing reasons. It does not have
     501        to be used from the calling function since the whole error handling
     502        is done in here.
    490503
    491504    @Input:
     
    497510
    498511    @Return:
    499         rcode: integer
    500             Resulting code of subprocess.check_call.
     512        rcode: string
     513            Resulting code of command execution. If successful the string
     514            will contain an integer number, representing the id of the job
     515            at the ecmwf server.
    501516    '''
    502517
    503518    try:
    504         rcode = subprocess.check_call(['ecaccess-job-submit',
    505                                        '-queueName', target,
    506                                        jobname])
     519        rcode = subprocess.check_output(['ecaccess-job-submit',
     520                                         '-queueName', target,
     521                                         jobname])
    507522    except subprocess.CalledProcessError as e:
    508523        print '... ERROR CODE: ', e.returncode
     524        print '... ERROR MESSAGE:\n ... ', e
     525        print '... COMMAND MESSAGE:\n ...', e.output
     526
     527        print '\nDo you have a valid eccert key?'
    509528        sys.exit('... ECACCESS-JOB-SUBMIT FAILED!')
    510529
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG