Skip to content

Commit fff99af

Browse files
author
Roberto Sora
authored
Add retry to telemetry daemon test (#768)
1 parent 18aefa0 commit fff99af

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Diff for: test/requirements.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ certifi==2019.11.28 # via requests
99
chardet==3.0.4 # via requests
1010
idna==2.8 # via requests
1111
importlib-metadata==1.5.0 # via pluggy, pytest
12-
invoke==1.4.1
12+
invoke==1.4.1 # via -r test/requirements.in
1313
more-itertools==7.1.0 # via pytest
1414
packaging==19.0 # via pytest
1515
pluggy==0.13.1 # via pytest
16-
prometheus-client==0.7.1
16+
prometheus-client==0.7.1 # via -r test/requirements.in
1717
py==1.8.0 # via pytest
1818
pyparsing==2.4.0 # via packaging
19-
pyserial==3.4
20-
pytest-timeout==1.3.4
21-
pytest==5.3.4
22-
pyyaml==5.3
23-
requests==2.22.0
24-
semver==2.9.0
25-
simplejson==3.17.0
19+
pyserial==3.4 # via -r test/requirements.in
20+
pytest-timeout==1.3.4 # via -r test/requirements.in
21+
pytest==5.3.4 # via -r test/requirements.in, pytest-timeout
22+
pyyaml==5.3 # via -r test/requirements.in
23+
requests==2.22.0 # via -r test/requirements.in
24+
semver==2.9.0 # via -r test/requirements.in
25+
simplejson==3.17.0 # via -r test/requirements.in
2626
six==1.12.0 # via packaging
2727
urllib3==1.25.8 # via requests
2828
wcwidth==0.1.7 # via pytest

Diff for: test/test_daemon.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import requests
2121
import yaml
2222
from prometheus_client.parser import text_string_to_metric_families
23+
from requests.adapters import HTTPAdapter
24+
from requests.packages.urllib3.util.retry import Retry
2325

2426

2527
@pytest.mark.timeout(60)
@@ -34,7 +36,10 @@ def test_telemetry_prometheus_endpoint(daemon_runner, data_dir):
3436

3537
# Check if :9090/metrics endpoint is alive,
3638
# telemetry is enabled by default in daemon mode
37-
metrics = requests.get("http://localhost:9090/metrics").text
39+
s = requests.Session()
40+
retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
41+
s.mount('http://', HTTPAdapter(max_retries=retries))
42+
metrics = s.get("http://localhost:9090/metrics").text
3843
family = next(text_string_to_metric_families(metrics))
3944
sample = family.samples[0]
4045
assert inventory["installation"]["id"] == sample.labels["installationID"]

0 commit comments

Comments
 (0)