Skip to content

Commit dbb8ead

Browse files
committed
Don't use remote server in tests..
1 parent 75398f9 commit dbb8ead

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/tracing/test_trace_propagation.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sentry_sdk
44
from http.client import HTTPConnection
55

6+
from tests.conftest import create_mock_http_server
7+
68
USE_DEFAULT_TRACES_SAMPLE_RATE = -1
79

810
INCOMING_TRACE_ID = "771a43a4192642f0b136d5159a501700"
@@ -18,12 +20,12 @@
1820
),
1921
}
2022

23+
PORT = create_mock_http_server()
24+
2125

22-
#
2326
# Proper high level testing for trace propagation.
2427
# Testing the matrix of test cases described here:
2528
# https://develop.sentry.dev/sdk/telemetry/traces/trace-propagation-cheat-sheet/
26-
#
2729

2830

2931
@pytest.fixture
@@ -71,7 +73,7 @@ def test_no_incoming_trace_and_trace_propagation_targets_matching(
7173

7274
with sentry_sdk.continue_trace(NO_INCOMING_HEADERS):
7375
with sentry_sdk.start_span(op="test", name="test"):
74-
requests.get("http://example.com")
76+
requests.get(f"http://localhost:{PORT}") # noqa:E231
7577

7678
# CHECK if performance data (a transaction/span) is sent to Sentry
7779
if traces_sample_rate == 1:
@@ -122,7 +124,7 @@ def test_no_incoming_trace_and_trace_propagation_targets_not_matching(
122124

123125
with sentry_sdk.continue_trace(NO_INCOMING_HEADERS):
124126
with sentry_sdk.start_span(op="test", name="test"):
125-
requests.get("http://example.com")
127+
requests.get(f"http://localhost:{PORT}") # noqa:E231
126128

127129
# CHECK if performance data (a transaction/span) is sent to Sentry
128130
if traces_sample_rate == 1:
@@ -187,7 +189,7 @@ def test_with_incoming_trace_and_trace_propagation_targets_matching(
187189

188190
with sentry_sdk.continue_trace(incoming_headers):
189191
with sentry_sdk.start_span(op="test", name="test"):
190-
requests.get("http://example.com")
192+
requests.get(f"http://localhost:{PORT}") # noqa:E231
191193

192194
# CHECK if performance data (a transaction/span) is sent to Sentry
193195
if (
@@ -265,7 +267,7 @@ def test_with_incoming_trace_and_trace_propagation_targets_not_matching(
265267

266268
with sentry_sdk.continue_trace(incoming_headers):
267269
with sentry_sdk.start_span(op="test", name="test"):
268-
requests.get("http://example.com")
270+
requests.get(f"http://localhost:{PORT}") # noqa:E231
269271

270272
# CHECK if performance data (a transaction/span) is sent to Sentry
271273
if (

0 commit comments

Comments
 (0)