blob: 9b68f156ad7eb81c5e292e2b092a9b3139865758 [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
garciadeblasf33d2cd2025-11-27 10:04:32 +010026${NS_ACTION_MAX_WAIT_TIME} 2min
garciadeblas7a9e0312023-12-11 22:24:46 +010027${NS_ACTION_POL_TIME} 15sec
28${VNF_SCALE_POL_TIME} 15sec
29${HEALING_POL_TIME} 15sec
30${VIM_TIMEOUT_MULTIPLIER} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
31
32
33*** Keywords ***
34Update Network Service
35 [Documentation] Run an update operation over a NS instance, and return the operation id.
36 [Arguments] ${ns_id} ${update_type} ${ns_update_config} ${ns_update_timeout}
37 ${rc} ${stdout}= Run And Return Rc And Output osm ns-update ${ns_id} --updatetype ${update_type} --config ${ns_update_config} --timeout ${ns_update_timeout} --wait
38 Log ${stdout}
39 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
40 RETURN ${stdout}
41
42Execute NS Action
43 [Documentation] Execute an action over the desired NS.
44 ... Parameters are given to this function in key=value format (one argument per key/value pair).
45 ... Return the ID of the operation associated to the executed action.
46 ... Examples of execution:
47 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
48 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
49
50 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
51 ${params}= Set Variable ${EMPTY}
52 FOR ${param} IN @{action_params}
53 ${match} ${param_name} ${param_value}= Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
54 Log ${match},${param_name},${param_value}
55 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
56 END
57 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
58 IF '${params}' != '${EMPTY}'
59 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} --params '{${params}}'
60 ELSE
61 ${osm_ns_action_command}= Set Variable ${osm_ns_action_command}
62 END
63 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
64 ${rc} ${stdout}= Run And Return Rc And Output ${osm_ns_action_command}
65 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
66 Wait Until Keyword Succeeds ${NS_ACTION_MAX_WAIT_TIME} ${NS_ACTION_POL_TIME} Check For NS Operation Ended ${stdout}
67 Check For NS Operation Completed ${stdout}
68 RETURN ${stdout}
69
70Execute NS K8s Action
71 [Documentation] Execute an action over the desired K8s NS.
72 ... Parameters are given to this function in key=value format (one argument per key/value pair).
73 ... Return the ID of the operation associated to the executed action.
74 ... Examples of execution:
75 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
76 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
77
78 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
79
80 ${params}= Set Variable ${EMPTY}
81 FOR ${param} IN @{action_params}
82 ${match} ${param_name} ${param_value}= Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
83 Log ${match},${param_name},${param_value}
84 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
85 END
86 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
87 IF '${params}' != '${EMPTY}'
88 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} --params '{${params}}'
89 ELSE
90 ${osm_ns_action_command}= Set Variable ${osm_ns_action_command}
91 END
92 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
93 ${rc} ${stdout}= Run And Return Rc And Output ${osm_ns_action_command}
94 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
95 Wait Until Keyword Succeeds ${NS_ACTION_MAX_WAIT_TIME} ${NS_ACTION_POL_TIME} Check For NS Operation Ended ${stdout}
96 Check For NS Operation Completed ${stdout}
97 RETURN ${stdout}
98
99Execute Manual VNF Scale
100 [Documentation] Execute a manual VNF Scale action.
101 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
102 ... Return the ID of the operation associated to the executed scale action.
103 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
104 ${vnf_scale_max_wait_time}= Convert Time ${vnf_scale_max_wait_time} result_format=number
105 ${vnf_scale_max_wait_time}= Evaluate ${vnf_scale_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
106 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
107 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
108 IF '${scale_type}'=='SCALE_IN'
109 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} --scale-in
110 ELSE
111 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} --scale-out
112 END
113 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
114 ${rc} ${stdout}= Run And Return Rc And Output ${osm_vnf_scale_command}
115 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
116 Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${VNF_SCALE_POL_TIME} Check For NS Operation Ended ${stdout}
117 Check For NS Operation Completed ${stdout}
118 RETURN ${stdout}
119
120Heal Network Service
121 [Documentation] Execute healing operation over one NS.
122 ... Return the ID of the operation associated to the executed healing action.
123 [Arguments] ${ns_name} ${params} ${healing_max_wait_time}=10m
124 Should Not Be Empty ${ns_name}
125 Should Not Be Empty ${params}
126 ${healing_max_wait_time}= Convert Time ${healing_max_wait_time} result_format=number
127 ${healing_max_wait_time}= Evaluate ${healing_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
128 ${rc} ${stdout}= Run And Return Rc And Output osm ns-heal ${ns_name} ${params}
129 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
130 Wait Until Keyword Succeeds ${healing_max_wait_time} ${HEALING_POL_TIME} Check For NS Operation Ended ${stdout}
131 Check For NS Operation Completed ${stdout}
132 RETURN ${stdout}
133
134Get Operations List
135 [Documentation] Get the list of operations of a given NS instance.
136 [Arguments] ${ns_name}
137 Should Not Be Empty ${ns_name}
138 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-list ${ns_name}
139 Log ${stdout}
140 Log ${rc}
141 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
142
143Check For NS Operation Completed
144 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
145 [Arguments] ${ns_operation_id}
146 Should Not Be Empty ${ns_operation_id}
147 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
148 Log ${stdout}
149 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
150 Should Contain ${stdout} COMPLETED msg=The ns-action with id ${ns_operation_id} was not completed values=False
151
152Check For NS Operation Failed
153 [Documentation] Check wheter the status of the desired operation is "FAILED" or not.
154 [Arguments] ${ns_operation_id}
155 Should Not Be Empty ${ns_operation_id}
156 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
157 Log ${stdout}
158 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
159 Should Contain ${stdout} FAILED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
160
161Check For NS Operation Ended
162 [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED".
163 [Arguments] ${ns_operation_id}
164 Should Not Be Empty ${ns_operation_id}
165 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
166 Log ${stdout}
167 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
168 Should Contain Any ${stdout} FAILED COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
169
170Check For NS Operation Cancelled
171 [Documentation] Check whether the operation was cancelled or not.
172 [Arguments] ${ns_operation_id}
173 Should Not Be Empty ${ns_operation_id}
174 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-show ${ns_operation_id} --literal | yq -r '.operationState, .isCancelPending'
175 Log ${stdout}
176 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
177 Should Contain ${stdout} FAILED_TEMP\nfalse msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
178
179Get Operations By Type
180 [Documentation] Keyword to get the operation by type
181 [Arguments] ${ns_id} ${type}
182 Should Not Be Empty ${ns_id}
183 Should Not Be Empty ${type}
184 ${rc} ${stdout}= Run And Return Rc And Output osm ns-op-list ${ns_id} | grep ${type} | awk '{print $2}' 2>&1
185 Log ${stdout}
186 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
187 Should Not Be Empty ${stdout}
188 RETURN ${stdout}
189
190Cancel Operation By Id
191 [Documentation] Cancels an ongoing operation by operation ID
192 [Arguments] ${op_id} ${cancel_mode}=GRACEFUL
193
194 Should Not Be Empty ${op_id}
195 ${rc} ${stdout}= Run And Return RC And Output osm ns-op-cancel ${op_id} --cancel_mode ${cancel_mode} --wait
196 Log ${stdout}
197 Should Be Equal As Integers ${rc} ${success_return_code}
198 RETURN ${stdout}