blob: cce11c79da88e4d4347fe2aa0dab8034339c9db9 [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
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
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
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.
13
14
15*** Settings ***
16Documentation Library to deploy and delete NS, and run operations on them.
17
18Library Collections
19Library DateTime
20Library OperatingSystem
21Library String
22
23
24*** Variables ***
25${SUCCESS_RETURN_CODE} 0
26${NS_LAUNCH_POL_TIME} 30sec
27${NS_DELETE_POL_TIME} 15sec
28${VIM_TIMEOUT_MULTIPLIER} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
29
30
31*** Keywords ***
32Create Network Service
33 [Documentation] Launch the instantation of a NS and verify in a loop that the NS instance is successfully created in a given time, and return the NS instance id.
34 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
35 ${ns_launch_max_wait_time}= Convert Time ${ns_launch_max_wait_time} result_format=number
36 ${ns_launch_max_wait_time}= Evaluate ${ns_launch_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
37 Log ${ns_launch_max_wait_time}
38 ${config_attr}= Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' ${EMPTY}
39 ${sshkeys_attr}= Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} ${EMPTY}
40 ${config_file_attr}= Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' ${EMPTY}
41 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
42 Log ${ns_id}
43 Wait Until Keyword Succeeds ${ns_launch_max_wait_time} ${NS_LAUNCH_POL_TIME} Check For NS Instance To Configured ${ns_name}
44 Check For NS Instance For Failure ${ns_name}
45 RETURN ${ns_id}
46
47Instantiate Network Service
48 [Documentation] Launch the instantation of a NS, and return the NS instance id.
49 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
50 ${rc} ${stdout}= Run And Return Rc And Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} ${ns_extra_args}
51 Log ${stdout}
52 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
53 RETURN ${stdout}
54
55Get Vnf Management Ip Address
56 [Documentation] Get the mgmt IP address of a member VNF in a NS instance, and return it.
57 [Arguments] ${ns_id} ${vnf_member_index}
58 Should Not Be Empty ${ns_id}
59 Should Not Be Empty ${vnf_member_index}
60 ${rc} ${stdout}= Run And Return Rc And Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $14}' 2>&1
61 Log ${stdout}
62 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
63 RETURN ${stdout}
64
65Get Vnf Id
66 [Documentation] Get the VNF instance ID of a member VNF in a NS instance, and return it.
67 [Arguments] ${ns_id} ${vnf_member_index}
68 Should Not Be Empty ${ns_id}
69 Should Not Be Empty ${vnf_member_index}
70 ${rc} ${stdout}= Run And Return Rc And Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $2}' 2>&1
71 Log ${stdout}
72 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
73 RETURN ${stdout}
74
75Get Ns Id
76 [Documentation] Get the NS instance ID from a NS instance name passed as argument, and return it.
77 [Arguments] ${ns_name}
78 Should Not Be Empty ${ns_name}
79 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list | grep ${ns_name} | awk '{print $4}' 2>&1
80 Log ${stdout}
81 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
82 Should Not Be Empty ${stdout}
83 RETURN ${stdout}
84
85Get Ns List
86 [Documentation] Get the list of NS instances and return it.
87 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list 2>&1
88 Log ${stdout}
89 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
90 RETURN ${stdout}
91
92Get Ns Vnf List
93 [Documentation] Get the list of VNF instances of a given NS instance id, and return it.
94 [Arguments] ${ns_id}
95 Should Not Be Empty ${ns_id}
96 @{vnf_list_string}= Run And Return Rc And Output osm vnf-list --ns ${ns_id} | grep ${ns_id} | awk '{print $2}' 2>&1
97 # Returns a String of vnf_id and needs to be converted into a list
98 @{vnf_list}= Split String ${vnf_list_string}[1]
99 Log List ${vnf_list}
100 RETURN @{vnf_list}
101
102Get Ns Ip List
103 [Documentation] Obtain the list of IP addresses of all VM in a NS, and return it.
104 [Arguments] @{vnf_list}
105 Should Not Be Empty @{vnf_list}
106 @{temp_list}= Create List
107 FOR ${vnf_id} IN @{vnf_list}
108 Log ${vnf_id}
109 @{vnf_ip_list}= Get Vnf Ip List ${vnf_id}
110 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
111 END
112 Should Not Be Empty ${temp_list}
113 RETURN @{temp_list}
114
115Get Vnf Ip List
116 [Documentation] Obtain the list of IP addresses of all VM in a VNF, and return it.
117 [Arguments] ${vnf_id}
118 Should Not Be Empty ${vnf_id}
119 @{vnf_ip_list_string}= Run And Return Rc And Output osm vnf-list --filter id=${vnf_id} | grep -o '[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}' | sort -t: -u -k1,1 2>&1
120 # returns a string of ip addresses and needs to be converted into a list
121 Should Not Be Empty ${vnf_ip_list_string}[1]
122 @{vnf_ip_list}= Split String ${vnf_ip_list_string}[1]
123 Log Many ${vnf_ip_list}
124 Should Not Be Empty ${vnf_ip_list}
125 RETURN @{vnf_ip_list}
126
127Check For Ns Instance To Configured
128 [Documentation] Check if a given NS instance has completed the instantiation, no matter if it succeeded (the status should be READY or BROKEN).
129 [Arguments] ${ns_name}
130 ${rc} ${stdout}= Run And Return Rc And Output openstack server list
131 Log ${rc},${stdout}
132 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list --filter name="${ns_name}"
133 Log ${rc},${stdout}
134 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
135 Should Contain Any ${stdout} READY BROKEN
136
137Check For NS Instance For Failure
138 [Documentation] Check if a given NS instance has not failed in the instantiation (the status should not be BROKEN).
139 [Arguments] ${ns_name}
140 ${rc} ${stdout}= Run And Return Rc And Output openstack server list
141 Log ${rc},${stdout}
142 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list --filter name="${ns_name}"
143 Log ${rc},${stdout}
144 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
145 Should Not Contain ${stdout} BROKEN
146
147Check For NS Instance To Be Deleted
148 [Documentation] Check if a given NS instance is not present in OSM.
149 [Arguments] ${ns}
150 ${rc} ${stdout}= Run And Return Rc And Output openstack server list
151 Log ${rc},${stdout}
152 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list | awk '{print $2}' | grep ${ns}
153 Log ${rc},${stdout}
154 Should Not Be Equal As Strings ${stdout} ${ns}
155
156Delete NS
157 [Documentation] Delete a NS instance.
158 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
159 ${ns_delete_max_wait_time}= Convert Time ${ns_delete_max_wait_time} result_format=number
160 ${ns_delete_max_wait_time}= Evaluate ${ns_delete_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
161 Log ${ns_delete_max_wait_time}
162 ${rc} ${stdout}= Run And Return Rc And Output osm ns-delete ${ns}
163 Log ${stdout}
164 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
165 Wait Until Keyword Succeeds ${ns_delete_max_wait_time} ${NS_DELETE_POL_TIME} Check For NS Instance To Be Deleted ${ns}
166
167Get Ns Vnfr Ids
168 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
169 [Arguments] ${ns_id}
170 Should Not Be Empty ${ns_id}
171 ${rc} ${stdout}= Run And Return Rc And Output osm vnf-list --ns ${ns_id} | grep ${ns_id} | awk '{print $2}' 2>&1
172 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
garciadeblas17169ca2024-07-10 16:47:17 +0200173 @{vnfr}= Split String ${stdout}
174 RETURN @{vnfr}
garciadeblas7a9e0312023-12-11 22:24:46 +0100175
176Get Vnf Vdur Names
177 [Documentation] Return a list with the names of the VDU records of a VNF instance.
178 [Arguments] ${vnf_id}
179 Should Not Be Empty ${vnf_id}
180 ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq -r .vdur[].name
181 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
182 @{vdur}= Split String ${stdout}
183 RETURN @{vdur}
184
Pedro Pereira46b097a2024-06-22 12:23:51 +0100185Check Kdu Labels
186 [Documentation] Return the labels of the deployed Kubernetes objects associated with a NS instance.
187 [Arguments] ${ns_id} ${vnf_id} ${kdu_name}
188 Should Not Be Empty ${ns_id}
189 Should Not Be Empty ${vnf_id}
190 Should Not Be Empty ${kdu_name}
191 ${rc} ${stdout}= Run And Return Rc And Output osm ns-show ${ns_id} --literal | yq -r '._admin.deployed.K8s[0]."detailed-status"' | yq -r '.manifest[0].metadata.labels'
192 Log ${stdout}
193 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
194 ${labels}= Evaluate json.loads('''${stdout}''') json
195 Should Be Equal As Strings ${labels["managed-by"]} osm.etsi.org msg=${labels}
196 Should Be Equal As Strings ${labels["osm.etsi.org/ns-id"]} ${ns_id} msg=${labels}
197 Should Be Equal As Strings ${labels["osm.etsi.org/vnf-id"]} ${vnf_id} msg=${labels}
198 Should Be Equal As Strings ${labels["osm.etsi.org/kdu-name"]} ${kdu_name} msg=${labels}
199 RETURN ${labels}
200
garciadeblas7a9e0312023-12-11 22:24:46 +0100201Get Vnf Kdu Replica Count
202 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
203 [Arguments] ${vnf_id} ${kdu_name}
204 Should Not Be Empty ${vnf_id}
205 Should Not Be Empty ${kdu_name}
206 ${rc} ${stdout}= Run And Return Rc And Output osm vnf-show ${vnf_id} --kdu ${kdu_name} | yq -r .config.replicaCount
207 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
208 ${return}= Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout}
209 RETURN ${return}
210
211Get Application Names
212 [Documentation] Return the list of the application of a VNF instance.
213 [Arguments] ${ns_name}
214 Should Not Be Empty ${ns_name}
215 ${rc} ${stdout}= Run And Return Rc And Output osm ns-show ${ns_name} --literal | yq -r ._admin.deployed.VCA[].application
216 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
217 @{app_names}= Split String ${stdout}
218 RETURN ${app_names}
219
220Get VDU Affinity Group Name
221 [Documentation] Return the affinity group name for a NF
222 [Arguments] ${ns_name} ${vnf_id} ${vdur_id}
223 ${rc} ${affinity_group_id}= Run And Return Rc And Output osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(.id == "'${vdur_id}'")' | yq -r '."affinity-or-anti-affinity-group-id"[0]' 2>&1
224 Log ${affinity_group_id}
225 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${affinity_group_id} values=False
226 ${rc} ${affinity_group_name}= Run And Return Rc And Output osm ns-show ${ns_name} --literal | yq '."affinity-or-anti-affinity-group"[] | select(.id == "'${affinity_group_id}'")' | yq -r '.name' 2>&1
227 Log ${affinity_group_name}
228 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${affinity_group_name} values=False
229 RETURN ${affinity_group_name}
230
garciadeblasdba7f6b2023-12-18 11:54:35 +0100231Get Dual Ip
garciadeblas7a9e0312023-12-11 22:24:46 +0100232 [Documentation] Get dual ip from the ns list
233 [Arguments] ${ns_id}
234 Should Not Be Empty ${ns_id}
sritharan9e5450f2023-12-26 07:04:44 +0000235 ${rc} ${stdout}= Run And Return RC And Output osm ns-show ${ns_id} --literal | grep -A2 ip-address | grep -v "ip-address:" | awk '{print $2}' | tr -d ',-'
garciadeblas7a9e0312023-12-11 22:24:46 +0100236 Log ${rc},${stdout}
237 RETURN ${stdout}
sritharan9e5450f2023-12-26 07:04:44 +0000238
239Get NSD Id From The NS
240 [Documentation] Get the nsd id from the ns
241 [Arguments] ${ns_id}
242 Should Not Be Empty ${ns_id}
243 ${stdout}= Run osm ns-show ${ns_id} --literal | grep nsd-id | awk '{print $2}'
244 Log ${stdout}
245 RETURN ${stdout}
uniyalna55a88742024-07-11 10:04:59 +0000246
247Get Additional Params And Values From Kdu
248 [Documentation] Return the value of additional params (empty if none) of a KNF instance.
249 [Arguments] ${ns_name} ${param_name}
250 Should Not Be Empty ${ns_name}
251 Should Not Be Empty ${param_name}
252 ${rc0} ${stdout0}= Run And Return Rc And Output osm ns-show ${ns_name} --literal | yq -e '._admin.deployed' | yq '.K8s[]."detailed-status"'
253 Should Be Equal As Integers ${rc0} ${SUCCESS_RETURN_CODE} msg=${stdout0} values=False
254 ${rc} ${stdout}= Run And Return Rc And Output echo ${stdout0} | yq '.config.${param_name}'
255 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
256 ${return}= Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout}
257 RETURN ${return}