blob: f96c8ccd773f4172acfb7d30ab19772ac4370b54 [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}
63 ${hwComInfoReq}= Evaluate
64 ... {'device_uuid':${suite_device_uuid}, 'component_uuid':${component_uuid}, 'component_name':'${component_name}'}
65 ${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}
71 Set Component Inventory Info Unimplemented ${suite_device_uuid} ${component_uuid} ${component_name} new-value
72 END
73
74Get Loggable Entities
75 [Documentation] get the loggable entities of the device
76 [Tags] functionalDMI GetLoggableEntitiesDMI
77 ${loggable_entities}= Loggable Entities dmi1 ${suite_device_uuid}
78 ${size_loggable_entities}= Get Length ${loggable_entities}
79 Should Be True ${size_loggable_entities} > 5
80
81Set Get Logging Endpoint
82 [Documentation] set/get the loggable endpoint of a device
83 [Tags] functionalDMI SetGetLoggingEndpointDMI
84 ${defined_endpoint}= Set Variable 127.0.0.1
85 ${defined_protocol}= Set Variable udp
86 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
87 # now the new logging endpoint and protocol should be set!
88 ${uuid}= Evaluate {'uuid':${suite_device_uuid}}
89 ${log_endpoint}= dmi1.Hw Management Service Get Logging Endpoint ${uuid}
90 Check Dmi Status ${log_endpoint} OK_STATUS
91 ${get_endpoint}= Get From Dictionary ${log_endpoint} logging_endpoint
92 ${get_protocol}= Get From Dictionary ${log_endpoint} logging_protocol
93 Should Be Equal ${get_endpoint} ${defined_endpoint}
94 Should Be Equal ${get_protocol} ${defined_protocol}
95 # remove logging endpoint
96 ${defined_endpoint}= Set Variable
97 Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol}
98
99Set Get LogLevel
100 [Documentation] set and get the log level of a device
101 [Tags] functionalDMI SetGetLogLevelDMI skipped
102 ${loggable_entities}= Get X Loggable Entities dmi1 ${suite_device_uuid} 2
103 ${size}= GetLength ${loggable_entities}
104 Should Be True ${size} >= 2
105 # set new loglevel
106 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} ERROR
107 # get the loglevel
108 ${log_list}= Create List
109 ${entity}= Set Variable ${loggable_entities}[0][entities]
110 FOR ${log_entity} IN @{entity}
111 Append To List ${log_list} ${log_entity}
112 END
113 ${entity}= Set Variable ${loggable_entities}[1][entities]
114 FOR ${log_entity} IN @{entity}
115 Append To List ${log_list} ${log_entity}
116 END
117 ${loglvl_request}= Evaluate {'device_uuid':${suite_device_uuid}, 'entities':${log_list}}
118 ${response}= dmi1.Hw Management Service Get Log Level ${loglvl_request}
119 Check Dmi Status ${response} OK_STATUS
120 FOR ${counter} IN RANGE 0 2
121 Should Be True '${response}[logLevels][${counter}][logLevel]' == 'ERROR'
122 END
123 # set loglevel back to default
124 Set Logging Level dmi1 ${suite_device_uuid} ${loggable_entities} WARN
125
126*** Keywords ***
127Suite Setup
128 [Documentation] start a managed device in the device manager
129 dmi1.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT}
130 ${name}= Set Variable BBSim-BBSIM_OLT_0
131 ${suite_device_uuid}= Start Managing Device dmi1 ${OLT_IP} ${name}
132 ${suite_device_name}= Evaluate {'name':'BBSim-BBSIM_OLT_0'}
133 Set Suite Variable ${suite_device_uuid}
134 Set Suite Variable ${suite_device_name}
135
136Suite Teardown
137 [Documentation] stop a managed device in device manager
138 Stop Managing Device dmi1 BBSim-BBSIM_OLT_0
139 dmi1.Connection Close
140 Search For Managed Devices And Stop Managing It dmi1
141
142Check Physical Inventory
143 [Documentation] This keyword checks the passed inventory data
144 [Arguments] ${inventory} ${component}
145 FOR ${inventory_element} IN @{inventory}
146 log ${inventory_element}
147 Check Inventory Element ${inventory_element} ${component}
148 END
149
150Check Inventory Element
151 [Documentation] This keyword checks the passed element data
152 [Arguments] ${inventory_element} ${component}
153 FOR ${component_element} IN @{component['elements']}
154 log ${component_element}
155 ${result}= utility.check_Inventory_Element ${inventory_element} ${component['name']} ${component_element['element']}
156 ... ${component_element['value']}
157 Should be True ${result}
158 END
159
160Get Component Uuid From Inventory
161 [Documentation] This keyword delivers component-uuid from inventory of passed component-name
162 [Arguments] ${inventory} ${component_name}
163 FOR ${element} IN @{inventory}
164 Log ${element}
165 ${component_uuid}= utility.get_uuid_from_Inventory_Element ${element} ${component_name}
166 END
167 Should Not Be Equal ${None} ${component_uuid}
168 [Return] ${component_uuid}
169
170Loggable Entities
171 [Documentation] get the loggable entities of a device
172 [Arguments] ${lib_instance} ${uuid} ${with_check}=${TRUE}
173 ${device_uuid}= Evaluate {'device_uuid':${uuid}}
174 ${response}= Run Keyword ${lib_instance}.Hw Management Service Get Loggable Entities ${device_uuid}
175 ${state}= Get From Dictionary ${response} status
176 Run Keyword If ${with_check} == ${True} Should Be Equal ${state} OK_STATUS
177 ${response_uuid}= Get From Dictionary ${response} device_uuid
178 Run Keyword If ${with_check} == ${True} Should Be Equal ${uuid} ${response_uuid}
179 ${is_loglevels_in}= Run Keyword And Return Status Dictionary Should Contain Key ${response} logLevels
180 ${loggable_entities}= Run Keyword If ${is_loglevels_in}==${True} Get From Dictionary ${response} logLevels
181 ... ELSE Create Dictionary
182 [Return] ${loggable_entities}
183
184Get X Loggable Entities
185 [Documentation] get x (at least!) loggable entities and their loglevel of a device back to the user
186 [Arguments] ${lib_instance} ${uuid} ${number_entities}=5000 ${with_check}=${TRUE}
187 ${loggable_entities}= Loggable Entities ${lib_instance} ${suite_device_uuid} ${with_check}
188 ${entities2}= Create Dictionary
189 ${entities}= Create List
190 ${counter}= Set Variable ${1}
191 FOR ${entry} IN @{loggable_entities}
192 Append To List ${entities} ${entry}
193 Exit For Loop If ${number_entities}==${counter}
194 ${counter}= Set Variable ${counter+1}
195 END
196 [Return] ${entities}
197
198Set Component Inventory Info Unimplemented
199 [Documentation] This keyword sets a new value
200 [Arguments] ${uuid} ${component_uuid} ${component_name} ${new_value}
201 # try to set a component (note: currently not supported!)
202 ${modifiableComp}= Evaluate {'name':'${new_value}'}
203 ${HWCompSetReq}= Create Dictionary device_uuid=${uuid} component_uuid=${component_uuid}
204 Set To Dictionary ${HWCompSetReq} component_name=${component_name} changes=${modifiableComp}
205 ${state} ${response} Run Keyword And Ignore Error
206 ... dmi1.Hw Management Service Set Hw Component Info ${HWCompSetReq}
207 Should Contain ${response} StatusCode.UNIMPLEMENTED
208
209Set Logging Level
210 [Documentation] set the given loglevel in device
211 [Arguments] ${lib_instance} ${uuid} ${loggable_entities} ${log_level}
212 FOR ${counter} IN RANGE 0 2
213 ${loggable_entity} Get From List ${loggable_entities} ${counter}
214 Set To Dictionary ${loggable_entity} logLevel ${log_level}
215 END
216 ${loglvl_request}= Evaluate {'device_uuid':${uuid}, 'loglevels':${loggable_entities}}
217 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Log Level ${loglvl_request}
218 Check Dmi Status ${response} OK_STATUS
219
220Set Log Endpoint
221 [Documentation] set the given logging endpoint in device
222 [Arguments] ${lib_instance} ${uuid} ${defined_endpoint} ${defined_protocol}
223 ${set_endpoint}= Evaluate
224 ... {'device_uuid':${suite_device_uuid},'logging_endpoint':'${defined_endpoint}','logging_protocol':'${defined_protocol}'}
225 ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Logging Endpoint ${set_endpoint}
226 Check Dmi Status ${response} OK_STATUS