diff options
author | Benoit HERARD <benoit.herard@orange.com> | 2017-08-16 14:12:47 +0200 |
---|---|---|
committer | Benoit HERARD <benoit.herard@orange.com> | 2017-08-16 15:32:12 +0200 |
commit | 219391918bd42af63bc170712ba6268e7f009b76 (patch) | |
tree | c1d2047a08e505da4abe9391fedfc9bb8ea6328b | |
parent | fbdbdc076ba233e1add79a48616444116231ec4a (diff) |
Use separate timeouts for connection and reading.
Use a short timeout for connection timeout to avoid to slow down testcase
when remote recording API is not available and use a longer one to read data
from API on successfull connections.
Change-Id: I743c02f890059bf55b47cb4240d52fe0741f7cae
Signed-off-by: Benoit HERARD <benoit.herard@orange.com>
-rw-r--r-- | functest/energy/energy.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/functest/energy/energy.py b/functest/energy/energy.py index 580bc6b0..c410e84f 100644 --- a/functest/energy/energy.py +++ b/functest/energy/energy.py @@ -16,6 +16,7 @@ import urllib from functools import wraps import requests +import urllib3 import functest.utils.functest_utils as ft_utils @@ -76,7 +77,7 @@ class EnergyRecorder(object): INITIAL_STEP = "running" # Default connection timeout - CONNECTION_TIMOUT = 1 + CONNECTION_TIMOUT = urllib3.Timeout(connect=1, read=3) @staticmethod def load_config(): @@ -104,13 +105,13 @@ class EnergyRecorder(object): "API recorder at: " + energy_recorder_uri + uri_comp) # Creds - user = ft_utils.get_functest_config( + creds_usr = ft_utils.get_functest_config( "energy_recorder.api_user") - password = ft_utils.get_functest_config( + creds_pass = ft_utils.get_functest_config( "energy_recorder.api_password") - if user != "" and password != "": - energy_recorder_api_auth = (user, password) + if creds_usr != "" and creds_pass != "": + energy_recorder_api_auth = (creds_usr, creds_pass) else: energy_recorder_api_auth = None |