aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2015-10-10 17:39:22 +0800
committerHou Jingwen <houjingwen@huawei.com>2015-10-16 04:01:02 +0000
commit6bf31ef144d025d47dd8fb3770190b3fb42eed2d (patch)
treecdec869a5b36e33fee7e3aacee9f3eb54c14077e
parent89655940e65a7e3fabe4fe8a2ca49527a3094221 (diff)
Use result_collection_api to store test result
Execute a sample task file from Yardstick, push the test results to MongodB provided by Releng using the common result api provided by Functest. Usage: 0) install yardstick 1) config yardstick mkdir /etc/yardstick cat << EOF >> /etc/yardstick/yardstick.conf [DEFAULT] debug = True dispatcher = http [dispatcher_http] timeout = 5 target = http://213.77.62.197/results EOF 2) run test yardstick task start sample/fio.yaml 3) fetch result from remote result_collection_api curl "http://213.77.62.197/results?case=Fio&installer=compass" JIRA: YARDSTICK-132 Change-Id: I0996c6487c1900704380feb895555057a3f184e9 Signed-off-by: QiLiang <liangqi1@huawei.com>
-rwxr-xr-xyardstick/benchmark/runners/base.py1
-rw-r--r--yardstick/dispatcher/base.py4
-rw-r--r--yardstick/dispatcher/file.py3
-rw-r--r--yardstick/dispatcher/http.py53
4 files changed, 45 insertions, 16 deletions
diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py
index c3fe6b104..cc8c93cb6 100755
--- a/yardstick/benchmark/runners/base.py
+++ b/yardstick/benchmark/runners/base.py
@@ -39,6 +39,7 @@ def _output_serializer_main(filename, queue):
# blocks until data becomes available
record = queue.get()
if record == '_TERMINATE_':
+ dispatcher.flush_result_data()
break
else:
dispatcher.record_result_data(record)
diff --git a/yardstick/dispatcher/base.py b/yardstick/dispatcher/base.py
index 28c4c1ae6..fe635b9d4 100644
--- a/yardstick/dispatcher/base.py
+++ b/yardstick/dispatcher/base.py
@@ -36,3 +36,7 @@ class Base(object):
@abc.abstractmethod
def record_result_data(self, data):
"""Recording result data interface."""
+
+ @abc.abstractmethod
+ def flush_result_data(self):
+ """Flush result data into permanent storage media interface."""
diff --git a/yardstick/dispatcher/file.py b/yardstick/dispatcher/file.py
index b6130005f..50414b969 100644
--- a/yardstick/dispatcher/file.py
+++ b/yardstick/dispatcher/file.py
@@ -61,3 +61,6 @@ class FileDispatcher(DispatchBase):
def record_result_data(self, data):
if self.log:
self.log.info(json.dumps(data))
+
+ def flush_result_data(self):
+ pass
diff --git a/yardstick/dispatcher/http.py b/yardstick/dispatcher/http.py
index 703cfca62..af9ace469 100644
--- a/yardstick/dispatcher/http.py
+++ b/yardstick/dispatcher/http.py
@@ -44,27 +44,48 @@ class HttpDispatcher(DispatchBase):
self.headers = {'Content-type': 'application/json'}
self.timeout = CONF.dispatcher_http.timeout
self.target = CONF.dispatcher_http.target
+ self.raw_result = []
+ # TODO set pod_name, installer, version based on pod info
+ self.result = {
+ "project_name": "yardstick",
+ "description": "yardstick test cases result",
+ "pod_name": "opnfv-jump-2",
+ "installer": "compass",
+ "version": "Brahmaputra-dev"
+ }
def record_result_data(self, data):
+ self.raw_result.append(data)
+
+ def flush_result_data(self):
if self.target == '':
# if the target was not set, do not do anything
LOG.error('Dispatcher target was not set, no data will'
'be posted.')
return
- # We may have receive only one counter on the wire
- if not isinstance(data, list):
- data = [data]
-
- for result in data:
- try:
- LOG.debug('Message : %s' % result)
- res = requests.post(self.target,
- data=json.dumps(result),
- headers=self.headers,
- timeout=self.timeout)
- LOG.debug('Message posting finished with status code'
- '%d.' % res.status_code)
- except Exception as err:
- LOG.exception('Failed to record result data: %s',
- err)
+ self.result["details"] = self.raw_result
+
+ case_name = ""
+ for v in self.raw_result:
+ if isinstance(v, dict) and "scenario_cfg" in v:
+ case_name = v["scenario_cfg"]["type"]
+ break
+ if case_name == "":
+ LOG.error('Test result : %s' % json.dumps(self.result))
+ LOG.error('The case_name cannot be found, no data will be posted.')
+ return
+
+ self.result["case_name"] = case_name
+
+ try:
+ LOG.debug('Test result : %s' % json.dumps(self.result))
+ res = requests.post(self.target,
+ data=json.dumps(self.result),
+ headers=self.headers,
+ timeout=self.timeout)
+ LOG.debug('Test result posting finished with status code'
+ ' %d.' % res.status_code)
+ except Exception as err:
+ LOG.exception('Failed to record result data: %s',
+ err)