blob: 17b810bb0bb2c0958e7e8d635d93876f68166195 [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!
23Suite Setup Setup Suite
24Suite Teardown Teardown Suite
25Test Setup Setup
26Test Teardown Teardown
27Library Collections
28Library String
29Library OperatingSystem
30Library XML
31Library RequestsLibrary
32Library ../../libraries/DependencyLibrary.py
33Resource ../../libraries/onos.robot
34Resource ../../libraries/voltctl.robot
35Resource ../../libraries/voltha.robot
36Resource ../../libraries/utils.robot
37Resource ../../libraries/k8s.robot
38Resource ../../libraries/onu_utilities.robot
39Resource ../../libraries/bbsim.robot
40Resource ../../libraries/pm_utilities.robot
41Resource ../../variables/variables.robot
42
43Library kafka_robot.KafkaClient log_level=DEBUG WITH NAME kafka
44Library grpc_robot.VolthaTools WITH NAME volthatools
45
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
156 Wait for Ports in ONOS for all OLTs ${onos_ssh_connection} 0 BBSM
157 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
165 Wait for Ports in ONOS for all OLTs ${onos_ssh_connection} ${num_all_onus} BBSM determine_number=True
166 # 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
185 ${onos_ssh_connection} Open ONOS SSH Connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
186 Set Suite Variable ${onos_ssh_connection}
187 ${switch_type}= Get Variable Value ${web_power_switch.type}
188 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
TorstenThiemefc26b3b2021-05-12 14:42:13 +0000189 # todo: set ${kafka} depending on environment!!!
190# ${kafka}= Set Variable kafka-0-external
191 ${kafka}= Set Variable voltha-infra-kafka-0-external
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