|
1 | 1 | import time |
2 | 2 |
|
| 3 | +from .utils.wait import wait_until |
3 | 4 | from .utils.cmd import python |
4 | 5 | from .autoalloc.mock.mock import MockJobManager |
5 | 6 | from .autoalloc.mock.slurm import SlurmManager, adapt_slurm |
@@ -270,3 +271,28 @@ def test_restore_open_job_more_submits(hq_env: HqEnv, tmp_path): |
270 | 271 | table.check_row_value("Tasks", "3; Ids: 0-2") |
271 | 272 | hq_env.start_worker() |
272 | 273 | wait_for_job_state(hq_env, 1, "OPENED") |
| 274 | + |
| 275 | + |
| 276 | +def test_restore_streaming(hq_env: HqEnv, tmp_path): |
| 277 | + journal_path = os.path.join(tmp_path, "my.journal") |
| 278 | + stream_path = os.path.join(tmp_path, "stream") |
| 279 | + os.mkdir(stream_path) |
| 280 | + hq_env.start_server(args=["--journal", journal_path]) |
| 281 | + hq_env.start_worker() |
| 282 | + hq_env.command(["job", "open"]) |
| 283 | + hq_env.command( |
| 284 | + ["job", "submit", "--job=1", "--stream", stream_path, "--", "bash", "-c", "echo $HQ_INSTANCE_ID; sleep 2"] |
| 285 | + ) |
| 286 | + wait_for_job_state(hq_env, 1, "RUNNING") |
| 287 | + hq_env.stop_server() |
| 288 | + hq_env.start_server(args=["--journal", journal_path]) |
| 289 | + |
| 290 | + table = hq_env.command(["job", "info", "1"], as_table=True) |
| 291 | + table.check_row_value("Stdout", "<Stream>") |
| 292 | + table.check_row_value("Stderr", "<Stream>") |
| 293 | + hq_env.start_worker() |
| 294 | + hq_env.command(["job", "close", "1"]) |
| 295 | + wait_for_job_state(hq_env, 1, "FINISHED") |
| 296 | + assert int(hq_env.command(["read", stream_path, "cat", "1", "stdout"])) > 0 |
| 297 | + table = hq_env.command(["read", stream_path, "summary"], as_table=True) |
| 298 | + table.check_row_value("Superseded streams", "1") |
0 commit comments