summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/registration/tests
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-28 17:14:25 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-28 17:14:25 +0800
commit371ca5061b683b45df8d5b6988fc3d1e5cb67a23 (patch)
treede33197c0450e1d7ea3011aff9ed17ca472c833c /windriver/titanium_cloud/registration/tests
parent2bc5e9922a26af60cb42c2c0822faa241206b72b (diff)
test_register_hpa_cpupinning_successfully for TC
Change-Id: I07e65391ab3030202007a648fd9cef39dcef8497 Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/registration/tests')
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py91
1 files changed, 65 insertions, 26 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py
index 0b3a516d..a8c84b69 100644
--- a/windriver/titanium_cloud/registration/tests/test_registration.py
+++ b/windriver/titanium_cloud/registration/tests/test_registration.py
@@ -45,27 +45,6 @@ MOCK_GET_FLAVOR_RESPONSE = {
]
}
-MOCK_GET_FLAVOR_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",
- "hw:cpu_sockets" : "2",
- "hw:cpu_cores" : "4",
- "hw:cpu_threads" : "16",
- "hw:mem_page_size" : "large",
- "hw:numa_nodes" : "2",
- "hw:numa_cpus.0" : "0,1",
- "hw:numa_cpus.1" : "2,3,4,5",
- "hw:numa_mem.0" : "2048",
- "hw:numa_mem.1" : "2048",
- "hw:capabilities:cpu_info:features":"avx,acpi",
- "pci_passthrough:alias":"sriov-vf-intel-8086-15b3:4"
-
- }
-}
-
MOCK_GET_IMAGE_RESPONSE = {
"images": [
{
@@ -138,14 +117,16 @@ TEST_REGISTER_ENDPOINT_REQUEST = {
"defaultTenant": "project1"
}
-class TestFlavors(test_base.TestRequest):
+
+
+class TestRegistration(test_base.TestRequest):
def setUp(self):
- super(TestFlavors, self).setUp()
+ super(TestRegistration, self).setUp()
self.req_to_aai_backup = restcall.req_to_aai
def tearDown(self):
- super(TestFlavors, self).tearDown()
+ super(TestRegistration, self).tearDown()
restcall.req_to_aai = self.req_to_aai_backup
def _get_mock_response(self, return_value=None):
@@ -166,8 +147,6 @@ class TestFlavors(test_base.TestRequest):
"side_effect": [
self._get_mock_response(MOCK_GET_TENANT_RESPONSE),
self._get_mock_response(MOCK_GET_FLAVOR_RESPONSE),
- self._get_mock_response(MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE),
- self._get_mock_response(MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE),
self._get_mock_response(MOCK_GET_IMAGE_RESPONSE),
self._get_mock_response(),
self._get_mock_response(MOCK_GET_AZ_RESPONSE),
@@ -211,3 +190,63 @@ class TestFlavors(test_base.TestRequest):
self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR,
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_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"
+ }
+}
+
+@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)
+