uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 1 | # 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 *** |
| 16 | Documentation Library for testing dmi interface (hw_management_service.proto) |
| 17 | Library Process |
| 18 | Library grpc_robot.Dmi WITH NAME dmi1 |
| 19 | Library grpc_robot.Collections WITH NAME tools |
| 20 | Library kafka_robot.KafkaClient WITH NAME kafka |
| 21 | Library Collections |
| 22 | Library BuiltIn |
| 23 | Library ../../libraries/utility.py WITH NAME utility |
| 24 | Resource ../../libraries/dmi-basics.robot |
| 25 | Variables ../../variables/variables.py |
| 26 | Suite Setup Suite Setup |
| 27 | Suite 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 Windlass | 184fc22 | 2022-02-08 13:09:32 +0000 | [diff] [blame] | 33 | ${OLT_NAME} ${GIVEN_OLT_NAME} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 34 | |
Hardik Windlass | e01d3af | 2022-02-11 06:19:07 +0000 | [diff] [blame] | 35 | ${has_dataplane} True |
| 36 | |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 37 | *** Test Cases *** |
| 38 | Start 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 | |
| 45 | Get 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 Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 56 | Get Set Configurable Component Inventory Info |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 57 | [Documentation] get physical component info of all hw in given yaml file |
Hardik Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 58 | [Tags] functionalDMI GetSetConfigurableComponentInventoryInfoDMI |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 59 | &{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} |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 66 | ${hwComInfoReq}= Create Dictionary device_uuid=${suite_device_uuid} component_uuid=${component_uuid} |
| 67 | Set To Dictionary ${hwComInfoReq} component_name=${component_name} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 68 | ${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 Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 74 | # 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 ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 87 | END |
| 88 | |
| 89 | Get Loggable Entities |
| 90 | [Documentation] get the loggable entities of the device |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 91 | [Tags] functionalDMI GetLoggableEntitiesDMI bbsimUnimplementedDMI |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 92 | ${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 | |
| 96 | Set Get Logging Endpoint |
| 97 | [Documentation] set/get the loggable endpoint of a device |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 98 | [Tags] functionalDMI SetGetLoggingEndpointDMI bbsimUnimplementedDMI |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 99 | ${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 Windlass | e01d3af | 2022-02-11 06:19:07 +0000 | [diff] [blame] | 112 | ${defined_protocol}= Set Variable |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 113 | Set Log Endpoint dmi1 ${suite_device_uuid} ${defined_endpoint} ${defined_protocol} |
| 114 | |
| 115 | Set Get LogLevel |
| 116 | [Documentation] set and get the log level of a device |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 117 | [Tags] functionalDMI SetGetLogLevelDMI skipped bbsimUnimplementedDMI |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 118 | ${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 *** |
| 143 | Suite Setup |
| 144 | [Documentation] start a managed device in the device manager |
| 145 | dmi1.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT} |
Hardik Windlass | 184fc22 | 2022-02-08 13:09:32 +0000 | [diff] [blame] | 146 | ${suite_device_uuid}= Start Managing Device dmi1 ${OLT_IP} ${OLT_NAME} |
| 147 | ${suite_device_name}= Evaluate {'name':'${OLT_NAME}'} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 148 | Set Suite Variable ${suite_device_uuid} |
| 149 | Set Suite Variable ${suite_device_name} |
| 150 | |
| 151 | Suite Teardown |
| 152 | [Documentation] stop a managed device in device manager |
Hardik Windlass | 184fc22 | 2022-02-08 13:09:32 +0000 | [diff] [blame] | 153 | Stop Managing Device dmi1 ${OLT_NAME} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 154 | dmi1.Connection Close |
| 155 | Search For Managed Devices And Stop Managing It dmi1 |
| 156 | |
| 157 | Check 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 | |
| 165 | Check 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} |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 170 | ${result}= utility.check_Inventory_Element ${inventory_element} ${component['name']} |
| 171 | ... ${component_element['element']} ${component_element['value']} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 172 | Should be True ${result} |
| 173 | END |
| 174 | |
| 175 | Get 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 |
| 182 | Should Not Be Equal ${None} ${component_uuid} |
| 183 | [Return] ${component_uuid} |
| 184 | |
| 185 | Loggable 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 | |
| 199 | Get 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 Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 213 | Set Component Inventory Info |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 214 | [Documentation] This keyword sets a new value |
Hardik Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 215 | [Arguments] ${uuid} ${component_uuid} ${component_name} ${component_field} ${new_value} ${status_code} |
| 216 | ${modifiableComp}= Evaluate {'${component_field}':'${new_value}'} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 217 | ${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 Windlass | 74b7c84 | 2022-02-17 09:11:13 +0000 | [diff] [blame] | 221 | Log ${response} |
| 222 | Run Keyword If '${state}'=='FAIL' Should Contain ${response} StatusCode.${status_code} |
| 223 | ... ELSE Check Dmi Status ${response} ${status_code} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 224 | |
| 225 | Set 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 | |
| 236 | Set Log Endpoint |
| 237 | [Documentation] set the given logging endpoint in device |
| 238 | [Arguments] ${lib_instance} ${uuid} ${defined_endpoint} ${defined_protocol} |
TorstenThieme | f8f9a80 | 2020-12-16 15:25:25 +0000 | [diff] [blame] | 239 | ${set_endpoint}= Create Dictionary device_uuid=${suite_device_uuid} logging_endpoint=${defined_endpoint} |
| 240 | Set To Dictionary ${set_endpoint} logging_protocol=${defined_protocol} |
uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 241 | ${response}= Run Keyword ${lib_instance}.Hw Management Service Set Logging Endpoint ${set_endpoint} |
| 242 | Check Dmi Status ${response} OK_STATUS |