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-07] Events or alarms coming from SA-related VNFs in the NS.
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_07-alarms_from_sa-related_vnfs_data.py
29 Force Tags sa_07 cluster_sa daily regression
31 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
35 # NS instantiation parameters
36 ${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
38 # NS and VNF descriptor package folder and ids
39 ${vnfd_pkg} cirros_alarm_vnf
40 ${vnfd_name} cirros_alarm-vnf
41 ${vnfd_file} cirros_alarm_vnfd.yaml
42 ${new_vnfd_pkg} new_cirros_alarm_vnf
43 ${nsd_pkg} cirros_alarm_ns
44 ${nsd_name} cirros_alarm-ns
46 # NS instance name and id
48 ${ns_name} sa_07-alarm_test
50 # Webhook NS and VNF descriptor package folder and ids
51 ${ws_vnfd_pkg} hackfest_basic_vnf
52 ${ws_nsd_pkg} hackfest_basic_ns
53 ${ws_vnfd_name} hackfest_basic-vnf
54 ${ws_nsd_name} hackfest_basic-ns
56 # Webhook NS instance name and id
58 ${ws_ns_name} sa_07-webhook_service_test
60 # Webhook NS Variables
61 ${ws_vnf_member_index} vnf
62 ${ws_vnf_ip_addr} ${EMPTY}
63 ${ws_log_file} webhook.log
65 ${ws_alarm_msg} notify_alarm
67 # SSH keys and username to be used
68 ${publickey} %{HOME}/.ssh/id_rsa.pub
69 ${privatekey} %{HOME}/.ssh/id_rsa
73 # Prometheus polling interval and retries
74 ${prometheus_poll_retries} 15 times
75 ${prometheus_poll_timeout} 1 minute
77 # Prometheus metrics to retrieve
78 ${metric_name} osm_cpu_utilization
80 ${success_return_code} 0
84 Create Webhook Service VNF Descriptor
86 Create VNFD '%{PACKAGES_FOLDER}/${ws_vnfd_pkg}'
89 Create Webhook Service NS Descriptor
91 Create NSD '%{PACKAGES_FOLDER}/${ws_nsd_pkg}'
94 Instantiate Webhook Service Network Service
96 ${id}= Create Network Service ${ws_nsd_name} %{VIM_TARGET} ${ws_ns_name} ${ns_config} ${publickey}
97 Set Suite Variable ${ws_ns_id} ${id}
100 Get Webhook Service VNF IP Address
102 ${ip_addr}= Get Vnf Management Ip Address ${ws_ns_id} ${ws_vnf_member_index}
104 Set Suite Variable ${ws_vnf_ip_addr} ${ip_addr}
107 Start Webhook Service
109 Variable Should Exist ${privatekey} msg=SSH private key not available
110 Sleep 40 seconds Wait for SSH daemon to be up
111 ${stdout}= Execute Remote Command Check Rc Return Output ${ws_vnf_ip_addr} ${username} ${password} ${privatekey} while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; test; } | nc -l '${ws_port}'; done > '${ws_log_file}' 2>&1 &
114 Create VNF Descriptor
116 ${rc} ${stdout}= Run and Return RC and Output mkdir '%{PACKAGES_FOLDER}/${new_vnfd_pkg}' && WEBHOOK_URL="http://${ws_vnf_ip_addr}:${ws_port}" envsubst < '%{PACKAGES_FOLDER}/${vnfd_pkg}'/'${vnfd_file}' > '%{PACKAGES_FOLDER}/${new_vnfd_pkg}'/'${vnfd_file}'
118 Should Be Equal As Integers ${rc} ${success_return_code}
119 Create VNFD '%{PACKAGES_FOLDER}/${new_vnfd_pkg}'
124 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
127 Instantiate Network Service
129 ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
130 Set Suite Variable ${ns_id} ${id}
135 Variable Should Exist ${prometheus_poll_retries} msg=Metric polling retries is not available
136 Variable Should Exist ${prometheus_poll_timeout} msg=Metric polling timeout is not available
137 Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
138 Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
139 Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
140 ${metric_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_name}
141 Run Keyword If ${metric_value} <= 0 Fail msg=The metric '${metric_name}' value is '${metric_value}'
144 Check Alarms Were Received
146 Wait Until Keyword Succeeds 6 times 40 seconds Execute Remote Command Check Rc Return Output ${ws_vnf_ip_addr} ${username} ${password} ${privatekey} cat '${ws_log_file}' | grep '${ws_alarm_msg}' | grep '${ns_name}'
158 Delete NSD ${nsd_name}
161 Delete VNF Descriptor
164 Delete VNFD ${vnfd_name}
167 Delete Webhook Service NS Instance
170 Delete NS ${ws_ns_name}
173 Delete Webhook Service NS Descriptor
176 Delete NSD ${ws_nsd_name}
179 Delete Webhook Service VNF Descriptor
182 Delete VNFD ${ws_vnfd_name}
187 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
189 Run Keyword If Any Tests Failed Delete NS ${ns_name}
190 Run Keyword If Any Tests Failed Delete NSD ${nsd_name}
191 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
192 Run Keyword If Any Tests Failed Delete NS ${ws_ns_name}
193 Run Keyword If Any Tests Failed Delete NSD ${ws_nsd_name}
194 Run Keyword If Any Tests Failed Delete VNFD ${ws_vnfd_name}
195 Delete Temporary Descriptor Folder '%{PACKAGES_FOLDER}/${new_vnfd_pkg}'
198 Delete Temporary Descriptor Folder
199 [Documentation] Removes the temporary package folder created for the test
200 [Arguments] ${folder_name}
201 ${rc} ${stdout}= Run and Return RC and Output rm -rf '${folder_name}'