Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / testsuite / sa_01-vnf_with_vim_metrics.robot
1 *** 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 ***
16 Documentation   [SA-01] VNF with VIM-based metrics.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21
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
27
28 Test Tags   sa_01   cluster_sa   daily   regression
29
30 Suite Setup   Run Keyword And Ignore Error   Suite Preparation
31 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
32
33
34 *** Variables ***
35 # NS instantiation parameters
36 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
37
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
43
44 # NS instance name
45 ${NS_NAME}   sa_01-vnf_with_vim_metrics_test
46
47 # SSH keys and username to be used
48 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
49 ${PRIVATEKEY}   %{HOME}/.ssh/id_rsa
50
51 # Prometheus polling interval and retries
52 ${PROMETHEUS_POLL_RETRIES}   15 times
53 ${PROMETHEUS_POLL_TIMEOUT}   1 minute
54
55 # Prometheus metrics to retrieve
56 ${METRIC_1_NAME}   osm_cpu_utilization
57 ${METRIC_2_NAME}   osm_average_memory_utilization
58
59
60 *** Test Cases ***
61 Create VNF Descriptor
62     [Documentation]   Upload VNF package for the testsuite.
63     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
64
65 Create NS Descriptor
66     [Documentation]   Upload NS package for the testsuite.
67     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
68
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}
73
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}'
87
88 Delete NS Instance
89     [Documentation]   Delete NS instance.
90     [Tags]   cleanup
91     Delete NS   ${NS_NAME}
92
93 Delete NS Descriptor
94     [Documentation]   Delete NS package.
95     [Tags]   cleanup
96     Delete NSD   ${NSD_NAME}
97
98 Delete VNF Descriptor
99     [Documentation]   Delete VNF package.
100     [Tags]   cleanup
101     Delete VNFD   ${VNFD_NAME}
102
103
104 *** Keywords ***
105 Suite Preparation
106     [Documentation]   Test Suite Preparation: Setting Prometheus Testsuite Variables
107     Set Testsuite Prometheus Variables
108
109 Suite Cleanup
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}