summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2017-09-28 17:09:57 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-28 17:09:57 +0000
commitb9b8b9a0b24aac1d38e13f9c5b0e1fdebc995894 (patch)
treeeb1e1749cd2b92d84a71a5546531f82d3d6eb7f4
parent5ad79085891e4ff257c28b2ddafa67bf96d15a50 (diff)
parent2c1b685a0d7ac0cc95972433e831df8b2cc02fbf (diff)
Merge "Fix connection error due to invalid lib version usage." into stable/euphrates
-rw-r--r--functest/energy/energy.py14
-rw-r--r--functest/tests/unit/energy/test_functest_energy.py2
2 files changed, 10 insertions, 6 deletions
diff --git a/functest/energy/energy.py b/functest/energy/energy.py
index 2aabc06da..119942bbf 100644
--- a/functest/energy/energy.py
+++ b/functest/energy/energy.py
@@ -16,7 +16,6 @@ import urllib
from functools import wraps
import requests
-import urllib3
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
@@ -27,6 +26,9 @@ def finish_session(current_scenario):
if current_scenario is None:
EnergyRecorder.stop()
else:
+ EnergyRecorder.logger.debug("Restoring previous scenario (%s/%s)",
+ current_scenario["scenario"],
+ current_scenario["step"])
EnergyRecorder.submit_scenario(
current_scenario["scenario"],
current_scenario["step"]
@@ -78,7 +80,7 @@ class EnergyRecorder(object):
INITIAL_STEP = "running"
# Default connection timeout
- CONNECTION_TIMEOUT = urllib3.Timeout(connect=1, read=3)
+ CONNECTION_TIMEOUT = 4
@staticmethod
def load_config():
@@ -102,8 +104,6 @@ class EnergyRecorder(object):
uri_comp = "/recorders/environment/"
uri_comp += urllib.quote_plus(environment)
- EnergyRecorder.logger.debug(
- "API recorder at: " + energy_recorder_uri + uri_comp)
# Creds
creds_usr = ft_utils.get_functest_config(
@@ -124,6 +124,9 @@ class EnergyRecorder(object):
},
timeout=EnergyRecorder.CONNECTION_TIMEOUT)
api_available = json.loads(resp.text)["status"] == "OK"
+ EnergyRecorder.logger.info(
+ "API recorder available at : %s",
+ energy_recorder_uri + uri_comp)
except Exception as exc: # pylint: disable=broad-except
EnergyRecorder.logger.info(
"Energy recorder API is not available, cause=%s",
@@ -151,7 +154,8 @@ class EnergyRecorder(object):
return_status = True
# Ensure that connectyvity settings are loaded
if EnergyRecorder.load_config():
- EnergyRecorder.logger.debug("Submitting scenario")
+ EnergyRecorder.logger.debug("Submitting scenario (%s/%s)",
+ scenario, step)
# Create API payload
payload = {
diff --git a/functest/tests/unit/energy/test_functest_energy.py b/functest/tests/unit/energy/test_functest_energy.py
index 738bd3e14..99110802e 100644
--- a/functest/tests/unit/energy/test_functest_energy.py
+++ b/functest/tests/unit/energy/test_functest_energy.py
@@ -249,7 +249,7 @@ class EnergyRecorderTest(unittest.TestCase):
calls = [mock.call.start(self.case_name),
mock.call.submit_scenario(PREVIOUS_SCENARIO,
PREVIOUS_STEP)]
- recorder_mock.assert_has_calls(calls)
+ recorder_mock.assert_has_calls(calls, True)
def test_decorator_preserve_return(self):
"""Test that decorator preserve method returned value."""