diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-28 12:29:13 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-28 12:29:13 +0800 |
commit | 5932bcb2b9c7fdbd66e3d8fea3928c1fec24527e (patch) | |
tree | d585dcdcce622769a779cfd4502d880407ed7cb1 /newton | |
parent | e2af206ad46bc4dd7f1b6d607b7f33e89ddbfa5b (diff) |
Newton UT for capacity_check fail in hypervisor
fail due to out of storage
Change-Id: Ia460b88047de823a13386282c25cc5172ff9d500
Issue-ID: MULTICLOUD-203
Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r-- | newton/newton/resource/tests/test_capacity.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/newton/newton/resource/tests/test_capacity.py b/newton/newton/resource/tests/test_capacity.py index 662325ad..90d88944 100644 --- a/newton/newton/resource/tests/test_capacity.py +++ b/newton/newton/resource/tests/test_capacity.py @@ -43,6 +43,15 @@ MOCK_GET_HYPER_STATATICS_RESPONSE = { } } +MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFSTORAGE = { + "hypervisor_statistics" : { + "vcpus_used" : 4, + "free_ram_mb" : 120*1024, + "vcpus" : 10, + "free_disk_gb" : 3 + } +} + MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFRAM = { "hypervisor_statistics" : { "vcpus_used" : 4, @@ -148,3 +157,24 @@ 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_hypervisor_outofstorage(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), + self._get_mock_response(MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFSTORAGE), + 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) |