|
10 | 10 | import pytest
|
11 | 11 | import requests
|
12 | 12 | import urllib3
|
| 13 | + |
| 14 | +import tests.apps.flask_app # noqa: F401 |
13 | 15 | from instana.instrumentation.urllib3 import (
|
14 | 16 | _collect_kvs as collect_kvs,
|
15 |
| - extract_custom_headers, |
| 17 | +) |
| 18 | +from instana.instrumentation.urllib3 import ( |
16 | 19 | collect_response,
|
| 20 | + extract_custom_headers, |
17 | 21 | )
|
18 | 22 | from instana.singletons import agent, tracer
|
19 |
| - |
20 |
| -import tests.apps.flask_app # noqa: F401 |
21 | 23 | from tests.helpers import testenv
|
22 | 24 |
|
23 | 25 | if TYPE_CHECKING:
|
24 |
| - from instana.span.span import InstanaSpan |
25 | 26 | from pytest import LogCaptureFixture
|
26 | 27 |
|
| 28 | + from instana.span.span import InstanaSpan |
| 29 | + |
27 | 30 |
|
28 | 31 | class TestUrllib3:
|
29 | 32 | @pytest.fixture(autouse=True)
|
@@ -82,7 +85,7 @@ def make_request(u=None) -> int:
|
82 | 85 |
|
83 | 86 | threadpool_size = 15
|
84 | 87 | pool = ThreadPool(processes=threadpool_size)
|
85 |
| - res = pool.map(make_request, [u for u in range(threadpool_size)]) |
| 88 | + _ = pool.map(make_request, [u for u in range(threadpool_size)]) |
86 | 89 | # print(f'requests made within threadpool, instana does not instrument - statuses: {res}')
|
87 | 90 |
|
88 | 91 | spans = self.recorder.queued_spans()
|
@@ -136,6 +139,7 @@ def test_get_request(self):
|
136 | 139 | assert isinstance(urllib3_span.stack, list)
|
137 | 140 | assert len(urllib3_span.stack) > 1
|
138 | 141 |
|
| 142 | + @pytest.mark.flaky(reruns=3, reruns_delay=2) |
139 | 143 | def test_get_request_https(self):
|
140 | 144 | request_url = "https://reqres.in:443/api/users"
|
141 | 145 | with tracer.start_as_current_span("test"):
|
@@ -631,7 +635,9 @@ def test_exception_logging(self):
|
631 | 635 | assert test_span.data["sdk"]["name"] == "test"
|
632 | 636 | assert urllib3_span.n == "urllib3"
|
633 | 637 | assert urllib3_span.data["http"]["status"] == 500
|
634 |
| - assert urllib3_span.data["http"]["url"] == testenv["flask_server"] + "/exception" |
| 638 | + assert ( |
| 639 | + urllib3_span.data["http"]["url"] == testenv["flask_server"] + "/exception" |
| 640 | + ) |
635 | 641 | assert urllib3_span.data["http"]["method"] == "GET"
|
636 | 642 | assert urllib3_span.stack
|
637 | 643 | assert isinstance(urllib3_span.stack, list)
|
|
0 commit comments