Skip to content

Commit 507d6c8

Browse files
committed
ci: Add rerun failures package for flaky tests
Signed-off-by: Cagri Yonca <cagri@ibm.com>
1 parent ce94a54 commit 507d6c8

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ dev = [
6262
"pytest",
6363
"pytest-cov",
6464
"pytest-mock",
65+
"pytest-rerunfailures",
6566
"pre-commit>=3.0.0",
6667
"ruff"
6768
]

tests/clients/test_urllib3.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@
1010
import pytest
1111
import requests
1212
import urllib3
13+
14+
import tests.apps.flask_app # noqa: F401
1315
from instana.instrumentation.urllib3 import (
1416
_collect_kvs as collect_kvs,
15-
extract_custom_headers,
17+
)
18+
from instana.instrumentation.urllib3 import (
1619
collect_response,
20+
extract_custom_headers,
1721
)
1822
from instana.singletons import agent, tracer
19-
20-
import tests.apps.flask_app # noqa: F401
2123
from tests.helpers import testenv
2224

2325
if TYPE_CHECKING:
24-
from instana.span.span import InstanaSpan
2526
from pytest import LogCaptureFixture
2627

28+
from instana.span.span import InstanaSpan
29+
2730

2831
class TestUrllib3:
2932
@pytest.fixture(autouse=True)
@@ -82,7 +85,7 @@ def make_request(u=None) -> int:
8285

8386
threadpool_size = 15
8487
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)])
8689
# print(f'requests made within threadpool, instana does not instrument - statuses: {res}')
8790

8891
spans = self.recorder.queued_spans()
@@ -136,6 +139,7 @@ def test_get_request(self):
136139
assert isinstance(urllib3_span.stack, list)
137140
assert len(urllib3_span.stack) > 1
138141

142+
@pytest.mark.flaky(reruns=3, reruns_delay=2)
139143
def test_get_request_https(self):
140144
request_url = "https://reqres.in:443/api/users"
141145
with tracer.start_as_current_span("test"):
@@ -631,7 +635,9 @@ def test_exception_logging(self):
631635
assert test_span.data["sdk"]["name"] == "test"
632636
assert urllib3_span.n == "urllib3"
633637
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+
)
635641
assert urllib3_span.data["http"]["method"] == "GET"
636642
assert urllib3_span.stack
637643
assert isinstance(urllib3_span.stack, list)

0 commit comments

Comments
 (0)