2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
16 Documentation [BASIC-21] NS with only one VDU and several volumes
18 Library OperatingSystem
24 Resource ../lib/vnfd_lib.resource
25 Resource ../lib/vnf_lib.resource
26 Resource ../lib/nsd_lib.resource
27 Resource ../lib/ns_lib.resource
28 Resource ../lib/ssh_lib.resource
29 Resource ../lib/openstack_lib.resource
31 Test Tags basic_21 cluster_main daily regression
33 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
37 # NS and VNF descriptor package folder and ids
38 ${VNFD_PKG} several_volumes_vnf
39 ${VNFD_NAME} several_volumes-vnf
40 ${NSD_PKG} several_volumes_ns
41 ${NSD_NAME} several_volumes-ns
43 # NS instance name and configuration
45 ${NS_CONFIG} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
47 # SSH keys and username to be used
48 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
49 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
53 ${VNF_MEMBER_INDEX} vnf-several-volumes
54 ${SUCCESS_RETURN_CODE} 0
59 [Documentation] Upload VNF package for the testsuite.
61 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
64 [Documentation] Upload NS package for the testsuite.
66 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
68 Network Service Instance Test
69 [Documentation] Instantiate NS for the testsuite.
71 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG} ${PUBLICKEY}
72 Set Suite Variable ${NS_ID} ${id}
75 [Documentation] Get NS identifier and stores as suite variable to be used later on.
77 ${variables}= Get Variables
78 IF not "\${ns_id}" in "${variables}"
79 ${id}= Get Ns Id ${NS_NAME}
80 Set Suite Variable ${NS_ID} ${id}
84 [Documentation] Get from VNF descriptor the expected number of volumes in the VNF.
86 ${rc} ${stdout}= Run And Return RC And Output osm vnfpkg-show ${VNFD_NAME} --literal | yq '.vdu[0]."virtual-storage-desc" | length'
87 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
88 ${num_virtual_storage}= Convert To Integer ${stdout}
89 Set Suite Variable ${VNF_NUM_VOLUMES} ${num_virtual_storage}
90 Log ${VNF_NUM_VOLUMES}
93 [Documentation] Get the mgmt IP address of the VNF.
95 Variable Should Exist ${NS_ID} msg=NS is not available
96 ${ip_addr}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX}
98 Set Suite Variable ${VNF_IP_ADDR} ${ip_addr}
100 # Get Persistent Volume Id
101 # [Documentation] Get VIM volume identifier of the persistent volume of the VNF.
103 # Variable Should Exist ${ns_id} msg=NS is not available
104 # ${vnfs_list}= Get Ns Vnf List ${ns_id}
105 # ${vim_id}= Get VNF VIM ID ${vnfs_list}[0]
106 # ${volumes_attached}= Get Server Property ${vim_id} volumes_attached
107 # ${match}= Get Regexp Matches ${volumes_attached} '([0-9a-f\-]+)' 1
108 # Set Suite Variable ${PERSISTENT_VOLUME_ID} ${match}[0]
111 [Documentation] Check that the number of volumes is the expected one.
113 Variable Should Exist ${VNF_IP_ADDR} msg=VNF is not available
114 Sleep 30 seconds Wait for SSH daemon to be up
115 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF_IP_ADDR} ${USERNAME} ${PASSWORD} ${PRIVATEKEY} sudo lsblk -l
117 ${lines}= Get Lines Containing String ${stdout} disk
118 ${num_lines}= Get Line Count ${lines}
119 IF ${num_lines} < ${VNF_NUM_VOLUMES} Fail msg=Number of disks (${num_lines}) is less than specified in VDU (${VNF_NUM_VOLUMES})
121 Delete NS Instance Test
122 [Documentation] Delete NS instance.
126 # Check Persistent Volume Was Deleted
127 # [Documentation] Check that the persistent volume was deleted.
129 # Variable Should Exist ${PERSISTENT_VOLUME_ID} msg=Volume is not available
130 # ${exists}= Check If Volume Exists ${PERSISTENT_VOLUME_ID}
133 # Fail msg=Persistent volume was deleted
134 # Set Suite Variable ${PERSISTENT_VOLUME_ID} ${EMPTY}}
136 # Log Persistent volume still exists, deleting...
137 # Delete Volume ${PERSISTENT_VOLUME_ID}
138 # Set Suite Variable ${PERSISTENT_VOLUME_ID} ${EMPTY}}
141 Delete NS Descriptor Test
142 [Documentation] Delete NS package from OSM.
144 Delete NSD ${NSD_NAME}
146 Delete VNF Descriptor Test
147 [Documentation] Delete VNF package from OSM.
149 Delete VNFD ${VNFD_NAME}
154 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
155 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
156 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
157 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}
158 # Run Keyword If Any Tests Failed Check Volume Was Deleted