Skip to content

Commit

Permalink
Re adding test test_jobqueue_cluster_call (dask#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeeb authored Sep 12, 2022
1 parent 045d168 commit 9a66042
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ci/slurm/environment.yml
ci/pbs/environment.yml
ci/sge/environment.yml
ci/htcondor/environment.yml
.vscode/
26 changes: 26 additions & 0 deletions dask_jobqueue/tests/test_job.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio
from time import time
import sys
import re


from dask_jobqueue import PBSCluster, SLURMCluster, SGECluster, OARCluster
Expand Down Expand Up @@ -428,3 +430,27 @@ def test_deprecation_job_extra(Cluster):
)
job_script = job.job_script()
assert "old_param" in job_script


def test_jobqueue_job_call(tmpdir, Cluster):
cluster = Cluster(cores=1, memory="1GB")

path = tmpdir.join("test.py")
path.write('print("this is the stdout")')

out = cluster.job_cls._call([sys.executable, path.strpath])
assert out == "this is the stdout\n"

path_with_error = tmpdir.join("non-zero-exit-code.py")
path_with_error.write('print("this is the stdout")\n1/0')

match = (
"Command exited with non-zero exit code.+"
"Exit code: 1.+"
"stdout:\nthis is the stdout.+"
"stderr:.+ZeroDivisionError"
)

match = re.compile(match, re.DOTALL)
with pytest.raises(RuntimeError, match=match):
cluster.job_cls._call([sys.executable, path_with_error.strpath])
25 changes: 0 additions & 25 deletions dask_jobqueue/tests/test_jobqueue_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,31 +169,6 @@ def test_log_directory(Cluster, tmpdir):
assert os.path.exists(tmpdir.strpath)


@pytest.mark.skip
def test_jobqueue_cluster_call(tmpdir, Cluster):
cluster = Cluster(cores=1, memory="1GB")

path = tmpdir.join("test.py")
path.write('print("this is the stdout")')

out = cluster._call([sys.executable, path.strpath])
assert out == "this is the stdout\n"

path_with_error = tmpdir.join("non-zero-exit-code.py")
path_with_error.write('print("this is the stdout")\n1/0')

match = (
"Command exited with non-zero exit code.+"
"Exit code: 1.+"
"stdout:\nthis is the stdout.+"
"stderr:.+ZeroDivisionError"
)

match = re.compile(match, re.DOTALL)
with pytest.raises(RuntimeError, match=match):
cluster._call([sys.executable, path_with_error.strpath])


def test_cluster_has_cores_and_memory(Cluster):
base_regex = r"{}.+".format(Cluster.__name__)
with pytest.raises(ValueError, match=base_regex + r"cores=\d, memory='\d+GB'"):
Expand Down

0 comments on commit 9a66042

Please sign in to comment.