blob: fcc8f7c4e1a8b139b6f053b550fb1a6ff15e729f [file] [log] [blame]
uwe ottrembka504ca3e2020-11-23 12:02:20 +01001# Copyright 2020-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 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}
33
34*** Test Cases ***
35Start and Stop Managing Device In Device Manager
36 [Documentation] add/remove device in device manager (testcase is done by Suite Setup and Suite Teardown)
37 [Tags] sanityDMI functionalDMI EnableOltDMI
38 # this tescase exist, to have the possiblity to check only the Start-/Stop-ManagingDevice
39 # can be run via adding parameter ("-t add and remove device in device manager") to the robot call!
40 No Operation
41
42Get Inventory Data
43 [Documentation] get physical inventory data from OLT
44 [Tags] functionalDMI GetInventoryDataDMI
45 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
46 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
47 Check Dmi Status ${inventory}[0] OK_STATUS
48 FOR ${component} IN @{dm_components}
49 Log ${component}
50 Check Physical Inventory ${inventory} ${component}
51 END
52
53Get Configurable Component Inventory Info
54 [Documentation] get physical component info of all hw in given yaml file
55 [Tags] functionalDMI GetConfigurableComponentInventoryInfoDMI
56 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
57 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
58 Check Dmi Status ${inventory}[0] OK_STATUS
59 FOR ${component} IN @{dm_components}
60 Log ${component}
61 ${component_name}= Convert To String ${component['name']}
62 ${component_uuid}= Get Component Uuid From Inventory ${inventory} ${component_name}
TorstenThiemef8f9a802020-12-16 15:25:25 +000063 ${hwComInfoReq}= Create Dictionary device_uuid=${suite_device_uuid} component_uuid=${component_uuid}
64 Set To Dictionary ${hwComInfoReq} component_name=${component_name}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010065 ${hwComInfoRes}= dmi1.Hw Management Service Get Hw Component Info ${hwComInfoReq}
66 ${hwComInfoRes}= Get From List ${hwComInfoRes} 0
67 Check Dmi Status ${hwComInfoRes} OK_STATUS
68 ${res_component}= Get From Dictionary ${hwComInfoRes} component
69 ${value_name}= Get From Dictionary ${res_component} name
70 Should be Equal ${value_name} ${component_name}
TorstenThiemef8f9a802020-12-16 15:25:25 +000071 Set Component Inventory Info Unimplemented ${suite_device_uuid} ${component_uuid} ${component_name}
72 ... new-value
uwe ottrembka504ca3e2020-11-23 12:02:20 +010073 END
74
75Get Loggable Entities
76 [Documentation] get the loggable entities of the device
TorstenThiemef8f9a802020-12-16 15:25:25 +000077 [Tags] functionalDMI GetLoggableEntitiesDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010078 ${loggable_entities}= Loggable Entities dmi1 ${suite_device_uuid}
79 ${size_loggable_entities}= Get Length ${loggable_entities}
80 Should Be True ${size_loggable_entities} > 5
81
82Set Get Logging Endpoint
83 [Documentation] set/get the loggable endpoint of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +000084 [Tags] functionalDMI SetGetLoggingEndpointDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010085 ${defined_endpoint}= Set Variable 127.0.0.1
86 ${defined_protocol}= Set Variable udp
87 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
88 # now the new logging endpoint and protocol should be set!
89 ${uuid}= Evaluate {'uuid':${suite_device_uuid}}
90 ${log_endpoint}= dmi1.Hw Management Service Get Logging Endpoint ${uuid}
91 Check Dmi Status ${log_endpoint} OK_STATUS
92 ${get_endpoint}= Get From Dictionary ${log_endpoint} logging_endpoint
93 ${get_protocol}= Get From Dictionary ${log_endpoint} logging_protocol
94 Should Be Equal ${get_endpoint} ${defined_endpoint}
95 Should Be Equal ${get_protocol} ${defined_protocol}
96 # remove logging endpoint
97 ${defined_endpoint}= Set Variable
98 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
99
100Set Get LogLevel
101 [Documentation] set and get the log level of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +0000102 [Tags] functionalDMI SetGetLogLevelDMI skipped bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100103 ${loggable_entities}= Get X Loggable Entities dmi1 ${suite_device_uuid} 2
104 ${size}= GetLength ${loggable_entities}
105 Should Be True ${size} >= 2
106 # set new loglevel
107 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} ERROR
108 # get the loglevel
109 ${log_list}= Create List
110 ${entity}= Set Variable ${loggable_entities}[0][entities]
111 FOR ${log_entity} IN @{entity}
112 Append To List ${log_list} ${log_entity}
113 END
114 ${entity}= Set Variable ${loggable_entities}[1][entities]
115 FOR ${log_entity} IN @{entity}
116 Append To List ${log_list} ${log_entity}
117 END
118 ${loglvl_request}= Evaluate {'device_uuid':${suite_device_uuid}, 'entities':${log_list}}
119 ${response}= dmi1.Hw Management Service Get Log Level ${loglvl_request}
120 Check Dmi Status ${response} OK_STATUS
121 FOR ${counter} IN RANGE 0 2
122 Should Be True '${response}[logLevels][${counter}][logLevel]' == 'ERROR'
123 END
124 # set loglevel back to default
125 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} WARN
126
127*** Keywords ***
128Suite Setup
129 [Documentation] start a managed device in the device manager
130 dmi1.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT}
131 ${name}= Set Variable BBSim-BBSIM_OLT_0
132 ${suite_device_uuid}= Start Managing Device dmi1 ${OLT_IP} ${name}
133 ${suite_device_name}= Evaluate {'name':'BBSim-BBSIM_OLT_0'}
134 Set Suite Variable ${suite_device_uuid}
135 Set Suite Variable ${suite_device_name}
136
137Suite Teardown
138 [Documentation] stop a managed device in device manager
139 Stop Managing Device dmi1 BBSim-BBSIM_OLT_0
140 dmi1.Connection Close
141 Search For Managed Devices And Stop Managing It dmi1
142
143Check Physical Inventory
144 [Documentation] This keyword checks the passed inventory data
145 [Arguments] ${inventory} ${component}
146 FOR ${inventory_element} IN @{inventory}
147 log ${inventory_element}
148 Check Inventory Element ${inventory_element} ${component}
149 END
150
151Check Inventory Element
152 [Documentation] This keyword checks the passed element data
153 [Arguments] ${inventory_element} ${component}
154 FOR ${component_element} IN @{component['elements']}
155 log ${component_element}
TorstenThiemef8f9a802020-12-16 15:25:25 +0000156 ${result}= utility.check_Inventory_Element ${inventory_element} ${component['name']}
157 ... ${component_element['element']} ${component_element['value']}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100158 Should be True ${result}
159 END
160
161Get Component Uuid From Inventory
162 [Documentation] This keyword delivers component-uuid from inventory of passed component-name
163 [Arguments] ${inventory} ${component_name}
164 FOR ${element} IN @{inventory}
165 Log ${element}
166 ${component_uuid}= utility.get_uuid_from_Inventory_Element ${element} ${component_name}
167 END
168 Should Not Be Equal ${None} ${component_uuid}
169 [Return] ${component_uuid}
170
171Loggable Entities
172 [Documentation] get the loggable entities of a device
173 [Arguments] ${lib_instance} ${uuid} ${with_check}=${TRUE}
174 ${device_uuid}= Evaluate {'device_uuid':${uuid}}
175 ${response}= Run Keyword ${lib_instance}.Hw Management Service Get Loggable Entities ${device_uuid}
176 ${state}= Get From Dictionary ${response} status
177 Run Keyword If ${with_check} == ${True} Should Be Equal ${state} OK_STATUS
178 ${response_uuid}= Get From Dictionary ${response} device_uuid
179 Run Keyword If ${with_check} == ${True} Should Be Equal ${uuid} ${response_uuid}
180 ${is_loglevels_in}= Run Keyword And Return Status Dictionary Should Contain Key ${response} logLevels
181 ${loggable_entities}= Run Keyword If ${is_loglevels_in}==${True} Get From Dictionary ${response} logLevels
182 ... ELSE Create Dictionary
183 [Return] ${loggable_entities}
184
185Get X Loggable Entities
186 [Documentation] get x (at least!) loggable entities and their loglevel of a device back to the user
187 [Arguments] ${lib_instance} ${uuid} ${number_entities}=5000 ${with_check}=${TRUE}
188 ${loggable_entities}= Loggable Entities ${lib_instance} ${suite_device_uuid} ${with_check}
189 ${entities2}= Create Dictionary
190 ${entities}= Create List
191 ${counter}= Set Variable ${1}
192 FOR ${entry} IN @{loggable_entities}
193 Append To List ${entities} ${entry}
194 Exit For Loop If ${number_entities}==${counter}
195 ${counter}= Set Variable ${counter+1}
196 END
197 [Return] ${entities}
198
199Set Component Inventory Info Unimplemented
200 [Documentation] This keyword sets a new value
201 [Arguments] ${uuid} ${component_uuid} ${component_name} ${new_value}
202 # try to set a component (note: currently not supported!)
203 ${modifiableComp}= Evaluate {'name':'${new_value}'}
204 ${HWCompSetReq}= Create Dictionary device_uuid=${uuid} component_uuid=${component_uuid}
205 Set To Dictionary ${HWCompSetReq} component_name=${component_name} changes=${modifiableComp}
206 ${state} ${response} Run Keyword And Ignore Error
207 ... dmi1.Hw Management Service Set Hw Component Info ${HWCompSetReq}
208 Should Contain ${response} StatusCode.UNIMPLEMENTED
209
210Set Logging Level
211 [Documentation] set the given loglevel in device
212 [Arguments] ${lib_instance} ${uuid} ${loggable_entities} ${log_level}
213 FOR ${counter} IN RANGE 0 2
214 ${loggable_entity} Get From List ${loggable_entities} ${counter}
215 Set To Dictionary ${loggable_entity} logLevel ${log_level}
216 END
217 ${loglvl_request}= Evaluate {'device_uuid':${uuid}, 'loglevels':${loggable_entities}}
218 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Log Level ${loglvl_request}
219 Check Dmi Status ${response} OK_STATUS
220
221Set Log Endpoint
222 [Documentation] set the given logging endpoint in device
223 [Arguments] ${lib_instance} ${uuid} ${defined_endpoint} ${defined_protocol}
TorstenThiemef8f9a802020-12-16 15:25:25 +0000224 ${set_endpoint}= Create Dictionary device_uuid=${suite_device_uuid} logging_endpoint=${defined_endpoint}
225 Set To Dictionary ${set_endpoint} logging_protocol=${defined_protocol}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100226 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Logging Endpoint ${set_endpoint}
227 Check Dmi Status ${response} OK_STATUS