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