From 22f4074aed052a9dcb73c8907db74306642ae9b3 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 12 Apr 2018 15:08:58 +0100 Subject: Improve IXIA IxNetwork library and traffic profile (4) This patch implements an active wait for the traffic injection. Once the traffic is started, the traffic generator class will poll periodically the IXIA traffic generator chassis to retrieve the status of the traffic ("started", "stopped"). Now the latency statistics are retrieved and reported for each injection period. JIRA: YARDSTICK-1116 Change-Id: I4422e2c88b4fc97b7cac3de8a82b2d75467c4117 Signed-off-by: Rodolfo Alonso Hernandez Signed-off-by: Emma Foley (cherry picked from commit a3399d07b83ce0e50d9c0144d00a7ba83a73390f) --- tests/unit/__init__.py | 8 +++++++- .../vnf_generic/vnf/test_tg_rfc2544_ixia.py | 22 ++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 5935abbac..95b2b8a4e 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -12,9 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from yardstick import tests +import sys + +import mock +from yardstick import tests # NOTE(ralonsoh): to be removed. Replace all occurrences of # tests.unit.STL_MOCKS with yardstick.tests.STL_MOCKS STL_MOCKS = tests.STL_MOCKS + +mock_stl = mock.patch.dict(sys.modules, tests.STL_MOCKS) +mock_stl.start() diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py index 04cd9e858..146c6c96a 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py @@ -30,7 +30,8 @@ NAME = "tg__1" class TestIxiaResourceHelper(unittest.TestCase): def setUp(self): - self._mock_IxNextgen = mock.patch.object(tg_rfc2544_ixia, 'IxNextgen') + self._mock_IxNextgen = mock.patch.object(tg_rfc2544_ixia, + 'IxNextgen') self.mock_IxNextgen = self._mock_IxNextgen.start() self.addCleanup(self._stop_mocks) @@ -54,13 +55,19 @@ class TestIxiaResourceHelper(unittest.TestCase): ixia_resource_helper.stop_collect() self.assertEqual(mock_client.ix_stop_traffic.call_count, 1) - # NOTE(ralonsoh): to be updated in next patchset - def test__initialise_client(self): - pass - - # NOTE(ralonsoh): to be updated in next patchset def test_run_traffic(self): - pass + mock_tprofile = mock.Mock() + mock_tprofile.get_drop_percentage.return_value = True, 'fake_samples' + ixia_rhelper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock()) + ixia_rhelper.rfc_helper = mock.Mock() + ixia_rhelper.vnfd_helper = mock.Mock() + ixia_rhelper.vnfd_helper.port_pairs.all_ports = [] + with mock.patch.object(ixia_rhelper, 'generate_samples'), \ + mock.patch.object(ixia_rhelper, '_build_ports'), \ + mock.patch.object(ixia_rhelper, '_initialize_client'): + ixia_rhelper.run_traffic(mock_tprofile) + + self.assertEqual('fake_samples', ixia_rhelper._queue.get()) @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen") @@ -248,7 +255,6 @@ class TestIXIATrafficGen(unittest.TestCase): sut = tg_rfc2544_ixia.IxiaTrafficGen('vnf1', vnfd) sut._check_status() - @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.time") @mock.patch("yardstick.ssh.SSH") def test_traffic_runner(self, mock_ssh, *args): mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile) -- cgit 1.2.3-korg