Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / sol003_01-vnf-lifecycle-management.robot
index 18a2e13..6e84541 100644 (file)
-#   Licensed under the Apache License, Version 2.0 (the "License");\r
-#   you may not use this file except in compliance with the License.\r
-#   You may obtain a copy of the License at\r
-#\r
-#       http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-#   Unless required by applicable law or agreed to in writing, software\r
-#   distributed under the License is distributed on an "AS IS" BASIS,\r
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-#   See the License for the specific language governing permissions and\r
-#   limitations under the License\r
-\r
-*** Settings ***\r
-Documentation     [SOL003-01] Sol003 Api testing\r
-Suite Teardown    Run Keyword And Ignore Error    Suite Cleanup\r
-Force Tags        sol003_01   cluster_sol003   daily\r
-Library           OperatingSystem\r
-Library           String\r
-Library           Collections\r
-Library           RequestsLibrary\r
-Library           HttpLibrary.HTTP\r
-Library           yaml\r
-Library           JsonValidator\r
-Library           JSONLibrary\r
-Resource          %{ROBOT_DEVOPS_FOLDER}/lib/sol003-common.robot\r
-Variables         %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf-lifecycle-management.json\r
-Resource          %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot\r
-\r
-*** Variables ***\r
-${vnfd_pkg}       hackfest_basic_metrics_vnf\r
-${vnfd_name}      hackfest_basic_metrics_vnf\r
-\r
-*** Test Cases ***\r
-Create VNF package from JSON file descriptor\r
-    [Documentation]    Test case to create a VNF Identifier\r
-    Create VIM\r
-    Get Auth Token\r
-    ${json_path}=    Read Directory\r
-    ${json_obj}=    Load JSON From File    ${json_path}/sol003_01-vnf-lifecycle-management.json\r
-    ${json_obj}=    Get Variable Value    ${json_obj['data'][0]}\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${json_obj}    $..vimAccountId    ${created_vim_account_id}\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${updated_json_obj}    $..additionalParams.virtual-link-desc[0][id]    %{VIM_MGMT_NET}\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${updated_json_obj}    $..additionalParams.virtual-link-profile-id    %{VIM_MGMT_NET}\r
-    Set Suite Variable    ${updated_json_obj}\r
-    Post API Request    ${vnf_instance_uri}\r
-    Pass Execution If    ${request_response.status_code} in ${success_status_code_list}    Query VNF Instance completed\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $..id\r
-    Set Suite Variable    ${createid}    ${id[0]}\r
-\r
-Instantiate VNF\r
-    [Documentation]    Test case to Instantiate a VNF\r
-    ${id}=    Create VNFD    '%{PACKAGES_FOLDER}/${vnfd_pkg}'\r
-    Set Suite Variable    ${vnfid}    ${id}\r
-    Get Auth Token\r
-    ${json_path}=    Read Directory\r
-    ${json_obj}=    Load JSON From File    ${json_path}/sol003_01-vnf-lifecycle-management.json\r
-    ${json_obj}=    Get Variable Value    ${json_obj['data'][1]}\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${json_obj}    $..vimAccountId    ${created_vim_account_id}\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${json_obj}    $..vnfId    ${createid}\r
-    Post API Request    ${vnf_instantiate_uri}/${createid}/instantiate\r
-    Pass Execution If    ${request_response.status_code} in ${success_status_code_list}    Instantiate VNF Instance completed\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $..id\r
-    Set Suite Variable    ${instantiateid}    ${id[0]}\r
-    Sleep    12s\r
-\r
-Query VNF Instances\r
-    [Documentation]    Test case to query VNF Instance\r
-    Get Auth Token\r
-    Get Api Request    ${vnf_instance_uri}\r
-    ${value}=    Get ID    nsState\r
-    Should Be Equal    ${value}    INSTANTIATED\r
-    Pass Execution If    ${request_response.status_code} in ${success_status_code_list}    Query VNF Instance completed\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $.._id\r
-    Set Suite Variable    ${Queryid}    ${id[0]}\r
-\r
-Query VNF Instance ID\r
-    [Documentation]    Test case to query Vnf instance ID\r
-    Get Auth Token\r
-    Get Api Request    ${vnf_instance_uri}/${Queryid}\r
-    ${value}=    Get ID    nsState\r
-    Should Be Equal    ${value}    INSTANTIATED\r
-    Should Be Equal As Strings    ${RequestResponse.status_code}    202\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $.._id\r
-    Set Suite Variable    ${Instanceid}    ${id[0]}\r
-\r
-Query VNF LCM Ops\r
-    [Documentation]    Test case to Query VNF LCM operation\r
-    Get Auth Token\r
-    Get Api Request    ${vnf_instance_lcm_ops}\r
-    ${ID1}=    Get Value From Json    ${request_response.json()}    $.._id\r
-    Set Suite Variable    ${lcmops}    ${ID1[0]}\r
-    ${value}=    Get ID    operationState\r
-    Should Be Equal    ${value}    COMPLETED\r
-\r
-Query VNF LCM Ops ID\r
-    Get Auth Token\r
-    Get Api Request    ${vnf_instance_lcm_ops}/${lcmops}\r
-    ${ID1}=    Get Value From Json    ${request_response.json()}    $.._id\r
-    Set Suite Variable    ${lcmopsid}    ${ID1[0]}\r
-    ${value}=    Get ID    operationState\r
-    : FOR    ${Index}    IN RANGE    0    15\r
-    \    ${status}=    Run Keyword And Return Status    Should Be Equal    ${value}    COMPLETED\r
-    \    Run Keyword Unless    ${status}    Sleep    10s\r
-    \    Run Keyword If    ${status}    Exit For Loop\r
-\r
-Scale VNF\r
-    [Documentation]    Test case to Scale in and Scale out VNF\r
-    Get Auth Token\r
-    ${json_path}=    Read Directory\r
-    ${updated_json_obj}=    Load JSON From File    ${json_path}/sol003_01-vnf-lifecycle-management.json\r
-    ${updated_json_obj}=    Get Variable Value    ${updated_json_obj['data'][2]}\r
-    Set Suite Variable    ${updated_json_obj}\r
-    Post API Request    ${vnf_instance_uri}/${createid}/scale\r
-    ${value}=    Get ID    id\r
-    ${ID1}=    Get Value From Json    ${request_response.json()}    $..id\r
-    Set Suite Variable    ${scaleoutid}    ${ID1[0]}\r
-    Sleep    5s\r
-    ${json_path}=    Read Directory\r
-    ${updated_json_obj}=    Load JSON From File    ${json_path}/sol003_01-vnf-lifecycle-management.json\r
-    ${updated_json_obj}    JSONLibrary.Update Value To Json    ${updated_json_obj}    $..type    SCALE_IN\r
-    Set Suite Variable    ${updated_json_obj}\r
-    Post API Request    ${vnf_instance_uri}/${createid}/scale\r
-    Pass Execution If    ${request_response.status_code} in ${success_status_code_list}    Scale VNF instance completed\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $..id\r
-    Set Suite Variable    ${scaleind}    ${id[0]}\r
-    Sleep    10s\r
-\r
-Terminate VNF\r
-    [Documentation]    Test case to terminate the VNF\r
-    Get Auth Token\r
-    ${json_path}=    Read Directory\r
-    ${updated_json_obj}=    Load JSON From File    ${json_path}/sol003_01-vnf-lifecycle-management.json\r
-    ${updated_json_obj}=    Get Variable Value    ${updated_json_obj['data'][3]}\r
-    Set Suite Variable    ${updated_json_obj}\r
-    Post API Request   ${vnf_instance_uri}/${createid}/terminate\r
-    ${id}=    Get Value From Json    ${request_response.json()}    $..id\r
-    Set Suite Variable    ${terminateid}    ${id[0]}\r
-    Pass Execution If    ${request_response.status_code} in ${success_status_code_list}    Terminate VNF instance completed\r
-    sleep    10s\r
-\r
-Delete VNF\r
-    [Documentation]    Test case to delete VNF\r
-    Get Auth Token\r
-    Create Session    APISession    ${HOST}\r
-    &{Headers}    Create Dictionary    Content-Type=application/json    Accept=application/json    Authorization=Bearer ${AccessToken}\r
-    ${resp}=    Delete Request    APISession    ${vnf_instance_uri}/${createid}\r
-    Pass Execution If    ${resp.status_code} in ${success_status_code_list}    Delete VNF Instance completed\r
+*** Comments ***
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License
+
+
+*** Settings ***
+Documentation   [SOL003-01] Sol003 Api testing
+
+Library   OperatingSystem
+Library   String
+Library   Collections
+Library   RequestsLibrary
+Library   yaml
+Library   JsonValidator
+Library   JSONLibrary
+
+Resource   ../lib/rest_lib.resource
+Resource   ../lib/vnfd_lib.resource
+Resource   ../lib/ns_lib.resource
+Resource   ../lib/vnf_lib.resource
+Resource   ../lib/vim_lib.resource
+
+Test Tags   sol003_01   cluster_osm_rest   daily   regression
+
+Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
+
+
+*** Variables ***
+# SOL003 API URI paths
+${VNF_INSTANCE_URI}   /osm/vnflcm/v1/vnf_instances
+${VNF_INSTANCE_LCM_OPS}   /osm/vnflcm/v1/vnf_lcm_op_occs
+
+# NS and VNF descriptor package folder and ids
+${VNFD_PKG}   hackfest_basic_metrics_vnf
+${VNFD_NAME}   hackfest_basic_metrics-vnf
+
+
+*** Test Cases ***
+Create VNF Package From JSON File
+    [Documentation]   Create a VNF package and update it via SOL003 interface using a JSON file
+    Get VNFDs List
+    ${id}=   Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
+    Log   ${id}
+    ${CREATED_VIM_ACCOUNT_ID}=   Get VIM Target ID   %{VIM_TARGET}
+    Set Suite Variable   ${CREATED_VIM_ACCOUNT_ID}
+    Get Auth Token
+    ${json_path}=   Read Directory
+    ${json_obj}=   Load JSON From File   ${json_path}/sol003_01-vnf-lifecycle-management.json
+    ${json_obj}=   Get Variable Value   ${json_obj['data'][0]}
+    ${UPDATED_JSON_OBJ}=   JSONLibrary.Update Value To Json   ${json_obj}   $..vimAccountId   ${CREATED_VIM_ACCOUNT_ID}
+    Log   ${UPDATED_JSON_OBJ}
+    ${UPDATED_JSON_OBJ}=   JSONLibrary.Update Value To Json   ${UPDATED_JSON_OBJ}   $..additionalParams.virtual-link-desc[0][id]   %{VIM_MGMT_NET}
+    Log   ${UPDATED_JSON_OBJ}
+    ${UPDATED_JSON_OBJ}=   JSONLibrary.Update Value To Json   ${UPDATED_JSON_OBJ}   $..additionalParams.virtual-link-profile-id   %{VIM_MGMT_NET}
+    Log   ${UPDATED_JSON_OBJ}
+    Set Test Variable   ${UPDATED_JSON_OBJ}
+    Post Api Request   ${VNF_INSTANCE_URI}   ${UPDATED_JSON_OBJ}
+    Pass Execution If   ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Query VNF Instance completed
+    ${id}=   Get Value From Json   ${request_response.json()}   $..id
+    Set Suite Variable   ${CREATEID}   ${id[0]}
+    Get VNFDs List
+
+Instantiate VNF
+    [Documentation]   Test case to Instantiate a VNF
+    Get Ns List
+    Get Vnf List
+    Get Auth Token
+    ${json_path}=   Read Directory
+    ${json_obj}=   Load JSON From File   ${json_path}/sol003_01-vnf-lifecycle-management.json
+    ${json_obj}=   Get Variable Value   ${json_obj['data'][1]}
+    ${UPDATED_JSON_OBJ}=   JSONLibrary.Update Value To Json   ${json_obj}   $..vimAccountId   ${CREATED_VIM_ACCOUNT_ID}
+    ${UPDATED_JSON_OBJ}=   JSONLibrary.Update Value To Json   ${UPDATED_JSON_OBJ}   $..vnfId   ${CREATEID}
+    Set Test Variable   ${UPDATED_JSON_OBJ}
+    Post Api Request   ${VNF_INSTANCE_URI}/${CREATEID}/instantiate   ${UPDATED_JSON_OBJ}
+    Pass Execution If   ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Instantiate VNF Instance completed
+    ${id}=   Get Value From Json   ${request_response.json()}   $..id
+    Set Suite Variable   ${INSTANTIATEID}   ${id[0]}
+    Sleep   12s
+    Get Ns List
+    Get Vnf List
+
+Query VNF Instances
+    [Documentation]   Test case to query VNF Instance
+    Get Auth Token
+    Get Api Request   ${VNF_INSTANCE_URI}
+    ${value}=   Get ID   nsState
+    Should Be Equal   ${value}   INSTANTIATED
+    Pass Execution If   ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Query VNF Instance completed
+    ${id}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${QUERYID}   ${id[0]}
+
+Query VNF Instance ID
+    [Documentation]   Test case to query Vnf instance ID
+    Get Auth Token
+    Get Api Request   ${VNF_INSTANCE_URI}/${QUERYID}
+    ${value}=   Get ID   nsState
+    Should Be Equal   ${value}   INSTANTIATED
+    Should Be Equal As Strings   ${RequestResponse.status_code}   200
+    ${id}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${INSTANCEID}   ${id[0]}
+
+Query VNF LCM Ops
+    [Documentation]   Test case to Query VNF LCM operation
+    Get Auth Token
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}
+    ${id1}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${LCMOPS}   ${id1[0]}
+    FOR   ${index}   IN RANGE   0   15
+        Log   ${index}
+        Get Api Request   ${VNF_INSTANCE_LCM_OPS}
+        ${value}=   Get ID   operationState
+        ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
+        IF   ${status}
+            BREAK
+        ELSE
+            Sleep   10s
+        END
+    END
+
+Query VNF LCM Ops ID
+    [Documentation]   Check if the operation has completed.
+    Get Auth Token
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${LCMOPS}
+    ${id1}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${LCMOPSID}   ${id1[0]}
+    FOR   ${index}   IN RANGE   0   15
+        Log   ${index}
+        Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${LCMOPS}
+        ${value}=   Get ID   operationState
+        ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
+        IF   ${status}
+            BREAK
+        ELSE
+            Sleep   10s
+        END
+    END
+
+Scale VNF
+    [Documentation]   Scale out VNF
+    Get Auth Token
+    ${json_path}=   Read Directory
+    ${updated_json_obj}=   Load JSON From File   ${json_path}/sol003_01-vnf-lifecycle-management.json
+    ${updated_json_obj}=   Get Variable Value   ${UPDATED_JSON_OBJ['data'][2]}
+    Set Test Variable   ${UPDATED_JSON_OBJ}
+    Post Api Request   ${VNF_INSTANCE_URI}/${CREATEID}/scale   ${UPDATED_JSON_OBJ}
+    ${value}=   Get ID   id
+    ${id1}=   Get Value From Json   ${request_response.json()}   $..id
+    Set Suite Variable   ${SCALEOUTID}   ${id1[0]}
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${SCALEOUTID}
+    ${LcmopsScale}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${LCMOPSSCALEID}   ${LcmopsScale[0]}
+    FOR   ${index}   IN RANGE   0   15
+        Log   ${index}
+        Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${SCALEOUTID}
+        ${value}=   Get ID   operationState
+        ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
+        IF   ${status}
+            BREAK
+        ELSE
+            Sleep   10s
+        END
+    END
+    Pass Execution If   ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Scale VNF instance completed
+
+Terminate VNF
+    [Documentation]   Test case to terminate the VNF
+    Get Auth Token
+    ${json_path}=   Read Directory
+    ${updated_json_obj}=   Load JSON From File   ${json_path}/sol003_01-vnf-lifecycle-management.json
+    ${updated_json_obj}=   Get Variable Value   ${UPDATED_JSON_OBJ['data'][3]}
+    Set Suite Variable   ${UPDATED_JSON_OBJ}
+    Post Api Request   ${VNF_INSTANCE_URI}/${CREATEID}/terminate   ${UPDATED_JSON_OBJ}
+    ${id}=   Get Value From Json   ${request_response.json()}   $..id
+    Set Suite Variable   ${TERMINATEID}   ${id[0]}
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${TERMINATEID}
+    ${LcmopsTerminate}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${LCMOPSSCALEID}   ${LcmopsTerminate[0]}
+    FOR   ${index}   IN RANGE   0   15
+        Log   ${index}
+        Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${TERMINATEID}
+        ${value}=   Get ID   operationState
+        ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
+        IF   ${status}
+            BREAK
+        ELSE
+            Sleep   10s
+        END
+    END
+    Pass Execution If   ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Terminate VNF instance completed
+
+Delete VNF
+    [Documentation]   Delete VNF instance.
+    Get Auth Token
+    Create Session   APISession   ${REST_API_HOST}
+    &{Headers}=   Create Dictionary   Content-Type=application/json   Accept=application/json   Authorization=Bearer ${ACCESS_TOKEN}
+    ${resp}=   DELETE On Session   APISession   ${VNF_INSTANCE_URI}/${CREATEID}   headers=${Headers}
+    Pass Execution If   ${resp.status_code} in ${SUCCESS_STATUS_CODE_LIST}   Delete VNF Instance completed
+
+Delete VNF Descriptor Test
+    [Documentation]   Delete VNF package from OSM.
+    [Tags]   cleanup
+    Delete VNFD   ${VNFD_NAME}
+
+
+*** Keywords ***
+Suite Cleanup
+    [Documentation]   Test Suit Cleanup: Deleting Descriptor
+    Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}