1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
14 Documentation [SA-02] VNF with VIM-based metrics and auto-scaling.
16 Library OperatingSystem
21 Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
22 Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
23 Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
24 Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
25 Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot
27 Variables %{ROBOT_DEVOPS_FOLDER}/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py
29 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
37 ${vnf_ip_addr} ${EMPTY}
39 ${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
44 [Tags] vnf_vim_metrics_autoscaling sanity regression
46 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'
50 [Tags] vnf_vim_metrics_autoscaling sanity regression
52 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
55 Instantiate Network Service
56 [Tags] vnf_vim_metrics_autoscaling sanity regression
58 ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
59 Set Suite Variable ${ns_id} ${id}
63 [Tags] vnf_vim_metrics_autoscaling sanity regression
65 @{vnfr_list}= Get Ns Vnfr Ids ${ns_id}
67 Set Suite Variable ${vnf_id} ${vnfr_list}[0]
71 [Tags] vnf_vim_metrics_autoscaling sanity regression
73 ${ip_addr}= Get Vnf Management Ip Address ${ns_id} ${vnf_member_index}
75 Set Suite Variable ${vnf_ip_addr} ${ip_addr}
78 Get VNF VIM-based Metric Before Auto-scaling
79 [Tags] vnf_vim_metrics_autoscaling sanity regression
81 Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
82 Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
83 Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
84 ${metric_value}= Wait Until Keyword Succeeds 6 times 2 minutes Get Metric ${prometheus_host} ${prometheus_port} ${metric_name}
85 Run Keyword Unless ${metric_value} > 0 Fail msg=The metric '${metric_name}' value is '${metric_value}'
86 Run Keyword Unless ${metric_value} < ${metric_threshold} Fail msg=The metric '${metric_name}' value is higher than '${metric_threshold}' before scaling
89 Increase VIM-based Metric To Force Auto-scaling
90 [Tags] vnf_vim_metrics_autoscaling sanity regression
92 Variable Should Exist ${privatekey} msg=SSH private key not available
93 Execute Remote Command Check Rc Return Output ${vnf_ip_addr} ${username} ${password} ${privatekey} for i in {1..9}; do yes > /dev/null & done
96 Wait VIM-based Metric To Exceed Threshold
97 [Tags] vnf_vim_metrics_autoscaling sanity regression
99 Wait Until Keyword Succeeds 6 times 2 minutes Check VIM-based Metric Exceeds Threshold
102 Get VDUs After Auto-scaling
103 [Tags] vnf_vim_metrics_autoscaling sanity regression
105 Sleep 1 minute Wait for auto-scale to take place
106 @{vdur_list}= Get Vnf Vdur Names ${vnf_id}
107 Log List ${vdur_list}
108 ${vdurs}= Get Length ${vdur_list}
109 Run Keyword Unless ${vdurs} > 1 Fail msg=There is no new VDU after auto-scaling
113 [Tags] vnf_vim_metrics_autoscaling sanity regression cleanup
119 [Tags] vnf_vim_metrics_autoscaling sanity regression cleanup
121 Delete NSD ${nsd_name}
124 Delete VNF Descriptor
125 [Tags] vnf_vim_metrics_autoscaling sanity regression cleanup
127 Delete VNFD ${vnfd_name}
132 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
134 Run Keyword If Any Tests Failed Delete NS ${ns_name}
135 Run Keyword If Any Tests Failed Delete NSD ${nsd_name}
136 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
139 Check VIM-based Metric Exceeds Threshold
140 [Documentation] Auxiliar keyword to check if metric exceeds threshold
142 Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
143 Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
144 Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
145 ${metric_value}= Get Metric ${prometheus_host} ${prometheus_port} ${metric_name}
146 Run Keyword Unless ${metric_value} > ${metric_threshold} Fail msg=The metric '${metric_name}' value is '${metric_value}' which is lower than '${metric_threshold}'