aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/network_services/vnf_generic
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-04-22 19:52:49 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-05 08:38:17 +0100
commit5ea92a3ba1c5bbd011c9d9ae0f2c686aa59417af (patch)
tree0549df73cd05f74f5ab4240993b47d4865caafed /yardstick/tests/unit/network_services/vnf_generic
parent3aed8d1ad85f8a128a22a0a0f2436eb94562799f (diff)
Add "TrafficGeneratorProducer" for "GenericTrafficGen" instances
Added "TrafficGeneratorProducer" class, a message producer specific for "GenericTrafficGen" derived classes. JIRA: YARDSTICK-1127 Change-Id: Icc87a6920155612e759a1d4d2f29028940c2e040 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/tests/unit/network_services/vnf_generic')
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
index ebedcb451..ca3831ce8 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
@@ -15,10 +15,14 @@
import multiprocessing
import os
+import uuid
import mock
+from oslo_config import cfg
+import oslo_messaging
import unittest
+from yardstick.common import messaging
from yardstick.network_services.vnf_generic.vnf import base
from yardstick.ssh import SSH
@@ -221,7 +225,7 @@ class TestGenericVNF(unittest.TestCase):
self.assertEqual(msg, str(exc.exception))
-class TestGenericTrafficGen(unittest.TestCase):
+class GenericTrafficGenTestCase(unittest.TestCase):
def test_definition(self):
"""Make sure that the abstract class cannot be instantiated"""
@@ -234,3 +238,24 @@ class TestGenericTrafficGen(unittest.TestCase):
"abstract methods collect_kpi, instantiate, run_traffic, "
"scale, terminate")
self.assertEqual(msg, str(exc.exception))
+
+
+class TrafficGeneratorProducerTestCase(unittest.TestCase):
+
+ @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):
+ pid = uuid.uuid1().int
+ tg_producer = base.TrafficGeneratorProducer(pid)
+ mock_transport.assert_called_once_with(
+ mock_config, url='rabbit://yardstick:yardstick@localhost:5672/')
+ mock_target.assert_called_once_with(topic=messaging.TOPIC_TG,
+ fanout=True,
+ server=messaging.SERVER)
+ mock_rpcclient.assert_called_once_with('rpc_transport', 'rpc_target')
+ self.assertEqual(pid, tg_producer._pid)
+ self.assertEqual(messaging.TOPIC_TG, tg_producer._topic)