forked from Snakemake-Profiles/lsf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Snakemake-Profiles:master' into master
- Loading branch information
Showing
13 changed files
with
344 additions
and
57 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
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 |
---|---|---|
@@ -1,18 +1,35 @@ | ||
{ | ||
"LSF_UNIT_FOR_LIMITS": ["KB", "MB", "GB", "TB", "PB", "EB", "ZB"], | ||
"UNKWN_behaviour": ["wait", "kill"], | ||
"ZOMBI_behaviour": ["ignore", "kill"], | ||
"LSF_UNIT_FOR_LIMITS": [ | ||
"KB", | ||
"MB", | ||
"GB", | ||
"TB", | ||
"PB", | ||
"EB", | ||
"ZB" | ||
], | ||
"UNKWN_behaviour": [ | ||
"wait", | ||
"kill" | ||
], | ||
"ZOMBI_behaviour": [ | ||
"ignore", | ||
"kill" | ||
], | ||
"latency_wait": 5, | ||
"use_conda": false, | ||
"use_singularity": false, | ||
"restart_times": 0, | ||
"print_shell_commands": false, | ||
"jobs": 500, | ||
"default_mem_mb": 1024, | ||
"default_threads": 1, | ||
"default_cluster_logdir": "logs/cluster", | ||
"default_queue": "", | ||
"default_project": "", | ||
"max_status_checks_per_second": 10, | ||
"max_jobs_per_second": 10, | ||
"max_status_checks": 1, | ||
"wait_between_tries": 0.001, | ||
"jobscript_timeout": 10, | ||
"profile_name": "lsf" | ||
} | ||
} |
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,136 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
|
||
from tests.src.OSLayer import OSLayer | ||
from tests.src.lsf_cancel import kill_jobs, parse_input, KILL | ||
|
||
|
||
class TestParseInput(unittest.TestCase): | ||
script = "lsf_cancel.py" | ||
|
||
def test_parse_input_no_args(self): | ||
fake_args = [self.script] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
assert not actual | ||
|
||
def test_parse_input_one_job_no_log(self): | ||
fake_args = [self.script, "1234"] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
expected = fake_args[1:] | ||
assert actual == expected | ||
|
||
def test_parse_input_one_job_and_log(self): | ||
fake_args = [self.script, "1234", "log/file.out"] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
expected = [fake_args[1]] | ||
assert actual == expected | ||
|
||
def test_parse_input_two_jobs_and_log(self): | ||
fake_args = [self.script, "1234", "log/file.out", "9090", "log/other.out"] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
expected = [fake_args[1], fake_args[3]] | ||
assert actual == expected | ||
|
||
def test_parse_input_two_jobs_and_digits_in_log(self): | ||
fake_args = [self.script, "1234", "log/file.out", "9090", "log/123"] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
expected = [fake_args[1], fake_args[3]] | ||
assert actual == expected | ||
|
||
def test_parse_input_multiple_args_but_no_jobs(self): | ||
fake_args = [self.script, "log/file.out", "log/123"] | ||
with patch("sys.argv", fake_args): | ||
actual = parse_input() | ||
|
||
assert not actual | ||
|
||
|
||
class TestKillJobs(unittest.TestCase): | ||
@patch.object( | ||
OSLayer, | ||
OSLayer.run_process.__name__, | ||
return_value=( | ||
"Job <123> is being terminated", | ||
"", | ||
), | ||
) | ||
def test_kill_jobs_one_job( | ||
self, | ||
run_process_mock, | ||
): | ||
jobids = ["123"] | ||
expected_kill_cmd = "{} {}".format(KILL, " ".join(jobids)) | ||
|
||
kill_jobs(jobids) | ||
|
||
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False) | ||
|
||
@patch.object( | ||
OSLayer, | ||
OSLayer.run_process.__name__, | ||
return_value=( | ||
"Job <123> is being terminated\nJob <456> is being terminated", | ||
"", | ||
), | ||
) | ||
def test_kill_jobs_two_jobs( | ||
self, | ||
run_process_mock, | ||
): | ||
jobids = ["123", "456"] | ||
expected_kill_cmd = "{} {}".format(KILL, " ".join(jobids)) | ||
|
||
kill_jobs(jobids) | ||
|
||
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False) | ||
|
||
@patch.object( | ||
OSLayer, | ||
OSLayer.run_process.__name__, | ||
return_value=("", ""), | ||
) | ||
def test_kill_jobs_no_jobs( | ||
self, | ||
run_process_mock, | ||
): | ||
jobids = [] | ||
|
||
kill_jobs(jobids) | ||
|
||
run_process_mock.assert_not_called() | ||
|
||
@patch.object( | ||
OSLayer, | ||
OSLayer.run_process.__name__, | ||
return_value=("", ""), | ||
) | ||
def test_kill_jobs_empty_jobs(self, run_process_mock): | ||
jobids = ["", ""] | ||
|
||
kill_jobs(jobids) | ||
|
||
run_process_mock.assert_not_called() | ||
|
||
@patch.object( | ||
OSLayer, | ||
OSLayer.run_process.__name__, | ||
return_value=("", ""), | ||
) | ||
def test_kill_jobs_empty_job_and_non_empty_job(self, run_process_mock): | ||
jobids = ["", "123"] | ||
|
||
expected_kill_cmd = "{} {}".format(KILL, " ".join(jobids)) | ||
|
||
kill_jobs(jobids) | ||
|
||
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False) |
Oops, something went wrong.