コード例 #1
0
 def test_run_condor_retcode():
     'It test that we can run condor job and get the retcode'
     bin = create_test_binary()
     #a simple job
     cmd = [bin]
     cmd.extend(['-r', '10'])
     popen = Popen(cmd, runner_conf={'transfer_executable':True})
     assert popen.wait() == 10 #waits till finishes and looks to the retcode
     os.remove(bin)
コード例 #2
0
 def test_run_condor_kill():
     'It test that we can kill a condor job'
     bin = create_test_binary()
     #a simple job
     cmd = [bin]
     cmd.extend(['-w'])
     popen = Popen(cmd, runner_conf={'transfer_executable':True})
     pid = str(popen.pid)
     popen.kill()
     stdout = call(['condor_q', pid])[0]
     assert pid not in stdout
     os.remove(bin)
コード例 #3
0
 def test_run_condor_stdout():
     'It test that we can run condor job and retrieve stdout and stderr'
     bin = create_test_binary()
     #a simple job
     cmd = [bin]
     cmd.extend(['-o', 'hola', '-e', 'caracola'])
     stdout = NamedTemporaryFile()
     stderr = NamedTemporaryFile()
     popen = Popen(cmd, runner_conf={'transfer_executable':True},
                   stdout=stdout, stderr=stderr)
     assert popen.wait() == 0 #waits till finishes and looks to the retcode
     assert open(stdout.name).read() == 'hola'
     assert open(stderr.name).read() == 'caracola'
     os.remove(bin)
コード例 #4
0
 def test_run_condor_stdin():
     'It test that we can run condor job with stdin'
     bin = create_test_binary()
     #a simple job
     cmd = [bin]
     cmd.extend(['-s'])
     stdin  = NamedTemporaryFile()
     stdout = NamedTemporaryFile()
     stdin.write('hola')
     stdin.flush()
     popen = Popen(cmd, runner_conf={'transfer_executable':True},
                   stdout=stdout, stdin=stdin)
     assert popen.wait() == 0 #waits till finishes and looks to the retcode
     assert open(stdout.name).read() == 'hola'
     os.remove(bin)
コード例 #5
0
    def test_run_condor_in_file():
        'It test that we can run condor job with an input file'
        bin = create_test_binary()

        in_file = NamedTemporaryFile()
        in_file.write('hola')
        in_file.flush()

        cmd = [bin]
        cmd.extend(['-i', in_file.name])
        stdout = NamedTemporaryFile()
        stderr = NamedTemporaryFile()
        cmd_def = [{'options': ('-i', '--input'), 'io': 'in'}]
        popen = Popen(cmd, runner_conf={'transfer_executable':True},
                      stdout=stdout, stderr=stderr, cmd_def=cmd_def)

        assert popen.wait() == 0 #waits till finishes and looks to the retcod
        assert open(stdout.name).read() == 'hola'
        os.remove(bin)
コード例 #6
0
    def test_run_condor_in_out_file(self):
        'It test that we can run condor job with an output file'
        bin = create_test_binary()

        in_file = NamedTemporaryFile()
        in_file.write('hola')
        in_file.flush()
        out_file = open('output.txt', 'w')

        cmd = [bin]
        cmd.extend(['-i', in_file.name, '-t', out_file.name])
        stdout = NamedTemporaryFile()
        stderr = NamedTemporaryFile()
        cmd_def = [{'options': ('-i', '--input'), 'io': 'in'},
                   {'options': ('-t', '--output'), 'io': 'out'}]
        popen = Popen(cmd, runner_conf={'transfer_executable':True},
                      stdout=stdout, stderr=stderr, cmd_def=cmd_def)
        popen.wait()
        assert popen.wait() == 0 #waits till finishes and looks to the retcod
        assert open(out_file.name).read() == 'hola'
        os.remove(out_file.name)

        #and output file with path won't be allowed unless the transfer file
        #mechanism is not used
        out_file = NamedTemporaryFile()

        cmd = [bin]
        cmd.extend(['-i', in_file.name, '-t', out_file.name])
        stdout = NamedTemporaryFile()
        stderr = NamedTemporaryFile()
        cmd_def = [{'options': ('-i', '--input'), 'io': 'in'},
                   {'options': ('-t', '--output'), 'io': 'out'}]
        try:
            popen = Popen(cmd, runner_conf={'transfer_executable':True},
                          stdout=stdout, stderr=stderr, cmd_def=cmd_def)
            self.fail('ValueError expected')
            #pylint: disable-msg=W0704
        except ValueError:
            pass
        os.remove(bin)