summaryrefslogtreecommitdiffstats
path: root/tests/unit/dispatcher
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-02-25 00:48:07 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-03-08 08:42:32 +0000
commitaf3478e95314b5147c7837831dc8113d552ba067 (patch)
treee9411bebe78eca2f0d204d8a49464e7f620a0ff1 /tests/unit/dispatcher
parent501175fbb095a771f5f1b9fb80dcf729192214d2 (diff)
Bugfix: yardstick will create stacks with the same name when run using API in parallel
JIRA: YARDSTICK-575 Currently yardstick will create stacks with the same name when run using API in parallel. The reason is there is a global variable in context base and the core will always deploy the first context in Context.list. When run in parallel, it will run in the one process. So yardstick will deploy stacks with the same name. The solution is do not use Context.list in yardstick core. And using a local variable instead. BTW, if we use API to call yardstick core, we can not config the output way. So I parse yardstick.conf when task start. And I think we can include scenario_cfg, context_cfg, yardstick_cfg in one config object later so that we can get all config in one object. Change-Id: I1ada4ef486bd252e78c3a2e49c6a39b3f8f16a7c Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'tests/unit/dispatcher')
-rw-r--r--tests/unit/dispatcher/test_influxdb.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/unit/dispatcher/test_influxdb.py b/tests/unit/dispatcher/test_influxdb.py
index b84389e7e..0c7b58135 100644
--- a/tests/unit/dispatcher/test_influxdb.py
+++ b/tests/unit/dispatcher/test_influxdb.py
@@ -90,19 +90,21 @@ class InfluxdbDispatcherTestCase(unittest.TestCase):
}
}
+ self.yardstick_conf = {'yardstick': {}}
+
def test_record_result_data_no_target(self):
- influxdb = InfluxdbDispatcher(None)
+ 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)
+ influxdb = InfluxdbDispatcher(None, self.yardstick_conf)
self.assertEqual(influxdb.record_result_data(self.data2), -1)
@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)
+ 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)
@@ -112,7 +114,7 @@ class InfluxdbDispatcherTestCase(unittest.TestCase):
'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)
+ influxdb = InfluxdbDispatcher(None, self.yardstick_conf)
flattened_data = influxdb._dict_key_flatten(
self.data3['benchmark']['data'])
result = ",".join(
@@ -120,7 +122,7 @@ class InfluxdbDispatcherTestCase(unittest.TestCase):
self.assertEqual(result, line)
def test__get_nano_timestamp(self):
- influxdb = InfluxdbDispatcher(None)
+ influxdb = InfluxdbDispatcher(None, self.yardstick_conf)
results = {'benchmark': {'timestamp': '1451461248.925574'}}
self.assertEqual(influxdb._get_nano_timestamp(results),
'1451461248925574144')
@@ -128,7 +130,7 @@ class InfluxdbDispatcherTestCase(unittest.TestCase):
@mock.patch('yardstick.dispatcher.influxdb.time')
def test__get_nano_timestamp_except(self, mock_time):
results = {}
- influxdb = InfluxdbDispatcher(None)
+ influxdb = InfluxdbDispatcher(None, self.yardstick_conf)
mock_time.time.return_value = 1451461248.925574
self.assertEqual(influxdb._get_nano_timestamp(results),
'1451461248925574144')