From a9db50ee51788e0d05e0a3e5f82abb4c2c6dd50c Mon Sep 17 00:00:00 2001 From: Ameed Ashour Date: Tue, 4 Sep 2018 10:51:25 +0300 Subject: add error logs to storperf add error logs to storperf.py in order to show the errors in task log API JIRA: YARDSTICK-1407 Change-Id: I7cefd09cbd7bdefca98c9220f886675b6a5b02a4 Signed-off-by: Ameed Ashour --- yardstick/benchmark/scenarios/storage/storperf.py | 37 +++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/yardstick/benchmark/scenarios/storage/storperf.py b/yardstick/benchmark/scenarios/storage/storperf.py index e4c72dc8f..7c8e5fe66 100644 --- a/yardstick/benchmark/scenarios/storage/storperf.py +++ b/yardstick/benchmark/scenarios/storage/storperf.py @@ -102,13 +102,14 @@ class StorPerf(base.Scenario): setup_res = requests.post('http://%s:5000/api/v1.0/configurations' % self.target, json=env_args) - setup_res_content = jsonutils.loads( - setup_res.content) if setup_res.status_code != 200: - raise RuntimeError("Failed to create a stack, error message:", - setup_res_content["message"]) + LOG.error("Failed to create stack. %s: %s", + setup_res.status_code, setup_res.content) + raise RuntimeError("Failed to create stack. %s: %s" % + (setup_res.status_code, setup_res.content)) elif setup_res.status_code == 200: + setup_res_content = jsonutils.loads(setup_res.content) LOG.info("stack_id: %s", setup_res_content["stack_id"]) while not self._query_setup_state(): @@ -122,14 +123,15 @@ class StorPerf(base.Scenario): def _query_job_state(self, job_id): """Query the status of the supplied job_id and report on metrics""" LOG.info("Fetching report for %s...", job_id) - report_res = requests.get('http://{}:5000/api/v1.0/jobs'.format - (self.target), + report_res = requests.get('http://%s:5000/api/v1.0/jobs' % self.target, params={'id': job_id, 'type': 'status'}) report_res_content = jsonutils.loads( report_res.content) if report_res.status_code != 200: + LOG.error("Failed to fetch report, error message: %s", + report_res_content["message"]) raise RuntimeError("Failed to fetch report, error message:", report_res_content["message"]) else: @@ -186,15 +188,15 @@ class StorPerf(base.Scenario): LOG.info("Starting a job with parameters %s", job_args) job_res = requests.post('http://%s:5000/api/%s/jobs' % (self.target, - api_version), - json=job_args) - - job_res_content = jsonutils.loads(job_res.content) + api_version), json=job_args) if job_res.status_code != 200: - raise RuntimeError("Failed to start a job, error message:", - job_res_content["message"]) + LOG.error("Failed to start job. %s: %s", + job_res.status_code, job_res.content) + raise RuntimeError("Failed to start job. %s: %s" % + (job_res.status_code, job_res.content)) elif job_res.status_code == 200: + job_res_content = jsonutils.loads(job_res.content) job_id = job_res_content["job_id"] LOG.info("Started job id: %s...", job_id) @@ -247,13 +249,14 @@ class StorPerf(base.Scenario): job_res = requests.post('http://%s:5000/api/v1.0/initializations' % self.target, json=job_args) - job_res_content = jsonutils.loads(job_res.content) if job_res.status_code != 200: - raise RuntimeError( - "Failed to start initialization job, error message:", - job_res_content["message"]) + LOG.error("Failed to start initialization job, error message: %s: %s", + job_res.status_code, job_res.content) + raise RuntimeError("Failed to start initialization job, error message: %s: %s" % + (job_res.status_code, job_res.content)) elif job_res.status_code == 200: + job_res_content = jsonutils.loads(job_res.content) job_id = job_res_content["job_id"] LOG.info("Started initialization as job id: %s...", job_id) @@ -271,6 +274,8 @@ class StorPerf(base.Scenario): if teardown_res.status_code == 400: teardown_res_content = jsonutils.loads( teardown_res.json_data) + LOG.error("Failed to reset environment, error message: %s", + teardown_res_content['message']) raise RuntimeError("Failed to reset environment, error message:", teardown_res_content['message']) -- cgit 1.2.3-korg