diff options
Diffstat (limited to 'yardstick/tests/unit/network_services/nfvi/test_resource.py')
-rw-r--r-- | yardstick/tests/unit/network_services/nfvi/test_resource.py | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/yardstick/tests/unit/network_services/nfvi/test_resource.py b/yardstick/tests/unit/network_services/nfvi/test_resource.py index 741f9a6cc..c06658218 100644 --- a/yardstick/tests/unit/network_services/nfvi/test_resource.py +++ b/yardstick/tests/unit/network_services/nfvi/test_resource.py @@ -17,10 +17,10 @@ import errno import mock import unittest +from yardstick.common import exceptions +from yardstick.common.exceptions import ResourceCommandError from yardstick.network_services.nfvi.resource import ResourceProfile from yardstick.network_services.nfvi import resource, collectd -from yardstick.common.exceptions import ResourceCommandError -from yardstick.common.exceptions import SSHError class TestResourceProfile(unittest.TestCase): @@ -135,25 +135,45 @@ class TestResourceProfile(unittest.TestCase): self.assertIsNone(self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin")) - ssh_mock.execute = mock.Mock(side_effect=SSHError) - with self.assertRaises(SSHError): + ssh_mock.execute = mock.Mock(side_effect=exceptions.SSHError) + with self.assertRaises(exceptions.SSHError): self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin") ssh_mock.execute = mock.Mock(return_value=(1, "", "")) - self.assertIsNone(self.resource_profile._start_collectd(ssh_mock, - "/opt/nsb_bin")) + with self.assertRaises(ResourceCommandError): + self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin") + + def test__reset_rabbitmq(self): + ssh_mock = mock.Mock() + ssh_mock.execute = mock.Mock(return_value=(1, "", "")) + with self.assertRaises(exceptions.ResourceCommandError): + self.resource_profile._reset_rabbitmq(ssh_mock) + + def test__check_rabbitmq_user(self): + ssh_mock = mock.Mock() + ssh_mock.execute = mock.Mock(return_value=(0, "title\nadmin\t[]", "")) + self.assertTrue(self.resource_profile._check_rabbitmq_user(ssh_mock)) + + def test__set_rabbitmq_admin_user(self): + ssh_mock = mock.Mock() + ssh_mock.execute = mock.Mock(return_value=(1, "", "")) + with self.assertRaises(exceptions.ResourceCommandError): + self.resource_profile._set_rabbitmq_admin_user(ssh_mock) def test__start_rabbitmq(self): ssh_mock = mock.Mock() - ssh_mock.execute = mock.Mock(return_value=(0, "RabbitMQ", "")) - self.assertIsNone(self.resource_profile._start_rabbitmq(ssh_mock)) + self.resource_profile._reset_rabbitmq = mock.Mock() + self.resource_profile._set_rabbitmq_admin_user = mock.Mock() - ssh_mock.execute = mock.Mock(return_value=(0, "", "")) - with self.assertRaises(ResourceCommandError): + self.resource_profile._reset_mq_flag = True + ssh_mock.execute = mock.Mock(return_value=(1, "", "")) + with self.assertRaises(exceptions.ResourceCommandError): self.resource_profile._start_rabbitmq(ssh_mock) + self.resource_profile._reset_mq_flag = False + self.resource_profile._check_rabbitmq_user = mock.Mock(return_value=False) ssh_mock.execute = mock.Mock(return_value=(1, "", "")) - with self.assertRaises(ResourceCommandError): + with self.assertRaises(exceptions.ResourceCommandError): self.resource_profile._start_rabbitmq(ssh_mock) def test__prepare_collectd_conf(self): |