| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 1 | # Copyright 2020 Atos |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| 16 | Library Collections |
| 17 | |
| 18 | |
| 19 | *** Variables *** |
| 20 | ${success_return_code} 0 |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 21 | ${slice_launch_pol_time} 30sec |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 22 | ${slice_delete_pol_time} 15sec |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 23 | ${vim_timeout_multiplier} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0} |
| 24 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 25 | |
| 26 | *** Keywords *** |
| 27 | |
| 28 | Create Network Slice |
| 29 | [Documentation] Instantiates a NST and returns an instantiation id (nsi), verifying the slice is successfully instantiated |
| 30 | ... Parameters: |
| 31 | ... nst: Name of the slice template |
| 32 | ... vim_name: Name of the VIM entry already in OSM |
| 33 | ... slice_name: Name of the slice instance |
| 34 | ... slice_config: Extra parameters that might require the slice instantiation i.e. configuration attributes |
| 35 | ... publickey: SSH public key of the local machine |
| 36 | ... Execution example: |
| 37 | ... \${nsi}= Create Network Slice \${nst} \${vim_name} \${slice_name} \${slice_config} \${publickey} |
| 38 | |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 39 | [Arguments] ${nst} ${vim_name} ${slice_name} ${slice_config} ${publickey} ${slice_launch_max_wait_time}=6min ${config_file}=${EMPTY} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 40 | |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 41 | ${slice_launch_max_wait_time}= Convert Time ${slice_launch_max_wait_time} result_format=number |
| 42 | ${slice_launch_max_wait_time}= Evaluate ${slice_launch_max_wait_time} * ${vim_timeout_multiplier} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 43 | ${config_attr} Set Variable If '${slice_config}'!='${EMPTY}' --config '${slice_config}' \ |
| 44 | ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \ |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 45 | ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \ |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 46 | |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 47 | ${nsi_id}= Instantiate Network Slice ${slice_name} ${nst} ${vim_name} ${config_attr} ${config_file_attr} ${sshkeys_attr} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 48 | log ${nsi_id} |
| 49 | |
| 50 | WAIT UNTIL KEYWORD SUCCEEDS ${slice_launch_max_wait_time} ${slice_launch_pol_time} Check For Network Slice Instance To Configured ${slice_name} |
| 51 | Check For Network Slice Instance For Failure ${slice_name} |
| 52 | [Return] ${nsi_id} |
| 53 | |
| 54 | |
| 55 | Instantiate Network Slice |
| 56 | [Documentation] Instantiates a NST and returns an instantiation id (nsi) |
| 57 | ... Parameters: |
| 58 | ... slice_name: Name of the slice instance |
| 59 | ... nst: Name of the slice template |
| 60 | ... vim_name: Name of the VIM entry already in OSM |
| 61 | ... slice_extra_args: Extra parameters that might require the slice instantiation i.e. configuration attributes |
| 62 | ... Execution example: |
| 63 | ... \${nsi}= Instantiate Network Slice \${slice_name} \${nst} \${vim_name} \${config_attr} |
| 64 | |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 65 | [Arguments] ${slice_name} ${nst} ${vim_name} ${slice_extra_args} ${sshkeys_attr} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 66 | |
| 67 | ${rc} ${stdout}= Run and Return RC and Output osm nsi-create --nsi_name ${slice_name} --nst_name ${nst} --vim_account ${vim_name} ${sshkeys_attr} ${slice_extra_args} |
| 68 | log ${stdout} |
| 69 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 70 | [Return] ${stdout} |
| 71 | |
| 72 | |
| 73 | Get Slice Ns List |
| 74 | [Documentation] Retrieves the list of NS in a slice |
| 75 | ... Parameters: |
| 76 | ... slice_name: Name of the slice instance |
| 77 | ... Execution example: |
| 78 | ... \@{slice_ns_list}= Get Slice Ns List \${slice_name} |
| 79 | |
| 80 | [Arguments] ${slice_name} |
| 81 | |
| 82 | Should Not Be Empty ${slice_name} |
| 83 | @{ns_list_string}= Run and Return RC and Output osm ns-list | grep ${slice_name} | awk '{print $4}' 2>&1 |
| 84 | # Returns a String of ns_id and needs to be converted into a list |
| 85 | @{ns_list} = Split String ${ns_list_string}[1] |
| 86 | Log List ${ns_list} |
| 87 | [Return] @{ns_list} |
| 88 | |
| 89 | |
| 90 | Get Slice Ns List Except One |
| 91 | [Documentation] Retrieves the list of NS in a slice removing one from the list. This is done to save time in the tests, avoiding one VNF to ping itself. |
| 92 | ... Parameters: |
| 93 | ... slice_name: Name of the slice instance |
| 94 | ... exception_ns: Name of the ns that will not appear in the final list |
| 95 | ... Execution example: |
| 96 | ... \@{slice_ns_list}= Get Slice Ns List Except One \${slice_name} \${exception_ns} |
| 97 | |
| 98 | [Arguments] ${slice_name} ${exception_ns} |
| 99 | |
| 100 | Should Not Be Empty ${slice_name} |
| 101 | Should Not Be Empty ${exception_ns} |
| 102 | |
| 103 | @{ns_list_string}= Run and Return RC and Output osm ns-list | grep ${slice_name} | awk '!/${exception_ns}/' | awk '{print $4}' 2>&1 |
| 104 | # Returns a String of ns_id and needs to be converted into a list |
| 105 | @{ns_list} = Split String ${ns_list_string}[1] |
| 106 | Log List ${ns_list} |
| 107 | [Return] @{ns_list} |
| 108 | |
| 109 | |
| 110 | Get Slice Ns Count |
| 111 | [Documentation] Returns the count of all the NS in a slice |
| 112 | ... Parameters: |
| 113 | ... slice_name: Name of the slice instance |
| 114 | ... Execution example: |
| 115 | ... \${slice_ns_count}= Get Slice Ns Count \${slice_name} |
| 116 | |
| 117 | [Arguments] ${slice_name} |
| 118 | |
| 119 | Should Not Be Empty ${slice_name} |
| 120 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list | grep ${slice_name} | wc -l 2>&1 |
| 121 | log ${stdout} |
| 122 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 123 | [Return] ${stdout} |
| 124 | |
| 125 | |
| 126 | Get Slice Vnf Ip Addresses |
| 127 | [Documentation] Retrieves the list of IP addresses that belong to each of the VNFs in the slice |
| 128 | ... Parameters: |
| 129 | ... slice_name: Name of the slice instance |
| 130 | ... Execution example: |
| 131 | ... \@{slice_ip_address_list}= Get Slice Vnf Ip Addresses \${slice_name} |
| 132 | |
| 133 | [Arguments] ${slice_name} |
| 134 | |
| 135 | # Get all the ns_id in the slice |
| 136 | @{slice_ns_list} Get Slice Ns List ${slice_name} |
| 137 | log many @{slice_ns_list} |
| 138 | @{temp_list}= Create List |
| 139 | # For each ns_id in the list, get all the vnf_id and their IP addresses |
| 140 | FOR ${ns_id} IN @{slice_ns_list} |
| 141 | log ${ns_id} |
| 142 | @{vnf_id_list} Get Ns Vnf List ${ns_id} |
| 143 | # For each vnf_id in the list, get all its IP addresses |
| 144 | @{ns_ip_list} Get Ns Ip List @{vnf_id_list} |
| 145 | @{temp_list}= Combine Lists ${temp_list} ${ns_ip_list} |
| 146 | END |
| 147 | Log List ${temp_list} |
| 148 | [Return] @{temp_list} |
| 149 | |
| 150 | |
| 151 | Check For Network Slice Instance To Configured |
| 152 | [Documentation] Verify the slice has been instantiated |
| 153 | ... Parameters: |
| 154 | ... slice_name: Name of the slice instance |
| 155 | ... Execution example: |
| 156 | ... Check For Network Slice Instance To Configured \${slice_name} |
| 157 | |
| 158 | [Arguments] ${slice_name} |
| 159 | |
| 160 | ${rc} ${stdout}= Run and Return RC and Output osm nsi-list --filter name="${slice_name}" |
| 161 | log ${stdout} |
| 162 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciadeblas | 6e121fd | 2022-05-20 13:13:01 +0200 | [diff] [blame] | 163 | Should Contain Any ${stdout} READY BROKEN configured |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 164 | |
| 165 | |
| 166 | Check For Network Slice Instance For Failure |
| 167 | [Documentation] Verify the slice instance is not in failure |
| 168 | ... Parameters: |
| 169 | ... slice_name: Name of the slice instance |
| 170 | ... Execution example: |
| 171 | ... Check For Network Slice Instance For Failure \${slice_name} |
| 172 | |
| 173 | [Arguments] ${slice_name} |
| 174 | |
| 175 | ${rc} ${stdout}= Run and Return RC and Output osm nsi-list --filter name="${slice_name}" |
| 176 | log ${stdout} |
| 177 | Should Be Equal As Integers ${rc} ${success_return_code} |
| aguilarherna | 17ed58b | 2021-01-27 12:50:04 +0000 | [diff] [blame] | 178 | Should Not Contain ${stdout} failed |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 179 | |
| 180 | |
| 181 | Delete NSI |
| 182 | [Documentation] Delete Network Slice Instance (NSI) |
| 183 | ... Parameters: |
| 184 | ... slice_name: Name of the slice instance |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 185 | ... slice_delete_max_wait_time: Delete operation timeout |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 186 | ... Execution example: |
| 187 | ... Delete NST \${slice_name} |
| 188 | |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 189 | [Arguments] ${slice_name} ${slice_delete_max_wait_time}=4min |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 190 | |
| 191 | ${rc} ${stdout}= Run and Return RC and Output osm nsi-delete ${slice_name} |
| 192 | log ${stdout} |
| 193 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 194 | |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 195 | ${slice_delete_max_wait_time}= Convert Time ${slice_delete_max_wait_time} result_format=number |
| 196 | ${slice_delete_max_wait_time}= Evaluate ${slice_delete_max_wait_time} * ${vim_timeout_multiplier} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 197 | WAIT UNTIL KEYWORD SUCCEEDS ${slice_delete_max_wait_time} ${slice_delete_pol_time} Check For Network Slice Instance To Be Deleted ${slice_name} |
| 198 | |
| 199 | |
| 200 | Check For Network Slice Instance To Be Deleted |
| 201 | [Documentation] Verify the slice instance is not present |
| 202 | ... Parameters: |
| 203 | ... slice_name: Name of the slice instance |
| 204 | ... Execution example: |
| 205 | ... Check For Network Slice Instance \${slice_name} |
| 206 | |
| 207 | [Arguments] ${slice_name} |
| 208 | |
| 209 | ${rc} ${stdout}= Run and Return RC and Output osm nsi-list | awk '{print $2}' | grep ${slice_name} |
| 210 | Should Not Be Equal As Strings ${stdout} ${slice_name} |
| 211 | |
| 212 | |