def test_collect_gnocchi_rate_instance(self, build_gnocchi_client, _):
mock_gnocchi_client = mock.Mock()
mock_gnocchi_client.metric = mock.Mock()
+ mock_vim_session = mock.Mock()
mock_gnocchi_client.metric.get_measures.return_value = [
(
datetime.datetime(
]
build_gnocchi_client.return_value = mock_gnocchi_client
- backend = GnocchiBackend({"_id": "test_uuid"})
+ backend = GnocchiBackend({"_id": "test_uuid"}, mock_vim_session)
value = backend._collect_instance_metric("cpu", "test_resource_id")
self.assertEqual(value, 1.0)
mock_gnocchi_client.metric.get_measures.assert_called_once_with(
@mock.patch.object(GnocchiBackend, "_build_gnocchi_client")
def test_collect_gnocchi_non_rate_instance(self, build_gnocchi_client, _):
mock_gnocchi_client = mock.Mock()
+ mock_vim_session = mock.Mock()
mock_gnocchi_client.metric.get_measures.return_value = [
(
datetime.datetime(
]
build_gnocchi_client.return_value = mock_gnocchi_client
- backend = GnocchiBackend({"_id": "test_uuid"})
+ backend = GnocchiBackend({"_id": "test_uuid"}, mock_vim_session)
value = backend._collect_instance_metric("memory.usage", "test_resource_id")
self.assertEqual(value, 128)
mock_gnocchi_client.metric.get_measures.assert_called_once_with(
@mock.patch.object(GnocchiBackend, "_build_gnocchi_client")
def test_collect_gnocchi_no_metric(self, build_gnocchi_client, _):
mock_gnocchi_client = mock.Mock()
+ mock_vim_session = mock.Mock()
mock_gnocchi_client.metric.get_measures.side_effect = (
gnocchiclient.exceptions.NotFound()
)
build_gnocchi_client.return_value = mock_gnocchi_client
- backend = GnocchiBackend({"_id": "test_uuid"})
+ backend = GnocchiBackend({"_id": "test_uuid"}, mock_vim_session)
value = backend._collect_instance_metric("memory.usage", "test_resource_id")
self.assertIsNone(value)
mock_gnocchi_client.metric.get_measures.assert_called_once_with(
self, build_gnocchi_client, build_neutron_client
):
mock_gnocchi_client = mock.Mock()
+ mock_vim_session = mock.Mock()
mock_gnocchi_client.resource.search.return_value = [
{"id": "test_id_1"},
{"id": "test_id_2"},
build_gnocchi_client.return_value = mock_gnocchi_client
- backend = GnocchiBackend({"_id": "test_uuid"})
+ backend = GnocchiBackend({"_id": "test_uuid"}, mock_vim_session)
value = backend._collect_interface_all_metric(
"packets_received", "test_resource_id"
)