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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation [SA-01] VNF with VIM-based metrics.
18 Library OperatingSystem
22 Resource ../lib/vnfd_lib.resource
23 Resource ../lib/nsd_lib.resource
24 Resource ../lib/ns_lib.resource
25 Resource ../lib/ssh_lib.resource
26 Resource ../lib/prometheus_lib.resource
28 Test Tags sa_01 cluster_sa daily regression
30 Suite Setup Run Keyword And Ignore Error Suite Preparation
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} hackfest_basic_metrics_vnf
40 ${VNFD_NAME} hackfest_basic_metrics-vnf
41 ${NSD_PKG} hackfest_basic_metrics_ns
42 ${NSD_NAME} hackfest_basic-ns-metrics
45 ${NS_NAME} sa_01-vnf_with_vim_metrics_test
47 # SSH keys and username to be used
48 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
49 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
51 # Prometheus polling interval and retries
52 ${PROMETHEUS_POLL_RETRIES} 15 times
53 ${PROMETHEUS_POLL_TIMEOUT} 1 minute
55 # Prometheus metrics to retrieve
56 ${METRIC_1_NAME} osm_cpu_utilization
57 ${METRIC_2_NAME} osm_average_memory_utilization
62 [Documentation] Upload VNF package for the testsuite.
63 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
66 [Documentation] Upload NS package for the testsuite.
67 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
69 Instantiate Network Service
70 [Documentation] Instantiate NS for the testsuite.
71 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG} ${PUBLICKEY}
72 Set Suite Variable ${NS_ID} ${id}
74 Get VNF VIM-based Metrics
75 [Documentation] Check that the expected metrics are present in Prometheus (pushed from SA modules).
76 Variable Should Exist ${PROMETHEUS_POLL_RETRIES} msg=Metric polling retries is not available
77 Variable Should Exist ${PROMETHEUS_POLL_TIMEOUT} msg=Metric polling timeout is not available
78 Variable Should Exist ${PROMETHEUS_HOST} msg=Prometheus address is not available
79 Variable Should Exist ${PROMETHEUS_PORT} msg=Prometheus port is not available
80 Variable Should Exist ${METRIC_1_NAME} msg=Prometheus first metric name is not available
81 Variable Should Exist ${METRIC_2_NAME} msg=Prometheus second metric name is not available
82 ${metric_filter}= Set Variable ns_id=${NS_ID}
83 ${metric_1_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_1_NAME} ${metric_filter}
84 IF ${metric_1_value} <= 0 Fail msg=The metric '${METRIC_1_NAME}' value is '${metric_1_value}'
85 ${metric_2_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_2_NAME} ${metric_filter}
86 IF ${metric_2_value} <= 0 Fail msg=The metric '${METRIC_2_NAME}' value is '${metric_2_value}'
89 [Documentation] Delete NS instance.
94 [Documentation] Delete NS package.
96 Delete NSD ${NSD_NAME}
99 [Documentation] Delete VNF package.
101 Delete VNFD ${VNFD_NAME}
106 [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables
107 Set Testsuite Prometheus Variables
110 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
111 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
112 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
113 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}