blob: 2f68fe6b52a478f40ae06941b03751b3d2703792 [file] [log] [blame]
Joey Armstrong9fadcbe2024-01-17 19:00:37 -05001# Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
uwe ottrembka504ca3e2020-11-23 12:02:20 +01002#
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 Library for testing dmi interface (hw_management_service.proto)
17Library Process
18Library grpc_robot.Dmi WITH NAME dmi1
19Library grpc_robot.Collections WITH NAME tools
20Library kafka_robot.KafkaClient WITH NAME kafka
21Library Collections
22Library BuiltIn
23Library ../../libraries/utility.py WITH NAME utility
24Resource ../../libraries/dmi-basics.robot
25Variables ../../variables/variables.py
26Suite Setup Suite Setup
27Suite Teardown Suite Teardown
28
29*** Variables ***
30${DEVICEMANAGER_IP} ${GIVEN_DM_IP}
31${DEVICEMANAGER_PORT} ${GIVEN_DM_PORT}
32${OLT_IP} ${GIVEN_OLT_IP}
Hardik Windlass184fc222022-02-08 13:09:32 +000033${OLT_NAME} ${GIVEN_OLT_NAME}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010034
Hardik Windlasse01d3af2022-02-11 06:19:07 +000035${has_dataplane} True
36
uwe ottrembka504ca3e2020-11-23 12:02:20 +010037*** Test Cases ***
38Start and Stop Managing Device In Device Manager
39 [Documentation] add/remove device in device manager (testcase is done by Suite Setup and Suite Teardown)
40 [Tags] sanityDMI functionalDMI EnableOltDMI
41 # this tescase exist, to have the possiblity to check only the Start-/Stop-ManagingDevice
42 # can be run via adding parameter ("-t add and remove device in device manager") to the robot call!
43 No Operation
44
45Get Inventory Data
46 [Documentation] get physical inventory data from OLT
47 [Tags] functionalDMI GetInventoryDataDMI
48 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
49 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
50 Check Dmi Status ${inventory}[0] OK_STATUS
51 FOR ${component} IN @{dm_components}
52 Log ${component}
53 Check Physical Inventory ${inventory} ${component}
54 END
55
Hardik Windlass74b7c842022-02-17 09:11:13 +000056Get Set Configurable Component Inventory Info
uwe ottrembka504ca3e2020-11-23 12:02:20 +010057 [Documentation] get physical component info of all hw in given yaml file
Hardik Windlass74b7c842022-02-17 09:11:13 +000058 [Tags] functionalDMI GetSetConfigurableComponentInventoryInfoDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010059 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
60 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
61 Check Dmi Status ${inventory}[0] OK_STATUS
62 FOR ${component} IN @{dm_components}
63 Log ${component}
64 ${component_name}= Convert To String ${component['name']}
65 ${component_uuid}= Get Component Uuid From Inventory ${inventory} ${component_name}
TorstenThiemef8f9a802020-12-16 15:25:25 +000066 ${hwComInfoReq}= Create Dictionary device_uuid=${suite_device_uuid} component_uuid=${component_uuid}
67 Set To Dictionary ${hwComInfoReq} component_name=${component_name}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010068 ${hwComInfoRes}= dmi1.Hw Management Service Get Hw Component Info ${hwComInfoReq}
69 ${hwComInfoRes}= Get From List ${hwComInfoRes} 0
70 Check Dmi Status ${hwComInfoRes} OK_STATUS
71 ${res_component}= Get From Dictionary ${hwComInfoRes} component
72 ${value_name}= Get From Dictionary ${res_component} name
73 Should be Equal ${value_name} ${component_name}
Hardik Windlass74b7c842022-02-17 09:11:13 +000074 # Try setting 'name' field
75 # (for BBSim the set api is not implemented)
76 # (for Physical Pod 'modifying component names is not supported')
77 ${set_name_status}= Set Variable If ${has_dataplane} ERROR_STATUS UNIMPLEMENTED
78 Set Component Inventory Info
79 ... ${suite_device_uuid} ${component_uuid} ${component_name} name new-value ${set_name_status}
80 # Try setting 'alias' (any, other than name) field (for BBSim the set api is not implemented)
81 ${set_alias_status}= Set Variable If ${has_dataplane} OK_STATUS UNIMPLEMENTED
82 Set Component Inventory Info
83 ... ${suite_device_uuid} ${component_uuid} ${component_name} alias ${component_name} ${set_alias_status}
84 # Reset alias field
85 Set Component Inventory Info
86 ... ${suite_device_uuid} ${component_uuid} ${component_name} alias ${None} ${set_alias_status}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010087 END
88
89Get Loggable Entities
90 [Documentation] get the loggable entities of the device
TorstenThiemef8f9a802020-12-16 15:25:25 +000091 [Tags] functionalDMI GetLoggableEntitiesDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010092 ${loggable_entities}= Loggable Entities dmi1 ${suite_device_uuid}
93 ${size_loggable_entities}= Get Length ${loggable_entities}
94 Should Be True ${size_loggable_entities} > 5
95
96Set Get Logging Endpoint
97 [Documentation] set/get the loggable endpoint of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +000098 [Tags] functionalDMI SetGetLoggingEndpointDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010099 ${defined_endpoint}= Set Variable 127.0.0.1
100 ${defined_protocol}= Set Variable udp
101 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
102 # now the new logging endpoint and protocol should be set!
103 ${uuid}= Evaluate {'uuid':${suite_device_uuid}}
104 ${log_endpoint}= dmi1.Hw Management Service Get Logging Endpoint ${uuid}
105 Check Dmi Status ${log_endpoint} OK_STATUS
106 ${get_endpoint}= Get From Dictionary ${log_endpoint} logging_endpoint
107 ${get_protocol}= Get From Dictionary ${log_endpoint} logging_protocol
108 Should Be Equal ${get_endpoint} ${defined_endpoint}
109 Should Be Equal ${get_protocol} ${defined_protocol}
110 # remove logging endpoint
111 ${defined_endpoint}= Set Variable
Hardik Windlasse01d3af2022-02-11 06:19:07 +0000112 ${defined_protocol}= Set Variable
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100113 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
114
115Set Get LogLevel
116 [Documentation] set and get the log level of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +0000117 [Tags] functionalDMI SetGetLogLevelDMI skipped bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100118 ${loggable_entities}= Get X Loggable Entities dmi1 ${suite_device_uuid} 2
119 ${size}= GetLength ${loggable_entities}
120 Should Be True ${size} >= 2
121 # set new loglevel
122 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} ERROR
123 # get the loglevel
124 ${log_list}= Create List
125 ${entity}= Set Variable ${loggable_entities}[0][entities]
126 FOR ${log_entity} IN @{entity}
127 Append To List ${log_list} ${log_entity}
128 END
129 ${entity}= Set Variable ${loggable_entities}[1][entities]
130 FOR ${log_entity} IN @{entity}
131 Append To List ${log_list} ${log_entity}
132 END
133 ${loglvl_request}= Evaluate {'device_uuid':${suite_device_uuid}, 'entities':${log_list}}
134 ${response}= dmi1.Hw Management Service Get Log Level ${loglvl_request}
135 Check Dmi Status ${response} OK_STATUS
136 FOR ${counter} IN RANGE 0 2
137 Should Be True '${response}[logLevels][${counter}][logLevel]' == 'ERROR'
138 END
139 # set loglevel back to default
140 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} WARN
141
142*** Keywords ***
143Suite Setup
144 [Documentation] start a managed device in the device manager
145 dmi1.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT}
Hardik Windlass184fc222022-02-08 13:09:32 +0000146 ${suite_device_uuid}= Start Managing Device dmi1 ${OLT_IP} ${OLT_NAME}
147 ${suite_device_name}= Evaluate {'name':'${OLT_NAME}'}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100148 Set Suite Variable ${suite_device_uuid}
149 Set Suite Variable ${suite_device_name}
150
151Suite Teardown
152 [Documentation] stop a managed device in device manager
Hardik Windlass184fc222022-02-08 13:09:32 +0000153 Stop Managing Device dmi1 ${OLT_NAME}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100154 dmi1.Connection Close
155 Search For Managed Devices And Stop Managing It dmi1
156
157Check Physical Inventory
158 [Documentation] This keyword checks the passed inventory data
159 [Arguments] ${inventory} ${component}
160 FOR ${inventory_element} IN @{inventory}
161 log ${inventory_element}
162 Check Inventory Element ${inventory_element} ${component}
163 END
164
165Check Inventory Element
166 [Documentation] This keyword checks the passed element data
167 [Arguments] ${inventory_element} ${component}
168 FOR ${component_element} IN @{component['elements']}
169 log ${component_element}
TorstenThiemef8f9a802020-12-16 15:25:25 +0000170 ${result}= utility.check_Inventory_Element ${inventory_element} ${component['name']}
171 ... ${component_element['element']} ${component_element['value']}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100172 Should be True ${result}
173 END
174
175Get Component Uuid From Inventory
176 [Documentation] This keyword delivers component-uuid from inventory of passed component-name
177 [Arguments] ${inventory} ${component_name}
178 FOR ${element} IN @{inventory}
179 Log ${element}
180 ${component_uuid}= utility.get_uuid_from_Inventory_Element ${element} ${component_name}
181 END
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200182 Should Not Be Equal ${None} ${component_uuid} Could not find UUID for ${component_name}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100183 [Return] ${component_uuid}
184
185Loggable Entities
186 [Documentation] get the loggable entities of a device
187 [Arguments] ${lib_instance} ${uuid} ${with_check}=${TRUE}
188 ${device_uuid}= Evaluate {'device_uuid':${uuid}}
189 ${response}= Run Keyword ${lib_instance}.Hw Management Service Get Loggable Entities ${device_uuid}
190 ${state}= Get From Dictionary ${response} status
191 Run Keyword If ${with_check} == ${True} Should Be Equal ${state} OK_STATUS
192 ${response_uuid}= Get From Dictionary ${response} device_uuid
193 Run Keyword If ${with_check} == ${True} Should Be Equal ${uuid} ${response_uuid}
194 ${is_loglevels_in}= Run Keyword And Return Status Dictionary Should Contain Key ${response} logLevels
195 ${loggable_entities}= Run Keyword If ${is_loglevels_in}==${True} Get From Dictionary ${response} logLevels
196 ... ELSE Create Dictionary
197 [Return] ${loggable_entities}
198
199Get X Loggable Entities
200 [Documentation] get x (at least!) loggable entities and their loglevel of a device back to the user
201 [Arguments] ${lib_instance} ${uuid} ${number_entities}=5000 ${with_check}=${TRUE}
202 ${loggable_entities}= Loggable Entities ${lib_instance} ${suite_device_uuid} ${with_check}
203 ${entities2}= Create Dictionary
204 ${entities}= Create List
205 ${counter}= Set Variable ${1}
206 FOR ${entry} IN @{loggable_entities}
207 Append To List ${entities} ${entry}
208 Exit For Loop If ${number_entities}==${counter}
209 ${counter}= Set Variable ${counter+1}
210 END
211 [Return] ${entities}
212
Hardik Windlass74b7c842022-02-17 09:11:13 +0000213Set Component Inventory Info
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100214 [Documentation] This keyword sets a new value
Hardik Windlass74b7c842022-02-17 09:11:13 +0000215 [Arguments] ${uuid} ${component_uuid} ${component_name} ${component_field} ${new_value} ${status_code}
216 ${modifiableComp}= Evaluate {'${component_field}':'${new_value}'}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100217 ${HWCompSetReq}= Create Dictionary device_uuid=${uuid} component_uuid=${component_uuid}
218 Set To Dictionary ${HWCompSetReq} component_name=${component_name} changes=${modifiableComp}
219 ${state} ${response} Run Keyword And Ignore Error
220 ... dmi1.Hw Management Service Set Hw Component Info ${HWCompSetReq}
Hardik Windlass74b7c842022-02-17 09:11:13 +0000221 Log ${response}
222 Run Keyword If '${state}'=='FAIL' Should Contain ${response} StatusCode.${status_code}
223 ... ELSE Check Dmi Status ${response} ${status_code}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100224
225Set Logging Level
226 [Documentation] set the given loglevel in device
227 [Arguments] ${lib_instance} ${uuid} ${loggable_entities} ${log_level}
228 FOR ${counter} IN RANGE 0 2
229 ${loggable_entity} Get From List ${loggable_entities} ${counter}
230 Set To Dictionary ${loggable_entity} logLevel ${log_level}
231 END
232 ${loglvl_request}= Evaluate {'device_uuid':${uuid}, 'loglevels':${loggable_entities}}
233 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Log Level ${loglvl_request}
234 Check Dmi Status ${response} OK_STATUS
235
236Set Log Endpoint
237 [Documentation] set the given logging endpoint in device
238 [Arguments] ${lib_instance} ${uuid} ${defined_endpoint} ${defined_protocol}
TorstenThiemef8f9a802020-12-16 15:25:25 +0000239 ${set_endpoint}= Create Dictionary device_uuid=${suite_device_uuid} logging_endpoint=${defined_endpoint}
240 Set To Dictionary ${set_endpoint} logging_protocol=${defined_protocol}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100241 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Logging Endpoint ${set_endpoint}
242 Check Dmi Status ${response} OK_STATUS