Skip to content

Commit

Permalink
Add retry to telemetry daemon test (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Sora committed Jun 29, 2020
1 parent 18aefa0 commit fff99af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
18 changes: 9 additions & 9 deletions test/requirements.txt
Expand Up @@ -9,20 +9,20 @@ certifi==2019.11.28 # via requests
chardet==3.0.4 # via requests
idna==2.8 # via requests
importlib-metadata==1.5.0 # via pluggy, pytest
invoke==1.4.1
invoke==1.4.1 # via -r test/requirements.in
more-itertools==7.1.0 # via pytest
packaging==19.0 # via pytest
pluggy==0.13.1 # via pytest
prometheus-client==0.7.1
prometheus-client==0.7.1 # via -r test/requirements.in
py==1.8.0 # via pytest
pyparsing==2.4.0 # via packaging
pyserial==3.4
pytest-timeout==1.3.4
pytest==5.3.4
pyyaml==5.3
requests==2.22.0
semver==2.9.0
simplejson==3.17.0
pyserial==3.4 # via -r test/requirements.in
pytest-timeout==1.3.4 # via -r test/requirements.in
pytest==5.3.4 # via -r test/requirements.in, pytest-timeout
pyyaml==5.3 # via -r test/requirements.in
requests==2.22.0 # via -r test/requirements.in
semver==2.9.0 # via -r test/requirements.in
simplejson==3.17.0 # via -r test/requirements.in
six==1.12.0 # via packaging
urllib3==1.25.8 # via requests
wcwidth==0.1.7 # via pytest
Expand Down
7 changes: 6 additions & 1 deletion test/test_daemon.py
Expand Up @@ -20,6 +20,8 @@
import requests
import yaml
from prometheus_client.parser import text_string_to_metric_families
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry


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

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

0 comments on commit fff99af

Please sign in to comment.