diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-28 12:36:37 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-28 12:36:37 +0800 |
commit | 2165c7dd12c4e6447c875f8d261d9b802d1b4def (patch) | |
tree | 55cf8cf0b3af5c6402860c282bec9377806a51be | |
parent | 330ccef9b10bc9dfa90dfeeaa334087f905d6082 (diff) |
Newton test_capacity_check_nova_limits_outofram
Change-Id: I6efe5583695b63849936a90e71f7b46eaa98f226
Issue-ID: MULTICLOUD-203
Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r-- | newton/newton/resource/tests/test_capacity.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/newton/newton/resource/tests/test_capacity.py b/newton/newton/resource/tests/test_capacity.py index 7c6452b0..3cdc8473 100644 --- a/newton/newton/resource/tests/test_capacity.py +++ b/newton/newton/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": 127 * 1024, + "totalCoresUsed": 4, + "maxTotalCores": 20, + } + } +} + MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFVCPU = { "hypervisor_statistics": { "vcpus_used": 9, @@ -210,3 +222,25 @@ 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-newton/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) + + self.assertEquals(status.HTTP_200_OK, response.status_code) + self.assertEqual({"result": False}, response.data) + |