diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/network_services/traffic_profile/test_rfc2544.py | 2 | ||||
-rw-r--r-- | tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py | 22 |
2 files changed, 21 insertions, 3 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_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') |