blob: 5012b83bbcfd8dbea655cd49a4d299fe7784bb1a [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
45Library grpc_robot.VolthaTools WITH NAME volthatools
46
47
48*** Variables ***
49${namespace} voltha
50${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
157 Wait for Ports in ONOS for all OLTs ${onos_ssh_connection} 0 BBSM
158 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
166 Wait for Ports in ONOS for all OLTs ${onos_ssh_connection} ${num_all_onus} BBSM determine_number=True
167 # 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
186 ${onos_ssh_connection} Open ONOS SSH Connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
187 Set Suite Variable ${onos_ssh_connection}
188 ${switch_type}= Get Variable Value ${web_power_switch.type}
189 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
TorstenThiemed81c1042021-05-27 14:19:49 +0000190 # set ${kafka} depending on environment in case of port-forward is needed
191 ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output
192 ... kubectl get svc -n default | grep kafka-0-external | awk '{print $1}'
193 Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found
TorstenThiemeff9c9142021-04-08 07:21:34 +0000194 # start port forwarding if needed (when voltha runs in k8s)
195 ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process
TorstenThiemefc26b3b2021-05-12 14:42:13 +0000196 ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} &
TorstenThiemeff9c9142021-04-08 07:21:34 +0000197 ... shell=true
198 Set Suite Variable ${portFwdHandle}
199 Sleep 5s
200 # open connection to read kafka bus
201 Wait Until Keyword Succeeds 3x 5s
202 ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0
203 # enable OLT(s) and bring up ONU(s)
204 Setup
205 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
206 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
207 ... ELSE Perform Sanity Test
208 # prepare pm data matrix for validation
209 ${METRIC_DICT}= Create Metric Dictionary
210 Set Suite Variable ${METRIC_DICT}
211
212Teardown Suite
213 [Documentation] tear down the test suite
214 # close connection to kafka
215 kafka.Connection Close
216 # stop port forwarding if started
217 Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true
218 # call common suite teardown
219 utils.Teardown Suite
220 Close All ONOS SSH Connections