diff options
Diffstat (limited to 'tests/unit/network_services')
4 files changed, 28 insertions, 23 deletions
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py index 5c2f890e8..4584b093d 100644 --- a/tests/unit/network_services/nfvi/test_resource.py +++ b/tests/unit/network_services/nfvi/test_resource.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import -import unittest - import errno + import mock +import unittest from yardstick.network_services.nfvi.resource import ResourceProfile from yardstick.network_services.nfvi import resource, collectd @@ -105,14 +104,16 @@ class TestResourceProfile(unittest.TestCase): def test___init__(self): self.assertEqual(True, self.resource_profile.enable) - def test_check_if_sa_running(self): - self.assertEqual(self.resource_profile.check_if_sa_running("collectd"), + def test_check_if_system_agent_running(self): + self.assertEqual(self.resource_profile.check_if_system_agent_running("collectd"), (0, "")) - def test_check_if_sa_running_excetion(self): + def test_check_if_system_agent_running_excetion(self): with mock.patch.object(self.resource_profile.connection, "execute") as mock_execute: mock_execute.side_effect = OSError(errno.ECONNRESET, "error") - self.assertEqual(self.resource_profile.check_if_sa_running("collectd"), (1, None)) + self.assertEqual( + self.resource_profile.check_if_system_agent_running("collectd"), + (1, None)) def test_get_cpu_data(self): reskey = ["", "cpufreq", "cpufreq-0"] @@ -139,8 +140,7 @@ class TestResourceProfile(unittest.TestCase): self.resource_profile._setup_ovs_stats(self.ssh_mock)) @mock.patch("yardstick.network_services.nfvi.resource.open") - @mock.patch("yardstick.network_services.nfvi.resource.os") - def test__provide_config_file(self, mock_open, mock_os): + def test__provide_config_file(self, *args): loadplugin = range(5) port_names = range(5) kwargs = { @@ -152,13 +152,13 @@ class TestResourceProfile(unittest.TestCase): self.ssh_mock.execute.assert_called_once() @mock.patch("yardstick.network_services.nfvi.resource.open") - def test_initiate_systemagent(self, mock_open): + def test_initiate_systemagent(self, *args): self.resource_profile._start_collectd = mock.Mock() self.assertIsNone( self.resource_profile.initiate_systemagent("/opt/nsb_bin")) @mock.patch("yardstick.network_services.nfvi.resource.open") - def test_initiate_systemagent_raise(self, mock_open): + def test_initiate_systemagent_raise(self, *args): self.resource_profile._start_collectd = mock.Mock(side_effect=RuntimeError) with self.assertRaises(RuntimeError): self.resource_profile.initiate_systemagent("/opt/nsb_bin") @@ -267,8 +267,10 @@ class TestResourceProfile(unittest.TestCase): def test_stop(self): self.assertIsNone(self.resource_profile.stop()) - def test_stop(self): + def test_stop_amqp_not_running(self): self.resource_profile.amqp_client = mock.MagicMock() + # TODO(efoley): Fix this incorrect test. + # Should check that we don't try to stop amqp when it's not running self.assertIsNone(self.resource_profile.stop()) if __name__ == '__main__': 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 ed49c7000..0ac46c632 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 @@ -16,15 +16,17 @@ # from itertools import repeat, chain -import mock import os import socket import time + +import mock import unittest from tests.unit import STL_MOCKS from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() @@ -1433,9 +1435,9 @@ class TestProxResourceHelper(unittest.TestCase): helper = ProxResourceHelper(mock.MagicMock()) helper.resource = resource = mock.MagicMock() - resource.check_if_sa_running.return_value = 0, '1234' + resource.check_if_system_agent_running.return_value = 0, '1234' resource.amqp_collect_nfvi_kpi.return_value = 543 - resource.check_if_sa_running.return_value = (0, None) + resource.check_if_system_agent_running.return_value = (0, None) expected = {'core': 543} result = helper.collect_collectd_kpi() @@ -1447,9 +1449,9 @@ class TestProxResourceHelper(unittest.TestCase): helper._result = {'z': 123} helper.resource = resource = mock.MagicMock() - resource.check_if_sa_running.return_value = 0, '1234' + resource.check_if_system_agent_running.return_value = 0, '1234' resource.amqp_collect_nfvi_kpi.return_value = 543 - resource.check_if_sa_running.return_value = (0, None) + resource.check_if_system_agent_running.return_value = (0, None) queue.empty.return_value = False queue.get.return_value = {'a': 789} diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py index 7b4d79e02..0104e7f63 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py @@ -330,7 +330,7 @@ class TestProxTrafficGen(unittest.TestCase): prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0) prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock( - **{"check_if_sa_running.return_value": [False]}) + **{"self.check_if_system_agent_running.return_value": [False]}) prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="") self.assertEqual({}, prox_traffic_gen.collect_kpi()) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py index 55cd4d2e8..1abc53688 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py @@ -15,11 +15,12 @@ # limitations under the License. # -import mock from multiprocessing import Process, Queue import os -import six.moves.configparser as configparser import time + +import mock +import six.moves.configparser as configparser import unittest from tests.unit import STL_MOCKS @@ -543,9 +544,9 @@ class TestVpeApproxVnf(unittest.TestCase): mock_ssh(ssh) resource = mock.Mock(autospec=ResourceProfile) - resource.check_if_sa_running.return_value = 1, '' + resource.check_if_system_agent_running.return_value = 1, '' resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234} - resource.check_if_sa_running.return_value = (1, None) + resource.check_if_system_agent_running.return_value = (1, None) vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf.q_in = mock.MagicMock() @@ -567,7 +568,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_ssh(ssh) resource = mock.Mock(autospec=ResourceProfile) - resource.check_if_sa_running.return_value = 0, '1234' + resource.check_if_system_agent_running.return_value = 0, '1234' resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234} vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) |