Skip to content

Commit 9f6f4ab

Browse files
authored
ci: run tests with 2 second http timeout (#18529)
## Description Reduce Test Optimization API requests' timeout to 2 seconds, to avoid CI jobs from timing out when responses are slow. ## Testing <!-- Describe your testing strategy or note what tests are included --> ## Risks <!-- Note any risks associated with this change, or "None" if no risks --> ## Additional Notes <!-- Any other information that would be helpful for reviewers --> Co-authored-by: federico.mon <federico.mon@datadoghq.com>
1 parent 67bb35b commit 9f6f4ab

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

riotfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def select_pys(min_version: str = MIN_PYTHON_VERSION, max_version: str = MAX_PYT
9797
"DD_PYTEST_USE_NEW_PLUGIN": "true",
9898
"DD_TRACE_COMPUTE_STATS": "false",
9999
"DD_CODE_ORIGIN_FOR_SPANS_ENABLED": "false",
100+
"DD_CIVISIBILITY_BACKEND_API_TIMEOUT_MILLIS": "2000", # 2-second timeout
100101
# Enable out-of-session retries for dd-trace-py's own test runs (opt-in feature) so state-leaking flaky tests get a
101102
# clean-slate retry. Only acts on ATR-exhausted failures. See ddtrace/testing/internal/pytest/plugin.py.
102103
"_DD_CIVISIBILITY_OUT_OF_SESSION_RETRIES_ENABLED": "1",

tests/testing/internal/test_http.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ class TestBackendConnector:
2929

3030
def test_constants(self) -> None:
3131
"""Test module constants."""
32-
assert DEFAULT_TIMEOUT_SECONDS == 30.0
32+
# Verify the parsing function returns the correct default when no env var is set
33+
assert _http_module._parse_timeout_millis(None) == 30.0
34+
# Verify the module constant matches what it should be for the current environment
35+
# (may be overridden if env var was set at module import time)
36+
expected = _http_module._parse_timeout_millis(os.environ.get("DD_CIVISIBILITY_BACKEND_API_TIMEOUT_MILLIS"))
37+
assert DEFAULT_TIMEOUT_SECONDS == expected
3338

3439
@patch("http.client.HTTPSConnection")
3540
def test_init_default_parameters(self, mock_https_connection: Mock) -> None:

0 commit comments

Comments
 (0)