summaryrefslogtreecommitdiffstats
path: root/windriver
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-28 11:32:01 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-28 11:32:01 +0800
commitb7bb9f3929a178675f47e5f9f4f0c2199017c53c (patch)
treef77364eb6dbca338944bd8d09dbfac4f4420643e /windriver
parent0c6dc6457671100827fbd11e7c235867d6017f7a (diff)
Add TC UT for capacity_check fail in hypervisor
fail due to out of storage Change-Id: I65e345fa3d33a04e39f78ac1c2c6e298b662f045 Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver')
-rw-r--r--windriver/titanium_cloud/resource/tests/test_capacity.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/windriver/titanium_cloud/resource/tests/test_capacity.py b/windriver/titanium_cloud/resource/tests/test_capacity.py
index effbc75b..05359e3d 100644
--- a/windriver/titanium_cloud/resource/tests/test_capacity.py
+++ b/windriver/titanium_cloud/resource/tests/test_capacity.py
@@ -52,6 +52,15 @@ MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFRAM = {
}
}
+MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFSTORAGE = {
+ "hypervisor_statistics" : {
+ "vcpus_used" : 4,
+ "free_ram_mb" : 120*1024,
+ "vcpus" : 10,
+ "free_disk_gb" : 3
+ }
+}
+
MOCK_GET_STORAGE_RESPONSE = {
"limits" : {
"rate" : [],
@@ -149,3 +158,26 @@ 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-titanium_cloud/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)
+
+