-
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.
Fix these expressions just a little and add a simple test for systemd adapter and it's launcher.
- Loading branch information
Showing
3 changed files
with
73 additions
and
16 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
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 |
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,15 @@ | ||
require 'test_helper' | ||
|
||
class SystemdTest < Minitest::Test | ||
include TestHelper | ||
|
||
def systemd_instance(config = { }) | ||
OodCore::Job::Factory.build({ adapter: 'systemd' }.merge(config)) | ||
end | ||
|
||
def test_instantiation | ||
sysd = systemd_instance | ||
|
||
refute_nil(sysd) | ||
end | ||
end |