This file is indexed.

/usr/lib/python2.7/dist-packages/asrun/unittest/210_multi.py is in code-aster-run 1.13.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import os
import os.path as osp
import re
import unittest
import time

from common import dict_conf, execcmd, tmpdir, aster_version
from data   import study_export, available_hosts

import asrun
from asrun.run import AsRunFactory
from asrun.profil import AsterProfil, ExportEntry
from asrun.calcul import parse_submission_result
from asrun.client import MULTIDIR
from asrun.job import parse_actu_result
from asrun.common.sysutils import short_hostname


def build_prof(nomjob, resoncli):
    prof = AsterProfil()
    prof.parse(study_export % dict_conf)
    prof['nomjob'] = nomjob
    prof['tpsjob'] = 1
    prof['multiple'] = 'yes'
    prof['multiple_result_on_client'] = resoncli
    lhosts = [dict_conf['localhost'],] + available_hosts.keys()
    #lhosts = available_hosts.keys()
    prof['multiple_server_list'] = " ".join(lhosts)
    prof.add(ExportEntry(osp.join(tmpdir, nomjob + '.repe'),
                         type='repe', isrep=True, result=True))
    return prof

def study(resoncli):
    assert len(available_hosts) > 0, "no remote host available."
    nomjob = 'multi_study_' + resoncli
    run = AsRunFactory()
    prof = build_prof(nomjob, resoncli)

    export = osp.join(tmpdir, "%s.export" % nomjob)
    prof.WriteExportTo(export)
    cmd = dict_conf["as_run"] + ["--serv", export]
    iret, out = execcmd(cmd, "%s.1" % nomjob, return_output=True)
    assert iret == 0
    jobid, queue, studyid = parse_submission_result(out)
    assert jobid.strip() != ""
    assert studyid.strip() != "" and studyid == jobid
    etat = 'RUN'
    while etat != 'ENDED':
        cmd = dict_conf["as_run"] + ["--actu", jobid, nomjob, "interactif"]
        iret, out = execcmd(cmd, "%s.2" % nomjob, return_output=True)
        etat, diag, node, tcpu, wrk, queue = parse_actu_result(out)
        if etat != "ENDED":
            time.sleep(0.5)
    assert run.GetGrav(diag) <= 1, "diag : %s, more details in ~/flasheur/%s.o%s" \
        % (diag, nomjob, jobid)
    # check that $HOME/MULTI/multi_study_`host` exists
    multidir = osp.expandvars(MULTIDIR)
    resdir = osp.join(multidir, '%s_%s' % (nomjob, dict_conf['localhost']))
    assert osp.isfile(osp.join(resdir, nomjob + '.repe', 'parameter'))
    for host in available_hosts.keys():
        host = short_hostname(host)
        if resoncli == "yes":
            resdir = osp.join(multidir, '%s_%s' % (nomjob, host))
            flashdir = osp.join(multidir, '%s_%s' % (nomjob, host), 'flash')
        else:
            # this will fail if MULTIDIR change !
            resdir = '%s:%s' % (host, osp.join('MULTI', '%s_%s' % (nomjob, host)))
            flashdir = '%s:%s' % (host, osp.join('MULTI', '%s_%s' % (nomjob, host), 'flash'))
        assert run.IsDir(resdir), "results on found at %s" % resdir
        assert run.IsDir(flashdir), "flash directory on found at %s" % flashdir
    cmd = dict_conf["as_run"] + ["--del", jobid, nomjob, "interactif"]
    iret, out = execcmd(cmd, "%s.3" % nomjob, return_output=True)
    assert iret == 0

def astout():
    assert len(available_hosts) > 0, "no remote host available."
    run = AsRunFactory()
    prof = AsterProfil()
    nomjob = 'multi_astout'
    resoncli = "yes"
    prof['nomjob'] = nomjob
    prof['actions'] = 'astout'
    prof['version'] = aster_version
    prof['tpsjob'] = 1
    prof['memjob'] = 1024*16
    prof['multiple'] = 'yes'
    prof['multiple_result_on_client'] = resoncli
    lhosts = [dict_conf['localhost'],] + available_hosts.keys()
    #lhosts = available_hosts.keys()
    prof['multiple_server_list'] = " ".join(lhosts)
    flist = osp.join(tmpdir, nomjob + '.list')
    open(flist, 'w').write('ttnl02a\nssls122c')
    prof.add(ExportEntry(flist, type='list', data=True))
    prof.add(ExportEntry(osp.join(tmpdir, nomjob + '.resu_test'),
                         type='resu_test', isrep=True, result=True))
    prof.add(ExportEntry(osp.join(tmpdir, nomjob + '.flash'),
                         type='flash', isrep=True, result=True))

    export = osp.join(tmpdir, "multi_astout.export")
    prof.WriteExportTo(export)
    cmd = dict_conf["as_run"] + ["--serv", export]
    iret, out = execcmd(cmd, "multi_astout.1", return_output=True)
    assert iret == 0
    jobid, queue, studyid = parse_submission_result(out)
    assert jobid.strip() != ""
    assert studyid.strip() != "" and studyid == jobid
    etat = 'RUN'
    while etat != 'ENDED':
        cmd = dict_conf["as_run"] + ["--actu", jobid, nomjob, "interactif"]
        iret, out = execcmd(cmd, "multi_astout.2", return_output=True)
        etat, diag, node, tcpu, wrk, queue = parse_actu_result(out)
        if etat != "ENDED":
            time.sleep(0.5)
    assert run.GetGrav(diag) <= 1, "diag : %s, more details in ~/flasheur/%s.o%s" \
        % (diag, nomjob, jobid)
    # check results
    multidir = osp.expandvars(MULTIDIR)
    for host in lhosts:
        host = short_hostname(host)
        resdir = osp.join(multidir, '%s_%s' % (nomjob, host), nomjob + '.resu_test')
        assert osp.isdir(resdir), "results directory not found: %s" % resdir
        nook = osp.join(resdir, "NOOK")
        assert not osp.isfile(nook), "test(s) failed, see %s" % nook
        res = osp.join(resdir, "RESULTAT")
        assert osp.isfile(res), "result file not found: %s" % res
        # check flash
        flashdir = osp.join(multidir, '%s_%s' % (nomjob, host), nomjob + '.flash')
        assert osp.isdir(flashdir), "flash directory not found: %s" % flashdir
    cmd = dict_conf["as_run"] + ["--del", jobid, nomjob, "interactif"]
    iret, out = execcmd(cmd, "multi_astout.3", return_output=True)
    assert iret == 0


class TestMultiple(unittest.TestCase):

    def test01a_study(self):
        study("yes")

    def test01b_study(self):
        study("no")

    def test02_astout(self):
        astout()


if __name__ == "__main__":
    unittest.main()