summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2017-09-28 17:09:39 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-28 17:09:39 +0000
commit5ad79085891e4ff257c28b2ddafa67bf96d15a50 (patch)
treeebbe91316d315ce4d14921f93e78bb426053275c
parentccc0f857e610c4c5417f267b767546515e0aa7ed (diff)
parent1f64eac0ac58f1616c75a3f85b384b2b8e77b024 (diff)
Merge "Add log details on SDK first connection." into stable/euphrates
-rw-r--r--functest/energy/energy.py19
-rw-r--r--functest/tests/unit/energy/test_functest_energy.py18
2 files changed, 19 insertions, 18 deletions
diff --git a/functest/energy/energy.py b/functest/energy/energy.py
index 508f18e74..2aabc06da 100644
--- a/functest/energy/energy.py
+++ b/functest/energy/energy.py
@@ -78,7 +78,7 @@ class EnergyRecorder(object):
INITIAL_STEP = "running"
# Default connection timeout
- CONNECTION_TIMOUT = urllib3.Timeout(connect=1, read=3)
+ CONNECTION_TIMEOUT = urllib3.Timeout(connect=1, read=3)
@staticmethod
def load_config():
@@ -122,11 +122,12 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT)
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT)
api_available = json.loads(resp.text)["status"] == "OK"
- except Exception: # pylint: disable=broad-except
- EnergyRecorder.logger.error(
- "Energy recorder API is not available")
+ except Exception as exc: # pylint: disable=broad-except
+ EnergyRecorder.logger.info(
+ "Energy recorder API is not available, cause=%s",
+ exc.message)
api_available = False
# Final config
EnergyRecorder.energy_recorder_api = {
@@ -165,7 +166,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -227,7 +228,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -269,7 +270,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -302,7 +303,7 @@ class EnergyRecorder(object):
response = requests.get(
EnergyRecorder.energy_recorder_api["uri"],
auth=EnergyRecorder.energy_recorder_api["auth"],
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code == 200:
return_value = json.loads(response.text)
diff --git a/functest/tests/unit/energy/test_functest_energy.py b/functest/tests/unit/energy/test_functest_energy.py
index 5e2254ad1..738bd3e14 100644
--- a/functest/tests/unit/energy/test_functest_energy.py
+++ b/functest/tests/unit/energy/test_functest_energy.py
@@ -99,7 +99,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.post',
@@ -113,7 +113,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.post',
@@ -127,7 +127,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.post',
@@ -141,7 +141,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.post',
@@ -155,7 +155,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.post',
@@ -169,7 +169,7 @@ class EnergyRecorderTest(unittest.TestCase):
auth=EnergyRecorder.energy_recorder_api["auth"],
data=mock.ANY,
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.delete',
@@ -182,7 +182,7 @@ class EnergyRecorderTest(unittest.TestCase):
EnergyRecorder.energy_recorder_api["uri"],
auth=EnergyRecorder.energy_recorder_api["auth"],
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.delete',
@@ -195,7 +195,7 @@ class EnergyRecorderTest(unittest.TestCase):
EnergyRecorder.energy_recorder_api["uri"],
auth=EnergyRecorder.energy_recorder_api["auth"],
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@mock.patch('functest.energy.energy.requests.delete',
@@ -208,7 +208,7 @@ class EnergyRecorderTest(unittest.TestCase):
EnergyRecorder.energy_recorder_api["uri"],
auth=EnergyRecorder.energy_recorder_api["auth"],
headers=self.request_headers,
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
@energy.enable_recording