aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/benchmark
diff options
context:
space:
mode:
authorMytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>2019-01-24 17:46:04 +0200
committerVolodymyr Mytnyk <volodymyrx.mytnyk@intel.com>2019-01-29 12:57:25 +0000
commit679b6d94288d801e84c0f22c6c0d712c08eb8458 (patch)
tree031cfad1c1a3d495af07a6222f73afa3d9437e3e /yardstick/tests/unit/benchmark
parente3871dda8a4deb1a0f7e72050cd9fbba6cc0ecb9 (diff)
NSB sync: clean-up draft IPC implementation (part 1)
The existing implementation of IPC is not finished and isn't used by any of the VNFs/TG implementation. It is used in the code but does nothing from functionality perspective. New syncronization mechanism is going to be implemented by using different approach than it was designed before. Thus, the current IPC mechanism is not going to be re-used. So, removing it. The IPC consumer/producer implementation is left as it may be required for other purposes. - Remove SampleVNF MQ consumer class - Remove IterationIPC MQ producer for VNF control messages - Remove MQ producer from SampleVNFTrafficGen class - Remove TrafficGeneratorProducer class - Remove IterationIPC runner - Remove unused task_id form VNF Generic initialization as it is not required for synchronization of VNFs/TGs anymore. - Fix UT JIRA: YARDSTICK-1592 Change-Id: I65fe51bcbd1bfeea0c43eb79ca6fb2aab5b65ae7 Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
Diffstat (limited to 'yardstick/tests/unit/benchmark')
-rw-r--r--yardstick/tests/unit/benchmark/runner/test_base.py56
-rw-r--r--yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py136
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py6
3 files changed, 1 insertions, 197 deletions
diff --git a/yardstick/tests/unit/benchmark/runner/test_base.py b/yardstick/tests/unit/benchmark/runner/test_base.py
index 49ba1efe4..559c991f3 100644
--- a/yardstick/tests/unit/benchmark/runner/test_base.py
+++ b/yardstick/tests/unit/benchmark/runner/test_base.py
@@ -8,17 +8,12 @@
##############################################################################
import time
-import uuid
import mock
-from oslo_config import cfg
-import oslo_messaging
import subprocess
from yardstick.benchmark.runners import base as runner_base
from yardstick.benchmark.runners import iteration
-from yardstick.common import messaging
-from yardstick.common.messaging import payloads
from yardstick.tests.unit import base as ut_base
@@ -99,54 +94,3 @@ class RunnerTestCase(ut_base.BaseUnitTestCase):
with self.assertRaises(NotImplementedError):
runner._run_benchmark(mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock())
-
-
-class RunnerProducerTestCase(ut_base.BaseUnitTestCase):
-
- @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target')
- @mock.patch.object(oslo_messaging, 'RPCClient')
- @mock.patch.object(oslo_messaging, 'get_rpc_transport',
- return_value='rpc_transport')
- @mock.patch.object(cfg, 'CONF')
- def test__init(self, mock_config, mock_transport, mock_rpcclient,
- mock_target):
- _id = uuid.uuid1().int
- runner_producer = runner_base.RunnerProducer(_id)
- mock_transport.assert_called_once_with(
- mock_config, url='rabbit://yardstick:yardstick@localhost:5672/')
- mock_target.assert_called_once_with(topic=messaging.TOPIC_RUNNER,
- fanout=True,
- server=messaging.SERVER)
- mock_rpcclient.assert_called_once_with('rpc_transport', 'rpc_target')
- self.assertEqual(_id, runner_producer._id)
- self.assertEqual(messaging.TOPIC_RUNNER, runner_producer._topic)
-
- @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target')
- @mock.patch.object(oslo_messaging, 'RPCClient')
- @mock.patch.object(oslo_messaging, 'get_rpc_transport',
- return_value='rpc_transport')
- @mock.patch.object(payloads, 'RunnerPayload', return_value='runner_pload')
- def test_start_iteration(self, mock_runner_payload, *args):
- runner_producer = runner_base.RunnerProducer(uuid.uuid1().int)
- with mock.patch.object(runner_producer,
- 'send_message') as mock_message:
- runner_producer.start_iteration(version=10)
-
- mock_message.assert_called_once_with(
- messaging.RUNNER_METHOD_START_ITERATION, 'runner_pload')
- mock_runner_payload.assert_called_once_with(version=10, data={})
-
- @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target')
- @mock.patch.object(oslo_messaging, 'RPCClient')
- @mock.patch.object(oslo_messaging, 'get_rpc_transport',
- return_value='rpc_transport')
- @mock.patch.object(payloads, 'RunnerPayload', return_value='runner_pload')
- def test_stop_iteration(self, mock_runner_payload, *args):
- runner_producer = runner_base.RunnerProducer(uuid.uuid1().int)
- with mock.patch.object(runner_producer,
- 'send_message') as mock_message:
- runner_producer.stop_iteration(version=15)
-
- mock_message.assert_called_once_with(
- messaging.RUNNER_METHOD_STOP_ITERATION, 'runner_pload')
- mock_runner_payload.assert_called_once_with(version=15, data={})
diff --git a/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py b/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py
deleted file mode 100644
index 10d14a8a0..000000000
--- a/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py
+++ /dev/null
@@ -1,136 +0,0 @@
-# Copyright (c) 2018 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import multiprocessing
-import time
-import os
-import uuid
-
-import mock
-
-from yardstick.benchmark.runners import iteration_ipc
-from yardstick.common import messaging
-from yardstick.common.messaging import payloads
-from yardstick.tests.unit import base as ut_base
-
-
-class RunnerIterationIPCEndpointTestCase(ut_base.BaseUnitTestCase):
-
- def setUp(self):
- self._id = uuid.uuid1().int
- self._ctx_ids = [uuid.uuid1().int, uuid.uuid1().int]
- self._queue = multiprocessing.Queue()
- self.runner = iteration_ipc.RunnerIterationIPCEndpoint(
- self._id, self._ctx_ids, self._queue)
- self._kwargs = {'version': 1, 'iteration': 10, 'kpi': {}}
- self._pload_dict = payloads.TrafficGeneratorPayload.dict_to_obj(
- self._kwargs).obj_to_dict()
-
- def test_tg_method_started(self):
- self._queue.empty()
- ctxt = {'id': self._ctx_ids[0]}
- self.runner.tg_method_started(ctxt, **self._kwargs)
- time.sleep(0.2)
-
- output = []
- while not self._queue.empty():
- output.append(self._queue.get(True, 1))
-
- self.assertEqual(1, len(output))
- self.assertEqual(self._ctx_ids[0], output[0]['id'])
- self.assertEqual(messaging.TG_METHOD_STARTED, output[0]['action'])
- self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict())
-
- def test_tg_method_finished(self):
- self._queue.empty()
- ctxt = {'id': self._ctx_ids[0]}
- self.runner.tg_method_finished(ctxt, **self._kwargs)
- time.sleep(0.2)
-
- output = []
- while not self._queue.empty():
- output.append(self._queue.get(True, 1))
-
- self.assertEqual(1, len(output))
- self.assertEqual(self._ctx_ids[0], output[0]['id'])
- self.assertEqual(messaging.TG_METHOD_FINISHED, output[0]['action'])
- self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict())
-
- def test_tg_method_iteration(self):
- self._queue.empty()
- ctxt = {'id': self._ctx_ids[0]}
- self.runner.tg_method_iteration(ctxt, **self._kwargs)
- time.sleep(0.2)
-
- output = []
- while not self._queue.empty():
- output.append(self._queue.get(True, 1))
-
- self.assertEqual(1, len(output))
- self.assertEqual(self._ctx_ids[0], output[0]['id'])
- self.assertEqual(messaging.TG_METHOD_ITERATION, output[0]['action'])
- self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict())
-
-
-class RunnerIterationIPCConsumerTestCase(ut_base.BaseUnitTestCase):
-
- def setUp(self):
- self._id = uuid.uuid1().int
- self._ctx_ids = [uuid.uuid1().int, uuid.uuid1().int]
- self.consumer = iteration_ipc.RunnerIterationIPCConsumer(
- self._id, self._ctx_ids)
- self.consumer._queue = mock.Mock()
-
- def test__init(self):
- self.assertEqual({self._ctx_ids[0]: [], self._ctx_ids[1]: []},
- self.consumer._kpi_per_id)
-
- def test_is_all_kpis_received_in_iteration(self):
- payload = payloads.TrafficGeneratorPayload(
- version=1, iteration=1, kpi={})
- msg1 = {'action': messaging.TG_METHOD_ITERATION,
- 'id': self._ctx_ids[0], 'payload': payload}
- msg2 = {'action': messaging.TG_METHOD_ITERATION,
- 'id': self._ctx_ids[1], 'payload': payload}
- self.consumer.iteration_index = 1
-
- self.consumer._queue.empty.side_effect = [False, True]
- self.consumer._queue.get.return_value = msg1
- self.assertFalse(self.consumer.is_all_kpis_received_in_iteration())
-
- self.consumer._queue.empty.side_effect = [False, True]
- self.consumer._queue.get.return_value = msg2
- self.assertTrue(self.consumer.is_all_kpis_received_in_iteration())
-
-
-class IterationIPCRunnerTestCase(ut_base.BaseUnitTestCase):
-
- @mock.patch.object(iteration_ipc, '_worker_process')
- @mock.patch.object(os, 'getpid', return_value=12345678)
- @mock.patch.object(multiprocessing, 'Process', return_value=mock.Mock())
- def test__run_benchmark(self, mock_process, mock_getpid, mock_worker):
- method = 'method'
- scenario_cfg = {'type': 'scenario_type'}
- context_cfg = 'context_cfg'
- name = '%s-%s-%s' % ('IterationIPC', 'scenario_type', 12345678)
- runner = iteration_ipc.IterationIPCRunner(mock.ANY)
- mock_getpid.reset_mock()
-
- runner._run_benchmark('class', method, scenario_cfg, context_cfg)
- mock_process.assert_called_once_with(
- name=name,
- target=mock_worker,
- args=(runner.result_queue, 'class', method, scenario_cfg,
- context_cfg, runner.aborted, runner.output_queue))
- mock_getpid.assert_called_once()
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 8214782b2..addd72bd5 100644
--- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -450,7 +450,6 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self._get_file_abspath("tg_trex_tpl.yaml")
self.context_cfg["nodes"]['vnf__1']['VNF model'] = \
self._get_file_abspath("tg_trex_tpl.yaml")
- self.context_cfg['task_id'] = 'fake_task_id'
vnf = mock.Mock(autospec=GenericVNF)
self.s.get_vnf_impl = mock.Mock(return_value=vnf)
@@ -568,7 +567,6 @@ class TestNetworkServiceTestCase(unittest.TestCase):
tgen.verify_traffic = lambda x: verified_dict
tgen.terminate = mock.Mock(return_value=True)
tgen.name = "tgen__1"
- tgen.run_traffic.return_value = 'tg_id'
vnf = mock.Mock(autospec=GenericVNF)
vnf.runs_traffic = False
vnf.terminate = mock.Mock(return_value=True)
@@ -581,6 +579,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs)
self.s._fill_traffic_profile = \
mock.Mock(return_value=TRAFFIC_PROFILE)
+ self.assertIsNone(self.s.setup())
def test_setup_exception(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -705,9 +704,6 @@ class TestNetworkServiceTestCase(unittest.TestCase):
)
self.assertEqual(self.s.topology, 'fake_nsd')
- def test_get_mq_ids(self):
- self.assertEqual(self.s._mq_ids, self.s.get_mq_ids())
-
def test_teardown(self):
vnf = mock.Mock(autospec=GenericVNF)
vnf.terminate = mock.Mock(return_value=True)