Skip to content

Commit 4d92648

Browse files
committed
copy test from broken pr #3232 for scaling in non-running blocks
1 parent e4b1106 commit 4d92648

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import logging
2+
import time
3+
4+
import pytest
5+
6+
import parsl
7+
8+
from parsl import File, python_app
9+
from parsl.jobs.states import JobState, TERMINAL_STATES
10+
from parsl.providers import LocalProvider
11+
from parsl.channels import LocalChannel
12+
from parsl.launchers import SingleNodeLauncher
13+
from parsl.config import Config
14+
from parsl.executors import HighThroughputExecutor
15+
16+
logger = logging.getLogger(__name__)
17+
18+
_max_blocks = 1
19+
_min_blocks = 0
20+
21+
22+
def local_config():
23+
return Config(
24+
executors=[
25+
HighThroughputExecutor(
26+
heartbeat_period=1,
27+
heartbeat_threshold=2,
28+
poll_period=100,
29+
label="htex_local",
30+
address="127.0.0.1",
31+
max_workers=1,
32+
encrypted=True,
33+
launch_cmd="sleep inf",
34+
provider=LocalProvider(
35+
channel=LocalChannel(),
36+
init_blocks=1,
37+
max_blocks=_max_blocks,
38+
min_blocks=_min_blocks,
39+
launcher=SingleNodeLauncher(),
40+
),
41+
)
42+
],
43+
max_idletime=0.5,
44+
strategy='htex_auto_scale',
45+
strategy_period=0.1
46+
)
47+
48+
49+
# see issue #1885 for details of failures of this test.
50+
# at the time of issue #1885 this test was failing frequently
51+
# in CI.
52+
@pytest.mark.local
53+
def test_scaledown_with_register(try_assert):
54+
dfk = parsl.dfk()
55+
htex = dfk.executors['htex_local']
56+
57+
num_managers = len(htex.connected_managers())
58+
assert num_managers == 0, "Expected 0 managers at start"
59+
60+
try_assert(lambda: len(htex.status()),
61+
fail_msg="Expected 1 block at start")
62+
63+
s = htex.status()
64+
assert s['0'].state == JobState.RUNNING, "Expected block to be in RUNNING"
65+
66+
def check_zero_blocks():
67+
s = htex.status()
68+
return len(s) == 1 and s['0'].state in TERMINAL_STATES
69+
70+
try_assert(
71+
check_zero_blocks,
72+
fail_msg="Expected 0 blocks after idle scaledown",
73+
timeout_ms=15000,
74+
)

0 commit comments

Comments
 (0)