Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / testsuite / sol003_02-dualstack_ip_vnfm.robot
index 4c16dd8..6a2ae7a 100644 (file)
@@ -1,3 +1,4 @@
+*** 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
@@ -10,8 +11,9 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License
 
+
 *** Settings ***
-Documentation Sol003-02 Sol003   This script launches dual-stack IP addresses NS in VIM and verify the dualstack ip
+Documentation   [Sol003-02] Sol003 Dual Stack IP in VNFM NB interface
 
 Library   OperatingSystem
 Library   String
@@ -21,55 +23,53 @@ Library   yaml
 Library   JsonValidator
 Library   JSONLibrary
 
-Resource   %{ROBOT_DEVOPS_FOLDER}/lib/rest_lib.robot
-Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
-Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
-Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot
-Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot
+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
 
-Force Tags   sol003_02   cluster_osm_rest   daily
+Test Tags   sol003_02   cluster_osm_rest   daily
 
 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
 
 
 *** Variables ***
 # SOL003 API URI paths
-${vnf_instance_uri}   /osm/vnflcm/v1/vnf_instances
-${vnf_instantiate_uri}   /osm/vnflcm/v1/vnf_instances
-${vnf_instance_lcm_ops}   /osm/vnflcm/v1/vnf_lcm_op_occs
+${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_vnf
-${vnfd_name}   hackfest_basic-vnf
+${VNFD_PKG}   hackfest_basic_vnf
+${VNFD_NAME}   hackfest_basic-vnf
 
 
 *** Test Cases ***
-
 Create VNFD Descriptor
     [Documentation]   Test case to create a VNF Identifier
-    ${vnfd_id}=   Create VNFD   %{PACKAGES_FOLDER}/${vnfd_pkg}
-    Set Suite Variable   ${vnfd_id}
-    ${created_vim_account_id}=   Get VIM Target ID   %{VIM_TARGET}
-    Set Suite Variable   ${created_vim_account_id}
+    ${VNFD_ID}=   Create VNFD   %{PACKAGES_FOLDER}/${VNFD_PKG}
+    Set Suite Variable   ${VNFD_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_DualStackip.json
     ${json_obj}=   Get Variable Value   ${json_obj['data'][0]}
-    ${ns_name}=   Get Variable Value   ${json_obj['vnfInstanceName']}
-    Set Suite Variable   ${ns_name}
-    ${Value1}=   Get Variable Value   ${json_obj['additionalParams']['ip-address']}
-    Set Suite Variable   ${Value1}
-    ${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}
+    ${NS_NAME}=   Get Variable Value   ${json_obj['vnfInstanceName']}
+    Set Suite Variable   ${NS_NAME}
+    ${VALUE1}=   Get Variable Value   ${json_obj['additionalParams']['ip-address']}
+    Set Suite Variable   ${VALUE1}
+    ${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]}
+    Set Suite Variable   ${CREATEID}   ${id[0]}
     Get VNFDs List
 
 Instantiate VNF
@@ -80,122 +80,128 @@ Instantiate VNF
     ${json_path}=   Read Directory
     ${json_obj}=   Load JSON From File   ${json_path}/sol003_DualStackip.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_instantiate_uri}/${createid}/instantiate
+    ${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]}
+    Set Suite Variable   ${VNF_INSTANCE_ID}   ${id[0]}
     Sleep   12s
     Get Ns List
     Get Vnf List
 
 Get Ns Id
-    [Documentation]   Get the ns id from the ns list
+    [Documentation]   Get the NS identifier
     ${id}=   Get Ns Id   ${ns_name}
-    Set Suite Variable   ${ns_id}   ${id}
+    Set Suite Variable   ${NS_ID}   ${id}
 
 Get Dual Ip
-    [Documentation]   Get the ip from the ns list
-    ${id}=   Get Dual Ip   ${ns_id}
-    Set Suite Variable   ${ip}   ${id}
+    [Documentation]   Get the IP address from the NS
+    ${id}=   Get Dual Ip   ${NS_ID}
+    Set Suite Variable   ${DUAL_IP}   ${id}
 
 Query VNF Instances
     [Documentation]   Test case to query VNF Instance
     Get Auth Token
-    Get Api Request   ${vnf_instance_uri}
+    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]}
+    Set Suite Variable   ${QUERY_ID}   ${id[0]}
 
 Query VNF Instance ID
     [Documentation]   Test case to query Vnf instance ID
     Get Auth Token
-    Get Api Request   ${vnf_instance_uri}/${Queryid}
+    Get Api Request   ${VNF_INSTANCE_URI}/${QUERY_ID}
     ${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]}
+    Log   ${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
-    Get Api Request   ${vnf_instance_lcm_ops}
-    ${value}=   Get ID   operationState
-    ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
-    Run Keyword If   ${status}   Exit For Loop
-    ...   ELSE   Sleep   10s
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}
+    ${id1}=   Get Value From Json   ${request_response.json()}   $.._id
+    Set Suite Variable   ${LCM_OP_ID}   ${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]   Test case to Query VNF LCM operation id
     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
-        Get Api Request   ${vnf_instance_lcm_ops}/${lcmops}
+    Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${LCM_OP_ID}
+    ${id1}=   Get Value From Json   ${request_response.json()}   $.._id
+    Log   ${id1[0]}
+    FOR   ${index}   IN RANGE   0   15
+        Log   ${index}
+        Get Api Request   ${VNF_INSTANCE_LCM_OPS}/${LCM_OP_ID}
         ${value}=   Get ID   operationState
         ${status}=   Run Keyword And Return Status   Should Be Equal   ${value}   COMPLETED
-        Run Keyword If   ${status}   Exit For Loop
-        ...   ELSE   Sleep   10s
+        IF   ${status}
+            BREAK
+        ELSE
+            Sleep   10s
+        END
     END
 
 Verify Dual Ip
-    Should Be Equal   ${ip}   ${Value1}
-
+    [Documentation]   Test case to terminate the VNF
+    Should Be Equal   ${DUAL_IP}   ${VALUE1}
 
 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_DualStackip.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}=   Load JSON From File   ${json_path}/sol003_DualStackip.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}
+    ${terminateid}=   Set Variable   ${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
-        Get Api Request   ${vnf_instance_lcm_ops}/${terminateid}
+    Log   ${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
-        Run Keyword If   ${status}   Exit For Loop
-        ...   ELSE   Sleep   10s
+        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]   Test case to delete VNF
     Get Auth Token
-    Create Session   APISession   ${HOST}
-    &{Headers}   Create Dictionary   Content-Type=application/json   Accept=application/json   Authorization=Bearer ${AccessToken}
-    ${resp}=   DELETE On Session   APISession   ${vnf_instance_uri}/${createid}   headers=${Headers}
+    Create Session   APISession   ${REST_API_HOST}
+    &{Headers}=   Create Dictionary   Content-Type=application/json   Accept=application/json   Authorization=Bearer ${AccessToken}
+    ${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]   Test case to delete the VNF descriptor test
     [Tags]   cleanup
-
-    Delete VNFD   ${vnfd_name}
+    Delete VNFD   ${VNFD_NAME}
 
 
 *** Keywords ***
 Suite Cleanup
     [Documentation]   Test Suit Cleanup: Deleting Descriptor
-
-    Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}
-
-
-
-
+    Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}