File size: 982 Bytes
d13981b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Tests for OPSD hang-debug logging switches."""

import importlib.util
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def _load_debug_log_module():
    spec = importlib.util.spec_from_file_location(
        "opsd_debug_log_for_test",
        ROOT / "opsd_utils" / "debug_log.py",
    )
    module = importlib.util.module_from_spec(spec)
    assert spec.loader is not None
    spec.loader.exec_module(module)
    return module


def test_force_hang_probe_can_be_disabled(capsys):
    opsd_debug = _load_debug_log_module()
    opsd_debug.configure(rank=0, world_size=1, hang_force=False)

    opsd_debug.hang_probe_force("forced_probe")

    assert "OPSD-HANGDBG" not in capsys.readouterr().out


def test_force_hang_probe_logs_by_default(capsys):
    opsd_debug = _load_debug_log_module()
    opsd_debug.configure(rank=0, world_size=1, hang_force=True)

    opsd_debug.hang_probe_force("forced_probe")

    assert "OPSD-HANGDBG" in capsys.readouterr().out