blob: b9d7186b07c30a2b21de8d9967933aae2dc1a404 [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 Run Keyword If "${workflow}"=="DT" Current State Test All Onus omci-admin-lock
TorstenThieme20e16272022-07-13 06:51:18 +0000120 ... ELSE IF "${workflow}"=="TT" Current State Test All Onus tech-profile-config-delete-success
121 ... ELSE Current State Test All Onus tech-profile-config-delete-success
Andrea Campanella753510e2022-04-28 23:26:27 +0200122 #check all ports are disabled in ONOS
TorstenThieme0c8cc6f2022-02-16 13:48:21 +0000123 Wait for all ONU Ports in ONOS Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${unitag_sub}
124 Run Keyword If ${print2console} Log Enable ONUs. console=yes
125 Enable Onu Device
126 Run Keyword If ${print2console} Log Sanity Test after Enable ONUs. console=yes
127 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber}
128 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber}
129 ... ELSE Perform Sanity Test ${suppressaddsubscriber}
130 END
131 [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console}
132 ... AND Run Keyword If ${logging} Collect Logs
133 ... AND Stop Logging CheckMibAudit
134
135
136*** Keywords ***
137Setup Suite
138 [Documentation] Set up the test suite
139 Start Logging Setup or Teardown Setup-${SUITE NAME}
140 # set tech profiles
141 ${preload_tech_profile}= Set Variable If ${unitag_sub} and "${workflow}"=="TT" and not ${has_dataplane} True False
142 Set Suite Variable ${preload_tech_profile}
143 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-HSIA ${INFRA_NAMESPACE} 64
144 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-VoIP ${INFRA_NAMESPACE} 65
145 Run Keyword If ${preload_tech_profile} Set Tech Profile TT-multi-uni-MCAST-AdditionalBW-None ${INFRA_NAMESPACE} 66
146 Common Test Suite Setup
147 ${switch_type}= Get Variable Value ${web_power_switch.type}
148 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
149 # set ${kafka} depending on environment in case of port-forward is needed
150 ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output
151 ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}'
152 Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found
153 # start port forwarding if needed (when voltha runs in k8s)
154 ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process
155 ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} &
156 ... shell=true
157 Set Suite Variable ${portFwdHandle}
158 Sleep 5s
159 # open connection to read kafka bus
160 Wait Until Keyword Succeeds 3x 5s
161 ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0
162 # enable OLT(s) and bring up ONU(s)
163 Setup
164 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
165 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
166 ... ELSE Perform Sanity Test
167 Stop Logging Setup or Teardown Setup-${SUITE NAME}
168
169Teardown Suite
170 [Documentation] tear down the test suite
171 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
172 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
173 Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes
174 # close connection to kafka
175 kafka.Connection Close
176 # stop port forwarding if started
177 Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true
178 # call common suite teardown
179 utils.Teardown Suite
180 Close All ONOS SSH Connections
181 Set Suite Variable ${TechProfile} ${EMPTY}
182 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 64
183 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 65
184 Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 66
185
186Validate MIB Audits All ONUs
187 [Documentation] Validates MIB Audit Events per ONU
188 [Arguments] ${list_onu_device_id}
189 ${Kafka_Records}= kafka.Records Get voltha.events
190 ${RecordsLength}= Get Length ${Kafka_Records}
191 FOR ${Index} IN RANGE 0 ${RecordsLength}
192 ${metric}= Set Variable ${Kafka_Records[${Index}]}
193 ${message}= Get From Dictionary ${metric} message
194 ${event}= volthatools.Events Decode Event ${message} return_default=true
195 Continue For Loop If not 'device_event' in ${event}
196 ${event_name}= Get From Dictionary ${event['device_event']} device_event_name
197 Continue For Loop If "${event_name}" != "ONU_MIB_AUDIT_FAILURE_MDS"
198 ${resource_id}= Get From Dictionary ${event['device_event']} resource_id
199 Remove Values From List ${list_onu_device_id} ${resource_id}
200 END
201 Should Be Empty ${list_onu_device_id} Missing MIB Audits for ONUs ${list_onu_device_id}!
202
203Calculate Interval
204 [Documentation] Converts the passed value in seconds, adds percentage and return it w/o unit
205 ... Conversion to string is needed to remove float format!
206 [Arguments] ${val} ${percentage}=0.2 ${unit}=True
207 ${seconds}= Convert Time ${val}
208 ${seconds}= evaluate ${seconds}+${seconds}*0.2
209 ${seconds}= Convert To String ${seconds}
210 ${seconds}= Get Substring ${seconds} 0 -2
211 ${seconds}= Set Variable If ${unit} ${seconds}s ${seconds}
212 [return] ${seconds}