Skip to content

Commit 5baca76

Browse files
committed
test dev for #3235
1 parent 39f0d8a commit 5baca76

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import logging
2+
import parsl
3+
import pytest
4+
from parsl.executors import HighThroughputExecutor
5+
from parsl import Config
6+
from parsl.providers import LocalProvider
7+
from parsl.executors.errors import BadStateException
8+
from parsl.jobs.states import JobStatus, JobState
9+
10+
11+
class FailingProvider(LocalProvider):
12+
def submit(*args, **kwargs):
13+
raise RuntimeError("Deliberate failure of provider.submit")
14+
15+
16+
def local_config():
17+
"""Config to simulate failing blocks without connecting"""
18+
return Config(
19+
executors=[
20+
HighThroughputExecutor(
21+
label="HTEX",
22+
heartbeat_period=1,
23+
heartbeat_threshold=2,
24+
poll_period=100,
25+
max_workers_per_node=1,
26+
provider=FailingProvider(
27+
init_blocks=0,
28+
max_blocks=2,
29+
min_blocks=0,
30+
),
31+
)
32+
],
33+
max_idletime=0.5,
34+
strategy='htex_auto_scale',
35+
strategy_period=0.1
36+
# this strategy period needs to be a few times smaller than the
37+
# status_polling_interval of FailingProvider, which is 5s at
38+
# time of writing
39+
)
40+
41+
42+
@parsl.python_app
43+
def double(x):
44+
return x * 2
45+
46+
47+
@pytest.mark.local
48+
def test_disconnected_blocks():
49+
"""Test reporting of blocks that fail to connect from HTEX"""
50+
dfk = parsl.dfk()
51+
executor = dfk.executors["HTEX"]
52+
53+
connected_blocks = executor.connected_blocks()
54+
assert not connected_blocks, "Expected 0 blocks"
55+
56+
future = double(5)
57+
with pytest.raises(BadStateException):
58+
future.result()
59+
60+
assert isinstance(future.exception(), BadStateException)
61+
62+
status_dict = executor.status()
63+
assert len(status_dict) == 1, "Expected exactly 1 block"
64+
for status in status_dict.values():
65+
assert isinstance(status, JobStatus)
66+
assert status.state == JobState.MISSING
67+
68+
connected_blocks = executor.connected_blocks()
69+
assert not connected_blocks, "Expected exactly 0 connected blocks"

0 commit comments

Comments
 (0)