blob: 931c000d428982149c064178aa60887d8daef5f3 [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}
Hardik Windlass184fc222022-02-08 13:09:32 +000033${OLT_NAME} ${GIVEN_OLT_NAME}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010034
35*** Test Cases ***
36Start and Stop Managing Device In Device Manager
37 [Documentation] add/remove device in device manager (testcase is done by Suite Setup and Suite Teardown)
38 [Tags] sanityDMI functionalDMI EnableOltDMI
39 # this tescase exist, to have the possiblity to check only the Start-/Stop-ManagingDevice
40 # can be run via adding parameter ("-t add and remove device in device manager") to the robot call!
41 No Operation
42
43Get Inventory Data
44 [Documentation] get physical inventory data from OLT
45 [Tags] functionalDMI GetInventoryDataDMI
46 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
47 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
48 Check Dmi Status ${inventory}[0] OK_STATUS
49 FOR ${component} IN @{dm_components}
50 Log ${component}
51 Check Physical Inventory ${inventory} ${component}
52 END
53
54Get Configurable Component Inventory Info
55 [Documentation] get physical component info of all hw in given yaml file
56 [Tags] functionalDMI GetConfigurableComponentInventoryInfoDMI
57 &{PhyInvReq}= Evaluate {'device_uuid':${suite_device_uuid}}
58 ${inventory}= dmi1.Hw Management Service Get Physical Inventory ${PhyInvReq}
59 Check Dmi Status ${inventory}[0] OK_STATUS
60 FOR ${component} IN @{dm_components}
61 Log ${component}
62 ${component_name}= Convert To String ${component['name']}
63 ${component_uuid}= Get Component Uuid From Inventory ${inventory} ${component_name}
TorstenThiemef8f9a802020-12-16 15:25:25 +000064 ${hwComInfoReq}= Create Dictionary device_uuid=${suite_device_uuid} component_uuid=${component_uuid}
65 Set To Dictionary ${hwComInfoReq} component_name=${component_name}
uwe ottrembka504ca3e2020-11-23 12:02:20 +010066 ${hwComInfoRes}= dmi1.Hw Management Service Get Hw Component Info ${hwComInfoReq}
67 ${hwComInfoRes}= Get From List ${hwComInfoRes} 0
68 Check Dmi Status ${hwComInfoRes} OK_STATUS
69 ${res_component}= Get From Dictionary ${hwComInfoRes} component
70 ${value_name}= Get From Dictionary ${res_component} name
71 Should be Equal ${value_name} ${component_name}
TorstenThiemef8f9a802020-12-16 15:25:25 +000072 Set Component Inventory Info Unimplemented ${suite_device_uuid} ${component_uuid} ${component_name}
73 ... new-value
uwe ottrembka504ca3e2020-11-23 12:02:20 +010074 END
75
76Get Loggable Entities
77 [Documentation] get the loggable entities of the device
TorstenThiemef8f9a802020-12-16 15:25:25 +000078 [Tags] functionalDMI GetLoggableEntitiesDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010079 ${loggable_entities}= Loggable Entities dmi1 ${suite_device_uuid}
80 ${size_loggable_entities}= Get Length ${loggable_entities}
81 Should Be True ${size_loggable_entities} > 5
82
83Set Get Logging Endpoint
84 [Documentation] set/get the loggable endpoint of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +000085 [Tags] functionalDMI SetGetLoggingEndpointDMI bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +010086 ${defined_endpoint}= Set Variable 127.0.0.1
87 ${defined_protocol}= Set Variable udp
88 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
89 # now the new logging endpoint and protocol should be set!
90 ${uuid}= Evaluate {'uuid':${suite_device_uuid}}
91 ${log_endpoint}= dmi1.Hw Management Service Get Logging Endpoint ${uuid}
92 Check Dmi Status ${log_endpoint} OK_STATUS
93 ${get_endpoint}= Get From Dictionary ${log_endpoint} logging_endpoint
94 ${get_protocol}= Get From Dictionary ${log_endpoint} logging_protocol
95 Should Be Equal ${get_endpoint} ${defined_endpoint}
96 Should Be Equal ${get_protocol} ${defined_protocol}
97 # remove logging endpoint
98 ${defined_endpoint}= Set Variable
99 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
100
101Set Get LogLevel
102 [Documentation] set and get the log level of a device
TorstenThiemef8f9a802020-12-16 15:25:25 +0000103 [Tags] functionalDMI SetGetLogLevelDMI skipped bbsimUnimplementedDMI
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100104 ${loggable_entities}= Get X Loggable Entities dmi1 ${suite_device_uuid} 2
105 ${size}= GetLength ${loggable_entities}
106 Should Be True ${size} >= 2
107 # set new loglevel
108 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} ERROR
109 # get the loglevel
110 ${log_list}= Create List
111 ${entity}= Set Variable ${loggable_entities}[0][entities]
112 FOR ${log_entity} IN @{entity}
113 Append To List ${log_list} ${log_entity}
114 END
115 ${entity}= Set Variable ${loggable_entities}[1][entities]
116 FOR ${log_entity} IN @{entity}
117 Append To List ${log_list} ${log_entity}
118 END
119 ${loglvl_request}= Evaluate {'device_uuid':${suite_device_uuid}, 'entities':${log_list}}
120 ${response}= dmi1.Hw Management Service Get Log Level ${loglvl_request}
121 Check Dmi Status ${response} OK_STATUS
122 FOR ${counter} IN RANGE 0 2
123 Should Be True '${response}[logLevels][${counter}][logLevel]' == 'ERROR'
124 END
125 # set loglevel back to default
126 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} WARN
127
128*** Keywords ***
129Suite Setup
130 [Documentation] start a managed device in the device manager
131 dmi1.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT}
Hardik Windlass184fc222022-02-08 13:09:32 +0000132 ${suite_device_uuid}= Start Managing Device dmi1 ${OLT_IP} ${OLT_NAME}
133 ${suite_device_name}= Evaluate {'name':'${OLT_NAME}'}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100134 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
Hardik Windlass184fc222022-02-08 13:09:32 +0000139 Stop Managing Device dmi1 ${OLT_NAME}
uwe ottrembka504ca3e2020-11-23 12:02:20 +0100140 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