summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-28 19:40:10 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-28 19:40:10 +0800
commitb5bfb3bfb3bbb0c668ced0ddda7d63579ecf73b8 (patch)
tree6e9c788ac85c24cfa47e2478ce9ca9e7ec7bf407
parentac11df702aa10322667e4b189ee2f8177e837955 (diff)
ocata test_register_pcipassthrough_successfully
Change-Id: I8be683ecd85b88481876c150deae55e460f5bcaa Issue-ID: MULTICLOUD-206 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--ocata/ocata/registration/tests/test_registration.py59
-rw-r--r--ocata/ocata/registration/views/registration.py1
2 files changed, 49 insertions, 11 deletions
diff --git a/ocata/ocata/registration/tests/test_registration.py b/ocata/ocata/registration/tests/test_registration.py
index 067e4089..c35eddfa 100644
--- a/ocata/ocata/registration/tests/test_registration.py
+++ b/ocata/ocata/registration/tests/test_registration.py
@@ -36,15 +36,15 @@ OCATA_MOCK_VIM_INFO = {
'cloud_owner': 'windriver-hudson-dc',
'cloud_region_id': 'RegionOne',
'cloud_extra_info':
- '{'
- '"ovsDpdk":{'
- '"version": "v1",'
- '"arch": "Intel64",'
- '"libname":"dataProcessingAccelerationLibrary",'
- '"libvalue":"v12.1",'
- '}'
- '}',
- 'insecure': 'True',
+ {
+ "ovsDpdk":{
+ "version": "v1",
+ "arch": "Intel64",
+ "libname":"dataProcessingAccelerationLibrary",
+ "libvalue":"v12.1",
+ }
+ },
+ 'insecure': 'True'
}
MOCK_GET_TENANT_RESPONSE = {
@@ -204,6 +204,15 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS5_RESPONSE = {
}
}
+# HPA UT6: pci passthrough
+MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE = {
+ "extra_specs": {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:4"
+ }
+}
+
MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS_RESPONSE = {
"extra_specs": {
"aggregate_instance_extra_specs:storage": "local_image",
@@ -236,7 +245,7 @@ class TestRegistration(test_base.TestRequest):
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_vim_info.return_value = OCATA_MOCK_VIM_INFO
mock_get_session.return_value = test_base.get_mock_session(
["get"], {
"side_effect": [
@@ -435,3 +444,33 @@ class TestRegistration(test_base.TestRequest):
self.assertEquals(status.HTTP_202_ACCEPTED,
response.status_code)
+ @mock.patch.object(VimDriverUtils, 'get_session')
+ @mock.patch.object(VimDriverUtils, 'get_vim_info')
+ def test_register_hpa_pcipassthrough_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_SPECS6_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-ocata/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)
+
diff --git a/ocata/ocata/registration/views/registration.py b/ocata/ocata/registration/views/registration.py
index 74b73b3b..636e3ecc 100644
--- a/ocata/ocata/registration/views/registration.py
+++ b/ocata/ocata/registration/views/registration.py
@@ -306,7 +306,6 @@ class Registry(newton_registration.Registry):
cloud_extra_info_str = viminfo.get('cloud_extra_info')
if cloud_extra_info_str :
- cloud_extra_info = json.loads(cloud_extra_info_str)
cloud_dpdk_info = cloud_extra_info.get("ovsDpdk")
if cloud_dpdk_info :
ovsdpdk_capability['hpaCapabilityID'] = str(feature_uuid)