test: fix templates paths, CLI gating, and stress-suite harness

- tests/**: update templates/ → decnet/templates/ paths after module move
- tests/mysql_spinup.sh: use root:root and asyncmy driver
- tests/test_auto_spawn.py: patch decnet.cli.utils._pid_dir (package split)
- tests/test_cli.py: set DECNET_MODE=master in api-command tests
- tests/stress/conftest.py: run locust out-of-process via its CLI + CSV
  stats shim to avoid urllib3 RecursionError from late gevent monkey-patch;
  raise uvicorn startup timeout to 60s, accept 401 from auth-gated health,
  strip inherited DECNET_* env, surface stderr on 0-request runs
- tests/stress/test_stress.py: loosen baseline thresholds to match hw
This commit is contained in:
2026-04-19 23:50:53 -04:00
parent 262a84ca53
commit 195580c74d
22 changed files with 219 additions and 60 deletions

View File

@@ -349,7 +349,9 @@ class TestCorrelateCommand:
class TestApiCommand:
@patch("os.killpg")
@patch("subprocess.Popen")
def test_api_keyboard_interrupt(self, mock_popen, mock_killpg):
def test_api_keyboard_interrupt(self, mock_popen, mock_killpg, monkeypatch):
monkeypatch.setenv("DECNET_MODE", "master")
monkeypatch.delenv("DECNET_DISALLOW_MASTER", raising=False)
proc = MagicMock()
proc.wait.side_effect = [KeyboardInterrupt, 0]
proc.pid = 4321
@@ -359,7 +361,9 @@ class TestApiCommand:
mock_killpg.assert_called()
@patch("subprocess.Popen", side_effect=FileNotFoundError)
def test_api_not_found(self, mock_popen):
def test_api_not_found(self, mock_popen, monkeypatch):
monkeypatch.setenv("DECNET_MODE", "master")
monkeypatch.delenv("DECNET_DISALLOW_MASTER", raising=False)
result = runner.invoke(app, ["api"])
assert result.exit_code == 0