diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-28 17:50:23 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-28 17:50:23 +0800 |
commit | b443099bc49e7b402e673b44c0daf2318e70c92d (patch) | |
tree | 05234f07417ba64e359ab614c842f5be0dd00d28 | |
parent | 371ca5061b683b45df8d5b6988fc3d1e5cb67a23 (diff) |
test_register_hpa_cputopology_successfully for TC
Change-Id: Idb357805da2c13071c43715e7c7bf6d2c2513f0b
Issue-ID: MULTICLOUD-203
Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 147 |
1 files changed, 94 insertions, 53 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index a8c84b69..7adace49 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -118,6 +118,45 @@ TEST_REGISTER_ENDPOINT_REQUEST = { } +# HPA UT1: CPU-PINNING +MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE= { + "flavors": [ + { + "id": "1", "name": "micro", "vcpus": 1, "ram": "1MB", + "disk": "1G", "OS-FLV-EXT-DATA:ephemeral": False, + "swap": True, "os-flavor-access:is_public": True, + "OS-FLV-DISABLED:disabled": True, "link": [{"href": 1}] + }, + { + "id": "2", "name": "onap.mini", "vcpus": 2, "ram": "2MB", + "disk": "2G", "OS-FLV-EXT-DATA:ephemeral": True, + "swap": False, "os-flavor-access:is_public": True, + "OS-FLV-DISABLED:disabled": True + }, + ] +} + +MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE = { + "extra_specs": { + "aggregate_instance_extra_specs:storage": "local_image", + "capabilities:cpu_info:model": "Haswell", + "hw:cpu_policy": "dedicated", + "hw:cpu_thread_policy": "prefer" + } +} + +# HPA UT2: CPU-Topology +MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS2_RESPONSE = { + "extra_specs": { + "aggregate_instance_extra_specs:storage": "local_image", + "capabilities:cpu_info:model": "Haswell", + "hw:cpu_sockets": "2", + "hw:cpu_cores": "4", + "hw:cpu_threads": "16" + } +} + + class TestRegistration(test_base.TestRequest): @@ -191,62 +230,64 @@ class TestRegistration(test_base.TestRequest): self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, response.status_code) + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_register_hpa_cpupinning_successfully( + self, mock_get_vim_info, mock_get_session): + restcall.req_to_aai = mock.Mock() + restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) + 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_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE), + self._get_mock_response(MOCK_GET_IMAGE_RESPONSE), + self._get_mock_response(), + self._get_mock_response(MOCK_GET_AZ_RESPONSE), + self._get_mock_response(MOCK_HYPERVISOR_RESPONSE), + self._get_mock_response(MOCK_GET_SNAPSHOT_RESPONSE), + self._get_mock_response(MOCK_GET_HYPERVISOR_RESPONSE) + ] + }) + + response = self.client.post(( + "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "registry"), TEST_REGISTER_ENDPOINT_REQUEST, + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + self.assertEquals(status.HTTP_202_ACCEPTED, + response.status_code) -# HPA UT1: CPU-PINNING -MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE= { - "flavors": [ - { - "id": "1", "name": "micro", "vcpus": 1, "ram": "1MB", - "disk": "1G", "OS-FLV-EXT-DATA:ephemeral": False, - "swap": True, "os-flavor-access:is_public": True, - "OS-FLV-DISABLED:disabled": True, "link": [{"href": 1}] - }, - { - "id": "2", "name": "onap.mini", "vcpus": 2, "ram": "2MB", - "disk": "2G", "OS-FLV-EXT-DATA:ephemeral": True, - "swap": False, "os-flavor-access:is_public": True, - "OS-FLV-DISABLED:disabled": True - }, - ] -} + @mock.patch.object(VimDriverUtils, 'get_session') + @mock.patch.object(VimDriverUtils, 'get_vim_info') + def test_register_hpa_topo_successfully( + self, mock_get_vim_info, mock_get_session): + restcall.req_to_aai = mock.Mock() + restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) + 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_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE), + self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS2_RESPONSE), + self._get_mock_response(MOCK_GET_IMAGE_RESPONSE), + self._get_mock_response(), + self._get_mock_response(MOCK_GET_AZ_RESPONSE), + self._get_mock_response(MOCK_HYPERVISOR_RESPONSE), + self._get_mock_response(MOCK_GET_SNAPSHOT_RESPONSE), + self._get_mock_response(MOCK_GET_HYPERVISOR_RESPONSE) + ] + }) -MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE = { - "extra_specs": { - "aggregate_instance_extra_specs:storage": "local_image", - "capabilities:cpu_info:model": "Haswell", - "hw:cpu_policy": "dedicated", - "hw:cpu_thread_policy": "prefer" - } -} + response = self.client.post(( + "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + "registry"), TEST_REGISTER_ENDPOINT_REQUEST, + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) -@mock.patch.object(VimDriverUtils, 'get_session') -@mock.patch.object(VimDriverUtils, 'get_vim_info') -def test_register_hpa_cpupinning_successfully( - self, mock_get_vim_info, mock_get_session): - restcall.req_to_aai = mock.Mock() - restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) - 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_RESPONSE), - self._get_mock_response(MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE), - self._get_mock_response(MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE), - self._get_mock_response(MOCK_GET_IMAGE_RESPONSE), - self._get_mock_response(), - self._get_mock_response(MOCK_GET_AZ_RESPONSE), - self._get_mock_response(MOCK_HYPERVISOR_RESPONSE), - self._get_mock_response(MOCK_GET_SNAPSHOT_RESPONSE), - self._get_mock_response(MOCK_GET_HYPERVISOR_RESPONSE) - ] - }) - - response = self.client.post(( - "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" - "registry"), TEST_REGISTER_ENDPOINT_REQUEST, - HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - - self.assertEquals(status.HTTP_202_ACCEPTED, + self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code) + |