blob: 1e0894c59e7889cc0999ec352a0d5952f23f509c [file] [log] [blame]
Martin Cosyns0efdc872021-09-27 16:24:30 +00001# Copyright 2020-present Open Networking Foundation
2# Original copyright 2020-present ADTRAN, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14
15*** Settings ***
16Documentation Library test suite for the grpc_robot library. To run the test suite, the fake device manager from
17... _./servers/dmi_ must have been started beforehand with command _python3 dmi_server.py_.
18Library OperatingSystem WITH NAME os
19Library String
20Library Collections
21Variables ./variables.py
22
23*** Test Cases ***
24Library import
25 [Documentation] Checks if the grpc_robot libraries can be imported.
26 Import Library grpc_robot.Dmi WITH NAME dmi
27 Import Library grpc_robot.Collections
28 Import Library grpc_robot.DmiTools WITH NAME dtools
29 Import Library grpc_robot.VolthaTools WITH NAME vtools
30
31library_versions
32 [Documentation] Checks if the library returns the installed library and device-management-interface versions.
33 [Template] version_check
34 grpc-robot dmi.Library Version Get
35 device-management-interface dmi.Dmi Version Get
36
37keywords
38 [Documentation] Checks if the keyword name exists in the library's keyword list.
39 Keyword Should Exist dmi.connection_close
40 Keyword Should Exist dmi.connection_open
41 Keyword Should Exist dmi.connection_parameters_get
42 Keyword Should Exist dmi.connection_parameters_set
43 Keyword Should Exist dmi.hw_event_mgmt_service_list_events
44 Keyword Should Exist dmi.hw_event_mgmt_service_update_events_configuration
45 Keyword Should Exist dmi.hw_management_service_get_hw_component_info
46 Keyword Should Exist dmi.hw_management_service_get_logging_endpoint
47 Keyword Should Exist dmi.hw_management_service_get_managed_devices
48 Keyword Should Exist dmi.hw_management_service_get_msg_bus_endpoint
49 Keyword Should Exist dmi.hw_management_service_get_physical_inventory
50 Keyword Should Exist dmi.hw_management_service_set_hw_component_info
51 Keyword Should Exist dmi.hw_management_service_set_logging_endpoint
52 Keyword Should Exist dmi.hw_management_service_set_msg_bus_endpoint
53 Keyword Should Exist dmi.hw_management_service_start_managing_device
54 Keyword Should Exist dmi.hw_management_service_stop_managing_device
55 Keyword Should Exist dmi.hw_management_service_get_loggable_entities
56 Keyword Should Exist dmi.hw_management_service_set_log_level
57 Keyword Should Exist dmi.hw_management_service_get_log_level
58 Keyword Should Exist dmi.hw_metrics_mgmt_service_get_metric
59 Keyword Should Exist dmi.hw_metrics_mgmt_service_list_metrics
60 Keyword Should Exist dmi.hw_metrics_mgmt_service_update_metrics_configuration
61 Keyword Should Exist dmi.sw_management_service_activate_image
62 Keyword Should Exist dmi.sw_management_service_download_image
63 Keyword Should Exist dmi.sw_management_service_revert_to_standby_image
64 Keyword Should Exist dmi.sw_management_service_get_software_version
65 Keyword Should Exist dmi.sw_management_service_update_startup_configuration
66 Keyword Should Exist dmi.sw_management_service_get_startup_configuration_info
67 Keyword Should Exist dtools.hw_metrics_mgmt_decode_metric
68 Keyword Should Exist dtools.hw_events_mgmt_decode_event
69 Keyword Should Exist vtools.events_decode_event
70 Keyword Should Exist vtools.tech_profile_decode_resource_instance
71
72dmi
73 [Documentation] Checks the RPC keywords whether or not they handle their input and output correctly and uses the
74 ... fake device manager for that. The fake device manager returns _OK_STATUS_ for each RPC. The variables
75 ... _${keywords_to_skip}_ and _${params}_ are defined in the variables file _./variables.py_.
76 [Setup] dmi.Connection Open host=127.0.0.1 port=50051
77 ${keywords} Run Keyword dmi.Get Keyword Names
78 FOR ${keyword} IN @{keywords}
79 Continue For Loop If '${keyword}' in ${keywords_to_skip}
80 ${status} ${params} Run Keyword And Ignore Error Get From Dictionary ${param_dicts} ${keyword}
81 Run Keyword If '${status}' == 'FAIL' Log no parameters available for keyword '${keyword}' WARN
82 Continue For Loop If '${status}' == 'FAIL'
83 Run Keyword If ${params} == ${NONE} ${keyword} ELSE ${keyword} ${params}
84 END
85 [Teardown] dmi.Connection Close
86
87connection_params
88 [Documentation] Checks the connection parameter settings.
89 ${new_timeout} Set Variable 100
90 ${settings_before} dmi.Connection Parameters Get
91 ${settings_while_set} dmi.Connection Parameters Set timeout=${new_timeout}
92 ${settings_after} dmi.Connection Parameters Get
93 Should Be Equal ${settings_before} ${settings_while_set}
94 Should Be Equal As Integers ${settings_after}[timeout] ${new_timeout}
95
96enum_and_default_values
97 [Documentation] Checks the optional parameters _return_enum_integer_ and _return_defaults_ of the RPC keywords to
98 ... control their output. Check keyword documentation for the meaning of the parameters.
99 ... *Note*: The fake device manager must be running for this test case.
100 [Setup] dmi.Connection Open host=127.0.0.1 port=50051
101 ${params} Get From Dictionary ${param_dicts} hw_management_service_get_log_level
102 ${return} hw_management_service_get_log_level ${params}
103 Should Be Equal As Strings ${return}[status] OK_STATUS
104 Dictionary Should Not Contain Key ${return} reason
105 ${return} hw_management_service_get_log_level ${params} return_enum_integer=true
106 Should Be Equal As Integers ${return}[status] 1
107 Dictionary Should Not Contain Key ${return} reason
108 ${return} hw_management_service_get_log_level ${params} return_enum_integer=${TRUE}
109 Should Be Equal As Integers ${return}[status] 1
110 Dictionary Should Not Contain Key ${return} reason
111 ${return} hw_management_service_get_log_level ${params} return_defaults=true
112 Should Be Equal As Strings ${return}[status] OK_STATUS
113 Should Be Equal As Strings ${return}[reason] UNDEFINED_REASON
114 ${return} hw_management_service_get_log_level ${params} return_defaults=${TRUE}
115 Should Be Equal As Strings ${return}[status] OK_STATUS
116 Should Be Equal As Strings ${return}[reason] UNDEFINED_REASON
117 ${return} hw_management_service_get_log_level ${params} return_enum_integer=true return_defaults=true
118 Should Be Equal As Integers ${return}[status] 1
119 Should Be Equal As Integers ${return}[reason] 0
120 [Teardown] dmi.Connection Close
121
122tools
123 [Documentation] Checks some functions from the tools library which shall support the tester with general functionality.
124 ${dict_1} Create Dictionary name=abc type=123
125 ${dict_2} Create Dictionary name=def type=456
126 ${list} Create List ${dict_1} ${dict_2}
127 ${return_dict} grpc_robot.Collections.List Get Dict By Value ${list} name def
128 Should Be Equal ${return_dict}[type] 456
129
130dmi_tools
131 [Documentation] Checks functions from the DMI tools library with decoding Kafka messages. The variables
132 ... _kafka_metric_messages_ and _kafka_event_messages_ are defined in the variables file.
133 FOR ${kafka} IN @{kafka_metric_messages}
134 ${metric} dtools.Hw Metrics Mgmt Decode Metric ${kafka}[message]
135 Should Be Equal ${metric}[metric_metadata][device_uuid][uuid] 4c411df2-22e6-58d2-b1bb-545a0263d18d
136 Should Be Equal ${metric}[metric_id] ${kafka}[metric]
137 END
138 FOR ${kafka} IN @{kafka_event_messages}
139 ${event} dtools.Hw Events Mgmt Decode Event ${kafka}[message]
140 Should Be Equal ${event}[event_metadata][device_uuid][uuid] 84f46fde-89fa-5a2f-be4a-6d18abe6e953
141 Should Be Equal ${event}[event_id] ${kafka}[event]
142 END
143
144voltha_tools
145 [Documentation] Checks functions from the Voltha tools library with decoding Kafka messages. The variables
146 ... _kafka_voltha_events_messages_ and _voltha_resource_instances_ are defined in the variables file.
147 FOR ${kafka} IN @{kafka_voltha_events_messages}
148 ${event} vtools.Events Decode Event ${kafka}[message] return_defaults=true
149 Should Be Equal ${event}[header][id] Voltha.openolt..1613491472935896440
150 Should Be Equal ${event}[kpi_event2][type] slice
151 ${event} vtools.Events Decode Event ${kafka}[message]
152 Dictionary Should Not Contain Key ${event}[kpi_event2] type
153 END
154 FOR ${input} IN @{voltha_resource_instances}
155 ${instance} vtools.Tech Profile Decode Resource Instance ${input} return_defaults=true
156 Should Be Equal ${instance}[tp_id] ${64}
157 END
158
159*** Keywords ***
160version_check
161 [Documentation] Determines the version of the installed package and compares it with the returned version of the
162 ... corresponding keyword.
163 [Arguments] ${package_name} ${kw_name}
164 ${pip show} os.Run python3 -m pip show ${package_name} | grep Version
165 ${pip show} Split To Lines ${pip show}
166 FOR ${line} IN @{pip show}
167 ${is_version} Evaluate '${line}'.startswith('Version')
168 Continue For Loop If not ${is_version}
169 ${pip_version} Evaluate '${line}'.split(':')[-1].strip()
170 END
171 ${lib_version} Run Keyword ${kw_name}
172 Should Be Equal ${pip_version} ${lib_version}