diff options
Diffstat (limited to 'tests/unit')
3 files changed, 40 insertions, 14 deletions
diff --git a/tests/unit/network_services/traffic_profile/test_rfc2544.py b/tests/unit/network_services/traffic_profile/test_rfc2544.py index 21c8f6d5b..cb3a547ee 100644 --- a/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -73,7 +73,7 @@ class TestRFC2544Profile(unittest.TestCase): def test___init__(self): r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE) - assert r_f_c2544_profile.rate + self.assertIsNotNone(r_f_c2544_profile.rate) def test_execute(self): traffic_generator = mock.Mock(autospec=TrexProfile) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py index faceeb695..bc48f994c 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py @@ -24,7 +24,7 @@ import unittest from tests.unit import STL_MOCKS from yardstick.common import utils from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper - +from yardstick.network_services import constants STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) @@ -46,7 +46,6 @@ if stl_patch: from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxVpeProfileHelper from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxlwAFTRProfileHelper - class TestCoreTuple(unittest.TestCase): def test___init__(self): core_tuple = CoreSocketTuple('core 5s6') @@ -1537,7 +1536,9 @@ class TestProxDataHelper(unittest.TestCase): sut = mock.MagicMock() sut.port_stats.return_value = list(range(10)) - data_helper = ProxDataHelper(vnfd_helper, sut, pkt_size, 25, None) + data_helper = ProxDataHelper( + vnfd_helper, sut, pkt_size, 25, None, + constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS) self.assertEqual(data_helper.rx_total, 6) self.assertEqual(data_helper.tx_total, 7) @@ -1551,7 +1552,7 @@ class TestProxDataHelper(unittest.TestCase): sut = mock.MagicMock() sut.port_stats.return_value = list(range(10)) - data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None) + data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None, None) expected = { 'xe1': { @@ -1574,13 +1575,15 @@ class TestProxDataHelper(unittest.TestCase): sut = mock.MagicMock() sut.port_stats.return_value = list(range(10)) - data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4) + data_helper = ProxDataHelper(vnfd_helper, sut, None, None, + 5.4, constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS) data_helper._totals_and_pps = 12, 32, 4.5 data_helper.tsc_hz = 9.8 data_helper.measured_stats = {'delta': TotStatsTuple(6.1, 6.2, 6.3, 6.4)} data_helper.latency = 7 self.assertIsNone(data_helper.result_tuple) + self.assertEqual(data_helper.line_speed, 10000000000) expected = ProxTestDataTuple(5.4, 9.8, 6.1, 6.2, 6.3, 7, 12, 32, 4.5) with data_helper: @@ -1595,7 +1598,7 @@ class TestProxDataHelper(unittest.TestCase): def test___enter___negative(self): vnfd_helper = mock.MagicMock() - data_helper = ProxDataHelper(vnfd_helper, None, None, None, None) + data_helper = ProxDataHelper(vnfd_helper, None, None, None, None, None) vnfd_helper.port_pairs.all_ports = [] with self.assertRaises(AssertionError): @@ -1617,7 +1620,7 @@ class TestProxDataHelper(unittest.TestCase): sut = ProxSocketHelper(mock.MagicMock()) sut.get_all_tot_stats = mock.MagicMock(side_effect=[start, end]) - data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4) + data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4, None) self.assertIsNone(data_helper.measured_stats) @@ -1638,7 +1641,7 @@ class TestProxDataHelper(unittest.TestCase): sut = mock.MagicMock() sut.hz.return_value = '54.6' - data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None) + data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None, None) self.assertIsNone(data_helper.tsc_hz) @@ -1935,7 +1938,8 @@ class TestProxProfileHelper(unittest.TestCase): helper = ProxProfileHelper(resource_helper) - helper.run_test(120, 5, 6.5) + helper.run_test(120, 5, 6.5, + constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS) class TestProxMplsProfileHelper(unittest.TestCase): @@ -2081,8 +2085,12 @@ class TestProxBngProfileHelper(unittest.TestCase): helper = ProxBngProfileHelper(resource_helper) - helper.run_test(120, 5, 6.5) - helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1 + helper.run_test(120, 5, 6.5, + constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS) + + # negative pkt_size is the only way to make ratio > 1 + helper.run_test(-1000, 5, 6.5, + constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS) class TestProxVpeProfileHelper(unittest.TestCase): diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py index c7d2abcd5..26bd1dadd 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py @@ -533,10 +533,12 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n')) @mock.patch.object(utils, 'read_meminfo', return_value={'Hugepagesize': '2048'}) - def test__setup_hugepages(self, mock_meminfo, *args): + def test__setup_hugepages_no_hugepages_defined(self, mock_meminfo, *args): ssh_helper = mock.Mock() + scenario_helper = mock.Mock() + scenario_helper.all_options = {} dpdk_setup_helper = DpdkVnfSetupEnvHelper( - mock.ANY, ssh_helper, mock.ANY) + mock.ANY, ssh_helper, scenario_helper) with mock.patch.object(sample_vnf.LOG, 'info') as mock_info: dpdk_setup_helper._setup_hugepages() mock_info.assert_called_once_with( @@ -544,6 +546,22 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): '%s', 2048, 8192, 100) mock_meminfo.assert_called_once_with(ssh_helper) + @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n')) + @mock.patch.object(utils, 'read_meminfo', + return_value={'Hugepagesize': '1048576'}) + def test__setup_hugepages_8gb_hugepages_defined(self, mock_meminfo, *args): + ssh_helper = mock.Mock() + scenario_helper = mock.Mock() + scenario_helper.all_options = {'hugepages_gb': 8} + dpdk_setup_helper = DpdkVnfSetupEnvHelper( + mock.ANY, ssh_helper, scenario_helper) + with mock.patch.object(sample_vnf.LOG, 'info') as mock_info: + dpdk_setup_helper._setup_hugepages() + mock_info.assert_called_once_with( + 'Hugepages size (kB): %s, number claimed: %s, number set: ' + '%s', 1048576, 8, 100) + mock_meminfo.assert_called_once_with(ssh_helper) + @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.open') @mock.patch.object(utils, 'find_relative_file') @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig') |