From d9b9b8970312e13f798a367439cfc2c333c7fca4 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Wed, 26 Jul 2017 00:58:29 -0700 Subject: fix sriov/ovs-dpdk unittests on systems with fewer than 10 cores we need to wrap vcpupin modulo number of cores. also mock time.sleep Change-Id: I6433418a99505b469c61c81a9a023d84434fa0ee Signed-off-by: Ross Brattain --- tests/unit/benchmark/contexts/test_ovsdpdk.py | 7 ++----- tests/unit/benchmark/contexts/test_sriov.py | 14 ++++++-------- yardstick/benchmark/contexts/ovsdpdk.py | 2 +- yardstick/benchmark/contexts/sriov.py | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/unit/benchmark/contexts/test_ovsdpdk.py b/tests/unit/benchmark/contexts/test_ovsdpdk.py index 125e475af..ac25ec877 100644 --- a/tests/unit/benchmark/contexts/test_ovsdpdk.py +++ b/tests/unit/benchmark/contexts/test_ovsdpdk.py @@ -18,7 +18,6 @@ import mock import unittest from yardstick.benchmark.contexts import ovsdpdk -from yardstick.benchmark.contexts.ovsdpdk import Ovsdpdk NIC_INPUT = { 'interface': {}, @@ -227,10 +226,8 @@ class OvsdpdkTestCase(unittest.TestCase): mock_ovs = mock.Mock() ssh_mock.put = mock.Mock() ovs_obj.check_output = mock.Mock(return_value=(0, "vm1")) - self.assertIsNone(ovs_obj.setup_ovs_context( - PCIS, - NIC_DETAILS, - DRIVER)) + with mock.patch("yardstick.benchmark.contexts.ovsdpdk.time"): + self.assertIsNone(ovs_obj.setup_ovs_context(PCIS, NIC_DETAILS, DRIVER)) @mock.patch( 'yardstick.benchmark.contexts.ovsdpdk', diff --git a/tests/unit/benchmark/contexts/test_sriov.py b/tests/unit/benchmark/contexts/test_sriov.py index e4d8f5e1a..a8641a2eb 100644 --- a/tests/unit/benchmark/contexts/test_sriov.py +++ b/tests/unit/benchmark/contexts/test_sriov.py @@ -185,8 +185,8 @@ class SriovTestCase(unittest.TestCase): nic_details['vf_pci'][i] = sriov_obj.get_vf_datas.return_value vf_pci = [[], []] vf_pci[i] = sriov_obj.get_vf_datas.return_value - self.assertIsNotNone( - sriov_obj.configure_nics_for_sriov(DRIVER, NIC_DETAILS)) + with mock.patch("yardstick.benchmark.contexts.sriov.time"): + self.assertIsNotNone(sriov_obj.configure_nics_for_sriov(DRIVER, NIC_DETAILS)) def test_setup_sriov_context(self): with mock.patch("yardstick.ssh.SSH") as ssh: @@ -224,8 +224,8 @@ class SriovTestCase(unittest.TestCase): mock.Mock(return_value=(0, {}, "")) ssh_mock.put = mock.Mock() sriov_obj.check_output = mock.Mock(return_value=(1, {})) - self.assertIsNone( - sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER)) + with mock.patch("yardstick.benchmark.contexts.sriov.time"): + self.assertIsNone(sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER)) def test_setup_sriov_context_vm_already_present(self): with mock.patch("yardstick.ssh.SSH") as ssh: @@ -263,10 +263,8 @@ class SriovTestCase(unittest.TestCase): mock.Mock(return_value=(0, {}, "")) ssh_mock.put = mock.Mock() sriov_obj.check_output = mock.Mock(return_value=(0, "vm1")) - self.assertIsNone(sriov_obj.setup_sriov_context( - PCIS, - nic_details, - DRIVER)) + with mock.patch("yardstick.benchmark.contexts.sriov.time"): + self.assertIsNone(sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER)) @mock.patch( 'yardstick.benchmark.contexts.sriov', diff --git a/yardstick/benchmark/contexts/ovsdpdk.py b/yardstick/benchmark/contexts/ovsdpdk.py index 86610305e..cf5529d89 100644 --- a/yardstick/benchmark/contexts/ovsdpdk.py +++ b/yardstick/benchmark/contexts/ovsdpdk.py @@ -329,7 +329,7 @@ class Ovsdpdk(StandaloneContext): for i in range(0, 10): self.connection.execute( "virsh vcpupin vm1 {0} {1}".format( - i, nodes[str(num_nodes - 1)][i])) + i, nodes[str(num_nodes - 1)][i % len(nodes[str(num_nodes - 1)])])) def get_numa_nodes(self): nodes_sysfs = glob.iglob("/sys/devices/system/node/node*") diff --git a/yardstick/benchmark/contexts/sriov.py b/yardstick/benchmark/contexts/sriov.py index da143cc4b..fe27d2579 100644 --- a/yardstick/benchmark/contexts/sriov.py +++ b/yardstick/benchmark/contexts/sriov.py @@ -392,7 +392,7 @@ class Sriov(StandaloneContext): for i in range(0, 10): self.connection.execute( "virsh vcpupin vm1 {0} {1}".format( - i, nodes[str(num_nodes - 1)][i])) + i, nodes[str(num_nodes - 1)][i % len(nodes[str(num_nodes - 1)])])) def get_numa_nodes(self): nodes_sysfs = glob.iglob("/sys/devices/system/node/node*") -- cgit 1.2.3-korg