-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init and add some tests for the systemd launcher
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'test_helper' | ||
require 'ood_core/job/adapters/systemd' | ||
require 'ood_core/job/adapters/systemd/launcher' | ||
|
||
class SystemdLauncherTest < Minitest::Test | ||
include TestHelper | ||
|
||
def launcher_instance(config = {}) | ||
default = { ssh_hosts: ['foo'], submit_host: 'localhost' } | ||
OodCore::Job::Adapters::LinuxSystemd::Launcher.new(**default.merge(config)) | ||
end | ||
|
||
def setup | ||
Etc.stubs(:getlogin).returns('testuser') | ||
end | ||
|
||
def test_instantiation | ||
launcher = launcher_instance | ||
|
||
refute_nil(launcher) | ||
end | ||
|
||
def test_ssh_cmd_default | ||
launcher = launcher_instance | ||
expected = [ 'ssh', '-t', '-p', '22', '-o', | ||
'Batchmode=yes', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', | ||
'testuser@localhost', '/bin/bash' | ||
] | ||
|
||
assert_equal(expected, launcher.send(:ssh_cmd, 'localhost', ['/bin/bash'])) | ||
end | ||
|
||
def test_ssh_cmd_with_host_checking | ||
launcher = launcher_instance({ strict_host_checking: true }) | ||
expected = [ 'ssh', '-t', '-p', '22', '-o', | ||
'Batchmode=yes', 'testuser@localhost', '/bin/bash' | ||
] | ||
|
||
assert_equal(expected, launcher.send(:ssh_cmd, 'localhost', ['/bin/bash'])) | ||
end | ||
|
||
def test_ssh_cmd_with_keyfile | ||
launcher = launcher_instance({ ssh_keyfile: "~/.ssh/my_key" }) | ||
expected = [ 'ssh', '-t', '-p', '22', '-o', | ||
'Batchmode=yes', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', | ||
'-i', '~/.ssh/my_key', 'testuser@localhost', '/bin/bash' | ||
] | ||
|
||
assert_equal(expected, launcher.send(:ssh_cmd, 'localhost', ['/bin/bash'])) | ||
end | ||
end |