-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
61 lines (49 loc) · 2.06 KB
/
conftest.py
File metadata and controls
61 lines (49 loc) · 2.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Pytest configuration for probe-cycle benchmarks (not collected with default ``tests/``)."""
from __future__ import annotations
import os
import sys
from pathlib import Path
# Benchmarks do not load ``tests/conftest.py``; mirror slack/test env so ``paperscout.config`` can import.
os.environ.setdefault("_PAPERSCOUT_TESTING", "1")
os.environ.setdefault("SLACK_BOT_TOKEN", "xoxb-benchmark")
os.environ.setdefault("SLACK_SIGNING_SECRET", "benchmark-secret")
import pytest
# Repo root so ``from tests.conftest import ...`` resolves when only ``benchmarks/`` is targeted.
_ROOT = Path(__file__).resolve().parents[1]
if str(_ROOT) not in sys.path:
sys.path.insert(0, str(_ROOT))
def pytest_addoption(parser):
parser.addoption(
"--bench-http-concurrency",
type=int,
default=5,
help="HTTP concurrency cap for ISOProber during benchmark (maps to Settings.http_concurrency).",
)
parser.addoption(
"--bench-poll-interval-minutes",
type=int,
default=30,
help="Settings.poll_interval_minutes (recorded in metrics; scheduler not exercised here).",
)
parser.addoption(
"--bench-per-request-delay-ms",
type=float,
default=0.15,
help="Simulated server delay per HEAD/GET in the mock transport (milliseconds).",
)
def pytest_configure(config):
if config.getoption("--bench-http-concurrency") <= 0:
raise pytest.UsageError("--bench-http-concurrency must be positive")
if config.getoption("--bench-poll-interval-minutes") <= 0:
raise pytest.UsageError("--bench-poll-interval-minutes must be positive")
if config.getoption("--bench-per-request-delay-ms") < 0:
raise pytest.UsageError("--bench-per-request-delay-ms must be non-negative")
config.addinivalue_line(
"markers",
"benchmark: probe cycle performance / regression (run via ``pytest benchmarks/ -m benchmark``).",
)
@pytest.fixture
def fake_pool():
"""Fresh in-memory pool (same as ``tests/conftest``)."""
from tests.conftest import FakePool
return FakePool()