summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-28 12:55:05 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-28 12:55:05 +0800
commit0f64005f2ea39680dcafa43cca65de2a1dc88563 (patch)
treee45539b07b9bb9625715401652f246a1de1b1129 /ocata
parentd9fed0d8ec902f8be6a223aed9548f6807878361 (diff)
Ocata UT for capacity_check fail in hypervisor
fail due to out of RAM Change-Id: I8fdc222fdcd915ec40b846b2e1570b1b6f875bc1 Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'ocata')
-rw-r--r--ocata/ocata/resource/tests/test_capacity.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/ocata/ocata/resource/tests/test_capacity.py b/ocata/ocata/resource/tests/test_capacity.py
index f7892bd1..b0dc71e2 100644
--- a/ocata/ocata/resource/tests/test_capacity.py
+++ b/ocata/ocata/resource/tests/test_capacity.py
@@ -13,6 +13,7 @@
# limitations under the License.
import mock
+import json
from rest_framework import status
@@ -42,6 +43,15 @@ MOCK_GET_HYPER_STATATICS_RESPONSE = {
}
}
+MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFRAM = {
+ "hypervisor_statistics" : {
+ "vcpus_used" : 4,
+ "free_ram_mb" : 1*1024,
+ "vcpus" : 10,
+ "free_disk_gb" : 300
+ }
+}
+
MOCK_GET_STORAGE_RESPONSE = {
"limits" : {
"rate" : [],
@@ -116,3 +126,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_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),
+ self._get_mock_response(MOCK_GET_HYPER_STATATICS_RESPONSE_OUTOFRAM),
+ 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)
+
+ self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual({"result": False}, response.data)