blob: b3d31517e70ebbcac76c8e2ebeaf010b0d342e55 [file] [log] [blame]
TorstenThiemeff9c9142021-04-08 07:21:34 +00001# Copyright 2021 - present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15*** Settings ***
16Documentation Test of open ONU go adapter PM data
17... in case of kafka pod runs in k8s cluster - kafka has to deploy with following EXTRA_HELM_FLAGS
18... --set externalAccess.enabled=true,
19... --set externalAccess.service.type=NodePort,
20... --set externalAccess.service.nodePorts[0]=${KAFKA_PORT},
21... --set externalAccess.service.domain=${KAFKA_IP}
22... with e.g. service.domain=10.0.02.15 or 127.0.0.1 and service.nodePorts[0]=30201!
TorstenThiemed81c1042021-05-27 14:19:49 +000023... For voltha-infra prefix kafka. is needed e.g.: --set kafka.externalAccess.enabled=true
TorstenThiemeff9c9142021-04-08 07:21:34 +000024Suite Setup Setup Suite
25Suite Teardown Teardown Suite
26Test Setup Setup
27Test Teardown Teardown
28Library Collections
29Library String
30Library OperatingSystem
31Library XML
32Library RequestsLibrary
33Library ../../libraries/DependencyLibrary.py
34Resource ../../libraries/onos.robot
35Resource ../../libraries/voltctl.robot
36Resource ../../libraries/voltha.robot
37Resource ../../libraries/utils.robot
38Resource ../../libraries/k8s.robot
39Resource ../../libraries/onu_utilities.robot
40Resource ../../libraries/bbsim.robot
41Resource ../../libraries/pm_utilities.robot
42Resource ../../variables/variables.robot
43
44Library kafka_robot.KafkaClient log_level=DEBUG WITH NAME kafka
TorstenThiemeff9c9142021-04-08 07:21:34 +000045
46
47*** Variables ***
Hardik Windlass4288c6a2021-09-28 07:22:06 +000048${NAMESPACE} voltha
49${INFRA_NAMESPACE} default
TorstenThiemeff9c9142021-04-08 07:21:34 +000050${timeout} 60s
51${of_id} 0
52${logical_id} 0
53${has_dataplane} True
54${external_libs} True
55${teardown_device} True
56${scripts} ../../scripts
57# Per-test logging on failure is turned off by default; set this variable to enable
58${container_log_dir} ${None}
59
60# logging flag to enable Collect Logs, can be passed via the command line too
61# example: -v logging:True
62${logging} False
63# determines the environment workflow: DT, TT or ATT (default)
64# example: -v workflow:DT
65${workflow} ATT
66# when voltha is running in k8s port forwarding is needed
67# example: -v PORT_FORWARDING:False
68${PORT_FORWARDING} True
69# kafka ip e.g. ip of master host where k8s is running
70# example: -v KAFKA_IP:10.0.2.15
71${KAFKA_IP} 127.0.0.1
72# kafka port: port of kafka nodeport
73# example: -v KAFKA_PORT:30201
74${KAFKA_PORT} 30201
75# kafka service port: service port of kafka nodeport
76# example: -v KAFKA_SVC_PORT:9094
77${KAFKA_SVC_PORT} 9094
78# onu pm data default interval
79# example: -v ONU_DEFAULT_INTERVAL:50s
80${ONU_DEFAULT_INTERVAL} 300s
81# onu pm data group PON_Optical interval
82# example: -v ONU_PON_OPTICAL_INTERVAL:50s
83${ONU_PON_OPTICAL_INTERVAL} 35s
84# onu pm data group UNI_Status interval
85# example: -v ONU_UNI_STATUS_INTERVAL:50s
86${ONU_UNI_STATUS_INTERVAL} 20s
87
88*** Test Cases ***
89Check Default Metrics All ONUs
90 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with dafault values
91 [Tags] functional CheckDefaultMetricsAllOnus
92 [Setup] Start Logging CheckDefaultMetricsAllOnus
93 ${collect_interval}= Determine Collection Interval
94 Collect and Validate PM Data ${collect_interval}
95 [Teardown] Run Keywords Clean Metric Dictionary
96 ... AND Run Keyword If ${logging} Collect Logs
97 ... AND Stop Logging CheckDefaultMetricsAllOnus
98
99Check User Onu Metrics
100 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with user values
101 ... Currently only the intvals of metric groups UNI_Status and PON_Optical will be set to user values.
102 [Tags] functional CheckUserOnuMetrics
103 [Setup] Start Logging CheckUserOnuMetrics
104 # set user values for intervals
105 Set Group Interval All Onu UNI_Status ${ONU_UNI_STATUS_INTERVAL}
106 Set Group Interval All Onu PON_Optical ${ONU_PON_OPTICAL_INTERVAL}
107 ${collect_interval}= Determine Collection Interval user=True
108 # activate user interval values
109 Activate And Validate Interval All Onu user=True
110 Collect and Validate PM Data ${collect_interval} user=True
111 # (re-)activate default interval values
112 Set Group Interval All Onu UNI_Status -1
113 Set Group Interval All Onu PON_Optical -1
114 Activate And Validate Interval All Onu
115 [Teardown] Run Keywords Clean Metric Dictionary
116 ... AND Run Keyword If ${logging} Collect Logs
117 ... AND Stop Logging CheckUserOnuMetrics
118
119Check User Onu Metrics Disabled Device
120 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with user values for disabled device
121 ... Currently only the intvals of metric groups UNI_Status will be set to user values and validated.
122 ... First enable status will be validated, then all devices will be disabled and status will be validated.
123 [Tags] functional CheckUserOnuMetricsDisabledDevice
124 [Setup] Start Logging CheckUserOnuMetricsDisabledDevice
125 # set user values for intervals
126 Set Group Interval All Onu UNI_Status ${ONU_UNI_STATUS_INTERVAL}
127 ${collect_interval}= Determine Collection Interval user=True
128 # activate user interval values
129 Activate And Validate Interval All Onu user=True
130 # read and store currents validation data
131 ${group}= Set Variable UNI_Status
132 ${oper_state}= Set Variable oper_status
133 ${admin_state}= Set Variable uni_admin_state
134 ${prev_validation_data_oper_state}= Get Validation Operation All Onu ${group} ${oper_state}
135 ${prev_validation_data_admin_state}= Get Validation Operation All Onu ${group} ${admin_state}
136 # change the validation data for oper_status and uni_admin_state of metric group UNI_Status
137 ${enable}= Set Variable 0
138 ${disable}= Set Variable 1
139 ${enabled_check}= Create Dictionary operator=${eq} operand=${enable}
140 ${disabled_check}= Create Dictionary operator=${eq} operand=${disable}
141 ${ValidationEnabled}= Create Dictionary first=${enabled_check} successor=${enabled_check}
142 ${ValidationDisabled}= Create Dictionary first=${disabled_check} successor=${disabled_check}
143 # validate enabled status
144 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationEnabled}
145 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationEnabled}
146 Collect and Validate PM Data ${collect_interval} user=True
147 Clean Metric Dictionary
148 # validate disabled status
149 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationDisabled}
150 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationDisabled}
151 # disable (all) onu devices
152 Disable Onu Device
153 ${alternativeonustates}= Create List omci-flows-deleted tech-profile-config-delete-success
154 Current State Test All Onus omci-admin-lock alternativeonustate=${alternativeonustates}
155 Log Ports
156 #check no port is enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000157 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM
TorstenThiemeff9c9142021-04-08 07:21:34 +0000158 Collect and Validate PM Data ${collect_interval} user=True
159 Clean Metric Dictionary
160 # enable (all) onu devices
161 Enable Onu Device
162 ${alternativeonustates}= Create List onu-reenabled
163 Current State Test All Onus omci-flows-pushed alternativeonustate=${alternativeonustates}
164 Log Ports onlyenabled=True
165 #check that all the UNI ports show up in ONOS again
TorstenThieme731a7592021-07-01 14:26:54 +0000166 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${num_all_onus} BBSM determine_number=True
TorstenThiemeff9c9142021-04-08 07:21:34 +0000167 # validate enabled status (again)
168 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationEnabled}
169 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationEnabled}
170 Collect and Validate PM Data ${collect_interval} user=True
171 # (re-)set previous validation data
172 Set Validation Operation Passed Onu ${group} ${oper_state} ${prev_validation_data_oper_state}
173 Set Validation Operation Passed Onu ${group} ${admin_state} ${prev_validation_data_admin_state}
174 # (re-)activate default interval values
175 Set Group Interval All Onu UNI_Status -1
176 Activate And Validate Interval All Onu
177 [Teardown] Run Keywords Clean Metric Dictionary
178 ... AND Run Keyword If ${logging} Collect Logs
179 ... AND Stop Logging CheckUserOnuMetricsDisabledDevice
180
181
182*** Keywords ***
183Setup Suite
184 [Documentation] Set up the test suite
185 Common Test Suite Setup
TorstenThiemeff9c9142021-04-08 07:21:34 +0000186 ${switch_type}= Get Variable Value ${web_power_switch.type}
187 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
TorstenThiemed81c1042021-05-27 14:19:49 +0000188 # set ${kafka} depending on environment in case of port-forward is needed
189 ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output
190 ... kubectl get svc -n default | grep kafka-0-external | awk '{print $1}'
191 Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found
TorstenThiemeff9c9142021-04-08 07:21:34 +0000192 # start port forwarding if needed (when voltha runs in k8s)
193 ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process
TorstenThiemefc26b3b2021-05-12 14:42:13 +0000194 ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} &
TorstenThiemeff9c9142021-04-08 07:21:34 +0000195 ... shell=true
196 Set Suite Variable ${portFwdHandle}
197 Sleep 5s
198 # open connection to read kafka bus
199 Wait Until Keyword Succeeds 3x 5s
200 ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0
201 # enable OLT(s) and bring up ONU(s)
202 Setup
203 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
204 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
205 ... ELSE Perform Sanity Test
206 # prepare pm data matrix for validation
207 ${METRIC_DICT}= Create Metric Dictionary
208 Set Suite Variable ${METRIC_DICT}
209
210Teardown Suite
211 [Documentation] tear down the test suite
212 # close connection to kafka
213 kafka.Connection Close
214 # stop port forwarding if started
215 Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true
216 # call common suite teardown
217 utils.Teardown Suite
218 Close All ONOS SSH Connections