diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-05-24 07:22:51 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-06-22 11:06:17 +0000 |
commit | acc757fc7cf9db54d97d4563cd294efafc3f7747 (patch) | |
tree | 20a55964d84fa84c06a91b2e9b9233902f42c2c7 /tests | |
parent | 5c33b82efbc0f7e58bdcfc4288ce08b7b3c999f2 (diff) |
Yardstick output format unified
JIRA: YARDSTICK-658
Currently the yardstick have three dispatcher: file, influxdb, mongodb.
(influxdb using API to get result and mongodb using testAPI to get result)
But their output format is different. It is hard to use.
In this patch, make all dispatchers using the same data source.
And make the output format of file and influxdb unified.
As for mongodb, since it is related to testAPI, so I make it push data
every test case.
The unified output format is:
http://paste.openstack.org/show/610125/
Change-Id: I854ac4f03e6f904469b07b0c924c7d850545ae5b
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/benchmark/core/test_task.py | 1 | ||||
-rw-r--r-- | tests/unit/benchmark/runner/test_base.py | 4 | ||||
-rw-r--r-- | tests/unit/dispatcher/test_influxdb.py | 36 |
3 files changed, 20 insertions, 21 deletions
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py index 8034392f4..b64bb8eed 100644 --- a/tests/unit/benchmark/core/test_task.py +++ b/tests/unit/benchmark/core/test_task.py @@ -65,6 +65,7 @@ class TaskTestCase(unittest.TestCase): runner = mock.Mock() runner.join.return_value = 0 runner.get_output.return_value = {} + runner.get_result.return_value = [] mock_base_runner.Runner.get.return_value = runner t._run([scenario], False, "yardstick.out") self.assertTrue(runner.run.called) diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py index 7880fe5a5..6e72fa548 100644 --- a/tests/unit/benchmark/runner/test_base.py +++ b/tests/unit/benchmark/runner/test_base.py @@ -13,7 +13,6 @@ from __future__ import print_function from __future__ import absolute_import import unittest -import multiprocessing import time from yardstick.benchmark.runners.iteration import IterationRunner @@ -22,8 +21,7 @@ from yardstick.benchmark.runners.iteration import IterationRunner class RunnerTestCase(unittest.TestCase): def test_get_output(self): - queue = multiprocessing.Queue() - runner = IterationRunner({}, queue) + runner = IterationRunner({}) runner.output_queue.put({'case': 'opnfv_yardstick_tc002'}) runner.output_queue.put({'criteria': 'PASS'}) diff --git a/tests/unit/dispatcher/test_influxdb.py b/tests/unit/dispatcher/test_influxdb.py index dca3c4189..a5d9b0754 100644 --- a/tests/unit/dispatcher/test_influxdb.py +++ b/tests/unit/dispatcher/test_influxdb.py @@ -94,31 +94,31 @@ class InfluxdbDispatcherTestCase(unittest.TestCase): } } - self.yardstick_conf = {'yardstick': {}} - - def test_record_result_data_no_target(self): - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) - influxdb.target = '' - self.assertEqual(influxdb.record_result_data(self.data1), -1) - - def test_record_result_data_no_case_name(self): - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) - self.assertEqual(influxdb.record_result_data(self.data2), -1) + self.yardstick_conf = {'dispatcher_influxdb': {}} @mock.patch('yardstick.dispatcher.influxdb.requests') def test_record_result_data(self, mock_requests): type(mock_requests.post.return_value).status_code = 204 - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) - self.assertEqual(influxdb.record_result_data(self.data1), 0) - self.assertEqual(influxdb.record_result_data(self.data2), 0) - self.assertEqual(influxdb.flush_result_data(), 0) + influxdb = InfluxdbDispatcher(self.yardstick_conf) + data = { + 'status': 1, + 'result': { + 'criteria': 'PASS', + 'info': { + }, + 'task_id': 'b9e2bbc2-dfd8-410d-8c24-07771e9f7979', + 'testcases': { + } + } + } + self.assertEqual(influxdb.flush_result_data(data), 0) def test__dict_key_flatten(self): line = 'mpstat.loadavg1=0.29,rtt=1.03,mpstat.loadavg0=1.09,' \ 'mpstat.cpu0.%idle=99.00,mpstat.cpu0.%sys=0.00' # need to sort for assert to work line = ",".join(sorted(line.split(','))) - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) + influxdb = InfluxdbDispatcher(self.yardstick_conf) flattened_data = influxdb._dict_key_flatten( self.data3['benchmark']['data']) result = ",".join( @@ -126,15 +126,15 @@ class InfluxdbDispatcherTestCase(unittest.TestCase): self.assertEqual(result, line) def test__get_nano_timestamp(self): - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) - results = {'benchmark': {'timestamp': '1451461248.925574'}} + influxdb = InfluxdbDispatcher(self.yardstick_conf) + results = {'timestamp': '1451461248.925574'} self.assertEqual(influxdb._get_nano_timestamp(results), '1451461248925574144') @mock.patch('yardstick.dispatcher.influxdb.time') def test__get_nano_timestamp_except(self, mock_time): results = {} - influxdb = InfluxdbDispatcher(None, self.yardstick_conf) + influxdb = InfluxdbDispatcher(self.yardstick_conf) mock_time.time.return_value = 1451461248.925574 self.assertEqual(influxdb._get_nano_timestamp(results), '1451461248925574144') |