From 2f56599f278527cad0ff3c4d00319cdf990924d4 Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Wed, 28 Mar 2018 13:19:45 +0800 Subject: Ocata test_capacity_check_nova_limits_outofram Change-Id: I7ff4321cb3af69e66c09bc62fc9a94ae4134e71d Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang --- ocata/ocata/resource/tests/test_capacity.py | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'ocata') diff --git a/ocata/ocata/resource/tests/test_capacity.py b/ocata/ocata/resource/tests/test_capacity.py index 3fb17f02..ded870b8 100644 --- a/ocata/ocata/resource/tests/test_capacity.py +++ b/ocata/ocata/resource/tests/test_capacity.py @@ -43,6 +43,18 @@ MOCK_GET_HYPER_STATATICS_RESPONSE = { } } +MOCK_GET_TENANT_LIMIT_RESPONSE_OUTOFRAM = { + "limits": { + "rate": [], + "absolute": { + "maxTotalRAMSize": 128 * 1024, + "totalRAMUsed": 1 * 1024, + "totalCoresUsed": 4, + "maxTotalCores": 20, + } + } +} + MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFVCPU = { "hypervisor_statistics": { "vcpus_used": 9, @@ -209,3 +221,22 @@ class TestCapacity(test_base.TestRequest): self.assertEquals(status.HTTP_200_OK, response.status_code) self.assertEqual({"result": False}, response.data) + + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_capacity_check_nova_limits_outofram(self, mock_get_vim_info, mock_get_session): + mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO + mock_get_session.return_value = test_base.get_mock_session( + ["get"], { + "side_effect": [ + self._get_mock_response(MOCK_GET_TENANT_LIMIT_RESPONSE_OUTOFRAM), + self._get_mock_response(MOCK_GET_HYPER_STATATICS_RESPONSE), + self._get_mock_response(MOCK_GET_STORAGE_RESPONSE), + ] + }) + + response = self.client.post( + "/api/multicloud-ocata/v0/windriver-hudson-dc_RegionOne/capacity_check", + data=json.dumps(TEST_REQ_SUCCESS_SOURCE), + content_type='application/json', + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) -- cgit 1.2.3-korg