Skip to content

Commit 1a4a6db

Browse files
committed
Add test for restoring queue worker resources
1 parent 9f97406 commit 1a4a6db

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/test_journal.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import time
22

3+
from .autoalloc.utils import wait_for_alloc
4+
from .autoalloc.mock.manager import default_job_id
5+
from .utils import wait_for_worker_state
36
from .test_events import read_events
47
from .utils.cmd import python
58
from .autoalloc.mock.mock import MockJobManager
@@ -242,6 +245,36 @@ def test_restore_queues(hq_env: HqEnv, tmp_path, flavor: ManagerFlavor):
242245
assert alloc_list3 == alloc_list4
243246

244247

248+
@all_flavors
249+
def test_restore_queue_worker_resources(hq_env: HqEnv, tmp_path, flavor: ManagerFlavor):
250+
journal_path = os.path.join(tmp_path, "my.journal")
251+
hq_env.start_server(args=["--journal", journal_path])
252+
253+
with MockJobManager(hq_env, flavor.default_handler()) as manager:
254+
add_queue(
255+
hq_env,
256+
manager=flavor.manager_type(),
257+
)
258+
hq_env.command(["submit", "ls"])
259+
260+
job_id = default_job_id(0)
261+
wait_for_alloc(hq_env, "QUEUED", job_id)
262+
263+
manager.handler.add_worker(hq_env, job_id)
264+
wait_for_worker_state(hq_env, [1], "RUNNING")
265+
266+
alloc_list = hq_env.command(["--output-mode=json", "alloc", "list"], as_json=True)
267+
worker_resources = alloc_list[0]["known_worker_resources"]
268+
assert worker_resources is not None
269+
270+
hq_env.stop_server()
271+
hq_env.start_server(args=["--journal", journal_path])
272+
273+
alloc_list2 = hq_env.command(["--output-mode=json", "alloc", "list"], as_json=True)
274+
current_worker_resources = alloc_list2[0]["known_worker_resources"]
275+
assert worker_resources == current_worker_resources
276+
277+
245278
def test_restore_open_job_more_jobs(hq_env: HqEnv, tmp_path):
246279
journal_path = os.path.join(tmp_path, "my.journal")
247280
hq_env.start_server(args=["--journal", journal_path])

0 commit comments

Comments
 (0)