Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / sa_08-vnf_with_vnf_indicators_snmp.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-08] VNF with VNF-based indicators through SNMP.
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_08   cluster_k8s   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}   snmp_ee_vnf
40 ${VNFD_NAME}   snmp_ee-vnf
41 ${NSD_PKG}   snmp_ee_ns
42 ${NSD_NAME}   snmp_ee-ns
43
44 # NS instance name
45 ${NS_NAME}   sa_08-vnf_with_vnf_indicators_snmp_test
46
47 # Prometheus polling interval and retries
48 ${PROMETHEUS_POLL_RETRIES}   10 times
49 ${PROMETHEUS_POLL_TIMEOUT}   1 minute
50
51 # Prometheus metrics to retrieve
52 ${METRIC_1_NAME}   ifInOctets
53 ${METRIC_1_FILTER}   ifIndex=1
54 ${METRIC_2_NAME}   ifMtu
55 ${METRIC_2_FILTER}   ifIndex=2
56
57
58 *** Test Cases ***
59 Create VNF Descriptor
60     [Documentation]   Upload VNF package for the testsuite.
61     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
62
63 Create NS Descriptor
64     [Documentation]   Upload NS package for the testsuite.
65     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
66
67 Instantiate Network Service
68     [Documentation]   Instantiate the NS for the testsuite.
69     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${EMPTY}
70     Set Suite Variable   ${NS_ID}   ${id}
71
72 Get VNF SNMP Metrics
73     [Documentation]   Check that SNMP metrics from the VNF are stored in Prometheus.
74     Variable Should Exist   ${PROMETHEUS_HOST}   msg=Prometheus address is not available
75     Variable Should Exist   ${PROMETHEUS_PORT}   msg=Prometheus port is not available
76     Variable Should Exist   ${METRIC_1_NAME}   msg=Prometheus first metric name is not available
77     Variable Should Exist   ${METRIC_2_NAME}   msg=Prometheus second metric name is not available
78     ${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_1_FILTER}
79     IF   ${metric_1_value} <= 0   Fail   msg=The metric '${METRIC_1_NAME}' value is '${metric_1_value}'
80     ${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_2_FILTER}
81     IF   ${metric_2_value} <= 0   Fail   msg=The metric '${METRIC_2_NAME}' value is '${metric_2_value}'
82
83 Delete NS Instance
84     [Documentation]   Delete NS instance.
85     [Tags]   cleanup
86     Delete NS   ${NS_NAME}
87
88 Delete NS Descriptor
89     [Documentation]   Delete NS package from OSM.
90     [Tags]   cleanup
91     Delete NSD   ${NSD_NAME}
92
93 Delete VNF Descriptor
94     [Documentation]   Delete VNF package from OSM.
95     [Tags]   cleanup
96     Delete VNFD   ${VNFD_NAME}
97
98
99 *** Keywords ***
100 Suite Preparation
101     [Documentation]   Test Suite Preparation: Setting Prometheus Testsuite Variables
102     Set Testsuite Prometheus Variables
103
104 Suite Cleanup
105     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
106     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
107     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
108     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}