Example #1
0
def test_ssh_init_nolive(proc, ssh):
    proc.sshRunner = Diot(ssh=ssh,
                          servers=['a', 'b', 'c', 'd'],
                          keys=['server1', 'server2', 'server3', 'wrongkey'],
                          checkAlive=True)
    with pytest.raises(RunnerSshError):
        RunnerSsh(0, proc)
Example #2
0
def test_ssh_init_nocheck(proc, ssh):
    proc.sshRunner = Diot(ssh=ssh,
                          servers=['server1', 'server2', 'server3', 'server4'],
                          keys=['server1', 'server2', 'server3', 'wrongkey'],
                          checkAlive=False)
    r = RunnerSsh(0, proc)
    assert RunnerSsh.LIVE_SERVERS == [0, 1, 2, 3]
    assert r.ssh.keywords['t'] == 'server1'
Example #3
0
def test_ssh_init_checktimeout(proc, ssh):
    proc.sshRunner = Diot(
        ssh=ssh,
        servers=['server1', 'server2', 'server3', 'server4'],
        keys=['server1', 'server2', 'server3+2.5', 'wrongkey'],
        checkAlive=2)
    r = RunnerSsh(0, proc)
    assert RunnerSsh.LIVE_SERVERS == [0, 1]
    assert r.ssh.keywords['t'] == 'server1'
Example #4
0
def test_ssh_scriptparts(proc):
    proc.sshRunner = Diot(ssh=ssh, servers=['server1'], checkAlive=False)
    r = RunnerSsh(0, proc)
    r.dir.mkdir()
    (r.dir / 'job.script').write_text('#!/usr/bin/env bash')
    r.script.write_text('#!/usr/bin/env bash')
    assert r.scriptParts.header == '#\n# Running job on server: server1\n#'
    assert r.scriptParts.pre == "\ncd %s" % cmdy._shquote(os.getcwd())
    assert r.scriptParts.post == ''
    assert r.scriptParts.saveoe == True
    assert r.scriptParts.command == [str(r.dir / 'job.script')]
Example #5
0
def test_ssh_impl(proc, ssh):
    proc.sshRunner = Diot(ssh=ssh, servers=['server1'], checkAlive=False)
    r = RunnerSsh(0, proc)
    assert not r.isRunningImpl()
    dbox = r.submitImpl()
    assert dbox.rc == RC_ERROR_SUBMISSION
    assert dbox.pid == -1
    assert 'is not using the same file system as the local machine' in dbox.stderr

    r.dir.mkdir()
    r.script.write_text('#!/usr/bin/env bash\nsleep 3')
    cmd = r.submitImpl()
    assert cmd.rc == 0
    assert r.pid == cmd.pid
    assert r.isRunningImpl()
    r.killImpl()
    assert not r.isRunningImpl()
Example #6
0
def test_ssh_isserveralive(server, key, timeout, expt, ssh):
    assert RunnerSsh.isServerAlive(server, key, timeout=timeout,
                                   ssh=ssh) == expt