blob: c68a0c038fc46704507bc3abe5a5aa0e21c7bbd4 [file] [log] [blame]
TorstenThieme0c8cc6f2022-02-16 13:48:21 +00001# Copyright 2022 - 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 MIB audit
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!
23... For voltha-infra prefix kafka. is needed e.g.: --set kafka.externalAccess.enabled=true
24Suite 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 ../../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${INFRA_NAMESPACE} default
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 MIB audit interval
79# example: -v ONU_MIB_AUDIT_INTERVAL:50s
80${ONU_MIB_AUDIT_INTERVAL} 60s
81# MDS mitsmatches per ONU
82# example: -v MDS_MISMATCHES_PER_ONU:2
83${MDS_MISMATCHES_PER_ONU} 3
84# if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline!
85# example: -v pausebeforecleanup:True
86${pausebeforecleanup} False
87# if True some outputs to console are done during running tests e.g. long duration flow test
88# example: -v print2console:True
89${print2console} False
90${suppressaddsubscriber} True
91
92# flag to choose the subscriber provisioning command type in ONOS
93# TT often provision a single services for a subscriber (eg: hsia, voip, ...) one after the other.
94# if set to True, command used is "volt-add-subscriber-unitag"
95# if set to False, comand used is "volt-add-subscriber-access"
96${unitag_sub} False
97
98*** Test Cases ***
99Check Mib Audit
100 [Documentation] Validates the ONU Go adapter MIB audit
101 [Tags] functional CheckMibAudit
102 [Setup] Start Logging CheckMibAudit
103 kafka.Records Clear
104 ${interval}= Calculate Interval ${ONU_MIB_AUDIT_INTERVAL}
105 FOR ${I} IN RANGE 1 ${MDS_MISMATCHES_PER_ONU} + 1
106 Run Keyword If ${print2console} Log \r\nInvalidate MDS ${I} of ${MDS_MISMATCHES_PER_ONU}. console=yes
107 Set Wrong MDS Counter All ONUs ${NAMESPACE}
108 ${list_onu_device_id} Create List
109 Build ONU Device Id List ${list_onu_device_id}
110 Run Keyword If ${print2console} Log Check for device events that indicate a failed MDS check. console=yes
111 Wait Until Keyword Succeeds ${interval} 5s Validate MIB Audits All ONUs ${list_onu_device_id}
112 kafka.Records Clear
113 Run Keyword If ${print2console} Log Sanity Test after MIB Audit. console=yes
114 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber}
115 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber}
116 ... ELSE Perform Sanity Test ${suppressaddsubscriber}
117 Run Keyword If ${print2console} Log Disable ONUs. console=yes
118 Disable Onu Device
Andrea Campanella753510e2022-04-28 23:26:27 +0200119 ${alternativeonustates}= Create List omci-flows-deleted
120 Run Keyword If "${workflow}"=="DT" Current State Test All Onus omci-admin-lock
121 ... ELSE IF "${workflow}"=="TT" Current State Test All Onus omci-admin-lock
122 ... ELSE Current State Test All Onus omci-admin-lock alternativeonustate=${alternativeonustates}
123 #check all ports are disabled in ONOS
TorstenThieme0c8cc6f2022-02-16 13:48:21 +0000124 Wait for all ONU Ports in ONOS Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${unitag_sub}
125 Run Keyword If ${print2console} Log Enable ONUs. console=yes
126 Enable Onu Device
127 Run Keyword If ${print2console} Log Sanity Test after Enable ONUs. console=yes
128 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber}
129 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber}
130 ... ELSE Perform Sanity Test ${suppressaddsubscriber}
131 END
132 [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console}
133 ... AND Run Keyword If ${logging} Collect Logs
134 ... AND Stop Logging CheckMibAudit
135
136
137*** Keywords ***
138Setup Suite
139 [Documentation] Set up the test suite
140 Start Logging Setup or Teardown Setup-${SUITE NAME}
141 # set tech profiles
142 ${preload_tech_profile}= Set Variable If ${unitag_sub} and "${workflow}"=="TT" and not ${has_dataplane} True False
143 Set Suite Variable ${preload_tech_profile}
144 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-HSIA ${INFRA_NAMESPACE} 64
145 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-VoIP ${INFRA_NAMESPACE} 65
146 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-multi-uni-MCAST-AdditionalBW-None ${INFRA_NAMESPACE} 66
147 Common Test Suite Setup
148 ${switch_type}= Get Variable Value ${web_power_switch.type}
149 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
150 # set ${kafka} depending on environment in case of port-forward is needed
151 ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output
152 ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}'
153 Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found
154 # start port forwarding if needed (when voltha runs in k8s)
155 ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process
156 ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} &
157 ... shell=true
158 Set Suite Variable ${portFwdHandle}
159 Sleep 5s
160 # open connection to read kafka bus
161 Wait Until Keyword Succeeds 3x 5s
162 ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0
163 # enable OLT(s) and bring up ONU(s)
164 Setup
165 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
166 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
167 ... ELSE Perform Sanity Test
168 Stop Logging Setup or Teardown Setup-${SUITE NAME}
169
170Teardown Suite
171 [Documentation] tear down the test suite
172 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
173 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
174 Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes
175 # close connection to kafka
176 kafka.Connection Close
177 # stop port forwarding if started
178 Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true
179 # call common suite teardown
180 utils.Teardown Suite
181 Close All ONOS SSH Connections
182 Set Suite Variable ${TechProfile} ${EMPTY}
183 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 64
184 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 65
185 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 66
186
187Validate MIB Audits All ONUs
188 [Documentation] Validates MIB Audit Events per ONU
189 [Arguments] ${list_onu_device_id}
190 ${Kafka_Records}= kafka.Records Get voltha.events
191 ${RecordsLength}= Get Length ${Kafka_Records}
192 FOR ${Index} IN RANGE 0 ${RecordsLength}
193 ${metric}= Set Variable ${Kafka_Records[${Index}]}
194 ${message}= Get From Dictionary ${metric} message
195 ${event}= volthatools.Events Decode Event ${message} return_default=true
196 Continue For Loop If not 'device_event' in ${event}
197 ${event_name}= Get From Dictionary ${event['device_event']} device_event_name
198 Continue For Loop If "${event_name}" != "ONU_MIB_AUDIT_FAILURE_MDS"
199 ${resource_id}= Get From Dictionary ${event['device_event']} resource_id
200 Remove Values From List ${list_onu_device_id} ${resource_id}
201 END
202 Should Be Empty ${list_onu_device_id} Missing MIB Audits for ONUs ${list_onu_device_id}!
203
204Calculate Interval
205 [Documentation] Converts the passed value in seconds, adds percentage and return it w/o unit
206 ... Conversion to string is needed to remove float format!
207 [Arguments] ${val} ${percentage}=0.2 ${unit}=True
208 ${seconds}= Convert Time ${val}
209 ${seconds}= evaluate ${seconds}+${seconds}*0.2
210 ${seconds}= Convert To String ${seconds}
211 ${seconds}= Get Substring ${seconds} 0 -2
212 ${seconds}= Set Variable If ${unit} ${seconds}s ${seconds}
213 [return] ${seconds}