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-28] NS with one VDU which has 2 persistent volumes with keep flag
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_28 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} keep_persistent_volume_vnf
39 ${VNFD_NAME} keep_persistent-volumes-vnf
40 ${NSD_PKG} keep_persistent_volume_ns
41 ${NSD_NAME} persistent_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-persistent-volumes
54 ${VDU_ID} keep-persistent-vol-VM
55 ${ROOT_DISK} root-volume
56 ${ORDINARY_DISK} persistent-volume
57 ${SUCCESS_RETURN_CODE} 0
62 [Documentation] Upload VNF package for the testsuite.
63 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
66 [Documentation] Upload NS package for the testsuite.
67 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
69 Network Service Instance Test
70 [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}
74 Check Persistent Volume Counts
75 [Documentation] Check that the number of persistent volumes attached to VM in the NS meet the expected number (2).
76 Variable Should Exist ${NS_ID} msg=NS is not available
77 ${VOLUME_MATCH}= Get Persistent Volumes Attached To Vm ${NS_ID}
78 Set Suite Variable ${VOLUME_MATCH}
79 ${VOLUME_COUNTS}= Get Length ${VOLUME_MATCH}
80 Set Suite Variable ${VOLUME_COUNTS}
81 IF ${VOLUME_COUNTS} != 2 Fail msg=There were not 2 volumes attached to VM
83 Set Persistent Volume Ids
84 [Documentation] Get the identifiers of the persistent volumes attached to VM in the NS and store in suite variables ROOT_VOL_ID and ORDINARY_VOL_ID.
85 Variable Should Exist ${VOLUME_MATCH} msg=NS is not available
86 Set Volume Id ${VOLUME_MATCH} 0
87 Set Volume Id ${VOLUME_MATCH} 1
89 Delete NS Instance Test
90 [Documentation] Delete NS instance.
93 Check Persistent Root Volume in VIM after NS Deleted
94 [Documentation] Check that the persistent root volume requested to be kept is present after deleting NS instance.
95 Variable Should Exist ${ROOT_VOL_ID} msg=Root volume is not available
96 ${root_vol_exists}= Check If Volume Exists ${ROOT_VOL_ID}
97 Log ${root_vol_exists}
99 Log Persistent root volume still exists
101 Fail msg=Persistent root volume was deleted
102 Set Suite Variable ${ROOT_VOL_ID} ${EMPTY}
105 Check Persistent Ordinary Volume in VIM after NS Deleted
106 [Documentation] Check that the persistent ordinary volume requested to be kept is present after deleting NS instance.
107 Variable Should Exist ${ORDINARY_VOL_ID} msg=Ordinary persistent volume is not available
108 ${ordinary_vol_exists}= Check If Volume Exists ${ORDINARY_VOL_ID}
109 Log ${ordinary_vol_exists}
110 IF ${ordinary_vol_exists}
111 Log Persistent ordinary volume still exists
113 Fail msg=Persistent ordinary volume was deleted
114 Set Suite Variable ${ORDINARY_VOL_ID} ${EMPTY}
117 Prepare Ns Config With Volume Id
118 [Documentation] Generate NS instantiation parameters to be used in next NS instance,
119 ... using the persistent volumes that were kept previously.
120 Set Suite Variable ${NS_CONFIG_WITH_VIM_ID} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ], vnf: [ {member-vnf-index: ${VNF_MEMBER_INDEX}, vdu: [ {id: ${VDU_ID}, volume: [{"name": ${ROOT_DISK}, vim-volume-id: ${ROOT_VOL_ID}}, {"name": ${ORDINARY_DISK}, vim-volume-id: ${ORDINARY_VOL_ID}}] } ] } ] }
122 Network Service Instance With Existing Volumes Test
123 [Documentation] Instantiate NS for the testsuite again. The persistent volumes passed as instantiation parameters should be used.
124 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG_WITH_VIM_ID} ${PUBLICKEY}
125 Set Suite Variable ${NS_ID} ${id}
127 Verify the Attachment Of Existing Persistent Volumes
128 [Documentation] Get the identifiers of the persistent volumes attached to VM in the second NS instance and verify that they are the same
129 ... of the first NS instance.
130 Set Suite Variable ${PREV_ROOT_VOL_ID} ${ROOT_VOL_ID}
131 Set Suite Variable ${PREV_ORDINARY_VOL_ID} ${ORDINARY_VOL_ID}
132 ${volume_match}= Get Persistent Volumes Attached To Vm ${NS_ID}
133 Set Suite Variable ${VOLUME_MATCH}
134 Set Volume Id ${VOLUME_MATCH} 0
135 Set Volume Id ${VOLUME_MATCH} 1
136 Should Be Equal As Strings ${ROOT_VOL_ID} ${PREV_ROOT_VOL_ID} msg=Existing root volume is not attached to server
137 Should Be Equal As Strings ${ORDINARY_VOL_ID} ${PREV_ORDINARY_VOL_ID} msg=Existing ordinary volume is not attached to server
139 Delete NS Instance With Existing Volumes Test
140 [Documentation] Delete NS instance.
144 Check Existence of Persistent Volumes
145 [Documentation] Check that the persistent volumes exist after deleting the NS.
146 Variable Should Exist ${ROOT_VOL_ID} msg=Volume is not available
147 Variable Should Exist ${ORDINARY_VOL_ID} msg=Volume is not available
148 ${root_vol_exists}= Check If Volume Exists ${ROOT_VOL_ID}
149 IF not ${root_vol_exists} Fail msg=Existing root volume is deleted
150 ${ordinary_vol_exists}= Check If Volume Exists ${ORDINARY_VOL_ID}
151 IF not ${ordinary_vol_exists} Fail msg=Existing ordinary volume is deleted
153 Delete Persistent Volumes
154 [Documentation] Delete persistent volumes.
155 Clean Persistent Volumes
157 Delete NS Descriptor Test
158 [Documentation] Delete NS package from OSM.
160 Delete NSD ${NSD_NAME}
162 Delete VNF Descriptor Test
163 [Documentation] Delete VNF package from OSM.
165 Delete VNFD ${VNFD_NAME}
170 [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim
171 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
172 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
173 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}
174 Run Keyword If Any Tests Failed Clean Persistent Volumes
176 Clean Persistent Volumes
177 [Documentation] Delete root and ordinary volumes.
179 Delete Volume ${ROOT_VOL_ID}
180 Delete Volume ${ORDINARY_VOL_ID}