Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip changelog] Add retry to telemetry daemon test #768

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/requirements.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"]