Launching the NS using the Dualstackip
Change-Id: I8bb8e9c492ef8519b3888e8695fe1905d66a5dd8
Signed-off-by: rarik <arika.r@tataelxsi.co.in>
diff --git a/robot-systest/lib/ns_lib.robot b/robot-systest/lib/ns_lib.robot
index a37e509..c8da271 100644
--- a/robot-systest/lib/ns_lib.robot
+++ b/robot-systest/lib/ns_lib.robot
@@ -415,4 +415,13 @@
${rc} ${stdout}= Run and Return RC and Output osm ns-op-cancel ${op_id} --cancel_mode ${cancel_mode} --wait
Log ${stdout}
Should Be Equal As Integers ${rc} ${success_return_code}
- [Return] ${stdout}
\ No newline at end of file
+ [Return] ${stdout}
+
+GET Dual Ip
+ [Documentation] Get dual ip from the ns list
+ [Arguments] ${ns_id}
+ Should Not Be Empty ${ns_id}
+ ${rc} ${stdout}= Run and Return RC and Output osm ns-show ${ns_id} --literal | grep -A2 ip-address | awk '{print $2}' | paste -sd ',' | sed 's/^,//; s/,/, /g' | sed 's/^/[/; s/$/]/'
+ Log ${stdout}
+ [Return] ${stdout}
+
diff --git a/robot-systest/resources/sol003_Dualstackip.json b/robot-systest/resources/sol003_Dualstackip.json
new file mode 100644
index 0000000..a1b1b49
--- /dev/null
+++ b/robot-systest/resources/sol003_Dualstackip.json
@@ -0,0 +1,41 @@
+{
+ "data":[
+ {
+ "vnfdId":"hackfest_basic-vnf",
+ "vnfInstanceName":"sol003-instance",
+ "vnfInstanceDescription":"Test vnfm instance description",
+ "vimAccountId":"8dc2f11d-e08a-4ec7-920c-6b8a88bff1e5",
+ "additionalParams":{
+ "virtual-link-desc":[
+ {
+ "id":"mgmtnet",
+ "mgmt-network":true,
+ "vim-network-name": "IPv6"
+ }
+ ],
+ "constituent-cpd-id":"vnf-cp0-ext",
+ "ip-address": ["2001:db8::5", "192.168.158.6"],
+ "virtual-link-profile-id":"mgmtnet"
+ }
+ },
+ {
+ "vnfName":"sol003-instance",
+ "vnfDescription":"vnf package",
+ "vnfId":"70b47595-fafa-4f63-904b-fc3ada60eebb",
+ "vimAccountId":"8dc2f11d-e08a-4ec7-920c-6b8a88bff1e5"
+ },
+ {
+ "type":"SCALE_OUT",
+ "aspectId":"vdu_autoscale",
+ "numberOfSteps":"1",
+ "additionalParams":{
+ "member-vnf-index":"1"
+ }
+ },
+ {
+ "terminationType":"GRACEFUL",
+ "gracefulTerminationTimeout":"5"
+ }
+ ]
+}
+
diff --git a/robot-systest/testsuite/sol003_02-dualstack_ip_vnfm.robot b/robot-systest/testsuite/sol003_02-dualstack_ip_vnfm.robot
new file mode 100644
index 0000000..4c16dd8
--- /dev/null
+++ b/robot-systest/testsuite/sol003_02-dualstack_ip_vnfm.robot
@@ -0,0 +1,201 @@
+# 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-02 Sol003 This script launches dual-stack IP addresses NS in VIM and verify the dualstack ip
+
+Library OperatingSystem
+Library String
+Library Collections
+Library RequestsLibrary
+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
+
+Force 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
+
+# NS and VNF descriptor package folder and ids
+${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}
+ 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}
+ 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_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
+ 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
+
+Get Ns Id
+ [Documentation] Get the ns id from the ns list
+ ${id}= Get Ns Id ${ns_name}
+ 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}
+
+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
+ 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
+ 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}
+ ${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
+ END
+
+Verify Dual Ip
+ Should Be Equal ${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
+ ${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
+ 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
+ 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}
+ 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}
+
+
+*** Keywords ***
+Suite Cleanup
+ [Documentation] Test Suit Cleanup: Deleting Descriptor
+
+ Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
+
+
+
+