blob: 4346925081da54e4d6cd0174c5490b8658ce38ba [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 ***
48${namespace} voltha
49${timeout} 60s
50${of_id} 0
51${logical_id} 0
52${has_dataplane} True
53${external_libs} True
54${teardown_device} True
55${scripts} ../../scripts
56# Per-test logging on failure is turned off by default; set this variable to enable
57${container_log_dir} ${None}
58
59# logging flag to enable Collect Logs, can be passed via the command line too
60# example: -v logging:True
61${logging} False
62# determines the environment workflow: DT, TT or ATT (default)
63# example: -v workflow:DT
64${workflow} ATT
65# when voltha is running in k8s port forwarding is needed
66# example: -v PORT_FORWARDING:False
67${PORT_FORWARDING} True
68# kafka ip e.g. ip of master host where k8s is running
69# example: -v KAFKA_IP:10.0.2.15
70${KAFKA_IP} 127.0.0.1
71# kafka port: port of kafka nodeport
72# example: -v KAFKA_PORT:30201
73${KAFKA_PORT} 30201
74# kafka service port: service port of kafka nodeport
75# example: -v KAFKA_SVC_PORT:9094
76${KAFKA_SVC_PORT} 9094
77# onu pm data default interval
78# example: -v ONU_DEFAULT_INTERVAL:50s
79${ONU_DEFAULT_INTERVAL} 300s
80# onu pm data group PON_Optical interval
81# example: -v ONU_PON_OPTICAL_INTERVAL:50s
82${ONU_PON_OPTICAL_INTERVAL} 35s
83# onu pm data group UNI_Status interval
84# example: -v ONU_UNI_STATUS_INTERVAL:50s
85${ONU_UNI_STATUS_INTERVAL} 20s
86
87*** Test Cases ***
88Check Default Metrics All ONUs
89 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with dafault values
90 [Tags] functional CheckDefaultMetricsAllOnus
91 [Setup] Start Logging CheckDefaultMetricsAllOnus
92 ${collect_interval}= Determine Collection Interval
93 Collect and Validate PM Data ${collect_interval}
94 [Teardown] Run Keywords Clean Metric Dictionary
95 ... AND Run Keyword If ${logging} Collect Logs
96 ... AND Stop Logging CheckDefaultMetricsAllOnus
97
98Check User Onu Metrics
99 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with user values
100 ... Currently only the intvals of metric groups UNI_Status and PON_Optical will be set to user values.
101 [Tags] functional CheckUserOnuMetrics
102 [Setup] Start Logging CheckUserOnuMetrics
103 # set user values for intervals
104 Set Group Interval All Onu UNI_Status ${ONU_UNI_STATUS_INTERVAL}
105 Set Group Interval All Onu PON_Optical ${ONU_PON_OPTICAL_INTERVAL}
106 ${collect_interval}= Determine Collection Interval user=True
107 # activate user interval values
108 Activate And Validate Interval All Onu user=True
109 Collect and Validate PM Data ${collect_interval} user=True
110 # (re-)activate default interval values
111 Set Group Interval All Onu UNI_Status -1
112 Set Group Interval All Onu PON_Optical -1
113 Activate And Validate Interval All Onu
114 [Teardown] Run Keywords Clean Metric Dictionary
115 ... AND Run Keyword If ${logging} Collect Logs
116 ... AND Stop Logging CheckUserOnuMetrics
117
118Check User Onu Metrics Disabled Device
119 [Documentation] Validates the ONU Go adapter pm date resp. Metrics with user values for disabled device
120 ... Currently only the intvals of metric groups UNI_Status will be set to user values and validated.
121 ... First enable status will be validated, then all devices will be disabled and status will be validated.
122 [Tags] functional CheckUserOnuMetricsDisabledDevice
123 [Setup] Start Logging CheckUserOnuMetricsDisabledDevice
124 # set user values for intervals
125 Set Group Interval All Onu UNI_Status ${ONU_UNI_STATUS_INTERVAL}
126 ${collect_interval}= Determine Collection Interval user=True
127 # activate user interval values
128 Activate And Validate Interval All Onu user=True
129 # read and store currents validation data
130 ${group}= Set Variable UNI_Status
131 ${oper_state}= Set Variable oper_status
132 ${admin_state}= Set Variable uni_admin_state
133 ${prev_validation_data_oper_state}= Get Validation Operation All Onu ${group} ${oper_state}
134 ${prev_validation_data_admin_state}= Get Validation Operation All Onu ${group} ${admin_state}
135 # change the validation data for oper_status and uni_admin_state of metric group UNI_Status
136 ${enable}= Set Variable 0
137 ${disable}= Set Variable 1
138 ${enabled_check}= Create Dictionary operator=${eq} operand=${enable}
139 ${disabled_check}= Create Dictionary operator=${eq} operand=${disable}
140 ${ValidationEnabled}= Create Dictionary first=${enabled_check} successor=${enabled_check}
141 ${ValidationDisabled}= Create Dictionary first=${disabled_check} successor=${disabled_check}
142 # validate enabled status
143 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationEnabled}
144 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationEnabled}
145 Collect and Validate PM Data ${collect_interval} user=True
146 Clean Metric Dictionary
147 # validate disabled status
148 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationDisabled}
149 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationDisabled}
150 # disable (all) onu devices
151 Disable Onu Device
152 ${alternativeonustates}= Create List omci-flows-deleted tech-profile-config-delete-success
153 Current State Test All Onus omci-admin-lock alternativeonustate=${alternativeonustates}
154 Log Ports
155 #check no port is enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000156 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM
TorstenThiemeff9c9142021-04-08 07:21:34 +0000157 Collect and Validate PM Data ${collect_interval} user=True
158 Clean Metric Dictionary
159 # enable (all) onu devices
160 Enable Onu Device
161 ${alternativeonustates}= Create List onu-reenabled
162 Current State Test All Onus omci-flows-pushed alternativeonustate=${alternativeonustates}
163 Log Ports onlyenabled=True
164 #check that all the UNI ports show up in ONOS again
TorstenThieme731a7592021-07-01 14:26:54 +0000165 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 +0000166 # validate enabled status (again)
167 Set Validation Operation All Onu ${group} ${oper_state} ${ValidationEnabled}
168 Set Validation Operation All Onu ${group} ${admin_state} ${ValidationEnabled}
169 Collect and Validate PM Data ${collect_interval} user=True
170 # (re-)set previous validation data
171 Set Validation Operation Passed Onu ${group} ${oper_state} ${prev_validation_data_oper_state}
172 Set Validation Operation Passed Onu ${group} ${admin_state} ${prev_validation_data_admin_state}
173 # (re-)activate default interval values
174 Set Group Interval All Onu UNI_Status -1
175 Activate And Validate Interval All Onu
176 [Teardown] Run Keywords Clean Metric Dictionary
177 ... AND Run Keyword If ${logging} Collect Logs
178 ... AND Stop Logging CheckUserOnuMetricsDisabledDevice
179
180
181*** Keywords ***
182Setup Suite
183 [Documentation] Set up the test suite
184 Common Test Suite Setup
TorstenThiemeff9c9142021-04-08 07:21:34 +0000185 ${switch_type}= Get Variable Value ${web_power_switch.type}
186 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
TorstenThiemed81c1042021-05-27 14:19:49 +0000187 # set ${kafka} depending on environment in case of port-forward is needed
188 ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output
189 ... kubectl get svc -n default | grep kafka-0-external | awk '{print $1}'
190 Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found
TorstenThiemeff9c9142021-04-08 07:21:34 +0000191 # start port forwarding if needed (when voltha runs in k8s)
192 ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process
TorstenThiemefc26b3b2021-05-12 14:42:13 +0000193 ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} &
TorstenThiemeff9c9142021-04-08 07:21:34 +0000194 ... shell=true
195 Set Suite Variable ${portFwdHandle}
196 Sleep 5s
197 # open connection to read kafka bus
198 Wait Until Keyword Succeeds 3x 5s
199 ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0
200 # enable OLT(s) and bring up ONU(s)
201 Setup
202 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
203 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
204 ... ELSE Perform Sanity Test
205 # prepare pm data matrix for validation
206 ${METRIC_DICT}= Create Metric Dictionary
207 Set Suite Variable ${METRIC_DICT}
208
209Teardown Suite
210 [Documentation] tear down the test suite
211 # close connection to kafka
212 kafka.Connection Close
213 # stop port forwarding if started
214 Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true
215 # call common suite teardown
216 utils.Teardown Suite
217 Close All ONOS SSH Connections