blob: 27b92049253c21ddc99d886b90d5d46854684748 [file] [log] [blame]
Martin Cosynsf88ed6e2020-12-02 10:30:10 +01001# Copyright 2020 ADTRAN, Inc.
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
14*** Settings ***
15Documentation Library test suite for the grpc_robot library. To run the test suite, the fake device manager from
16... _./servers/dmi_ must have been started beforehand with command _python3 dmi_server.py_.
17Library OperatingSystem WITH NAME os
18Library String
19Library Collections
20Variables ./variables.py
21
22*** Test Cases ***
23Library import
24 [Documentation] Checks if the grpc_robot libraries can be imported.
25 Import Library grpc_robot.Dmi WITH NAME dmi
26 Import Library grpc_robot.Collections
27 Import Library grpc_robot.DmiTools WITH NAME tools
28
29library_versions
30 [Documentation] Checks if the library returns the installed library and device-management-interface versions.
31 [Template] version_check
32 grpc-robot dmi.Library Version Get
33 device-management-interface dmi.Dmi Version Get
34
35keywords
36 [Documentation] Checks if the keyword name exists in the library's keyword list.
37 Keyword Should Exist dmi.connection_close
38 Keyword Should Exist dmi.connection_open
39 Keyword Should Exist dmi.connection_parameters_get
40 Keyword Should Exist dmi.connection_parameters_set
41 Keyword Should Exist dmi.hw_event_mgmt_service_list_events
42 Keyword Should Exist dmi.hw_event_mgmt_service_update_events_configuration
43 Keyword Should Exist dmi.hw_management_service_get_hw_component_info
44 Keyword Should Exist dmi.hw_management_service_get_logging_endpoint
45 Keyword Should Exist dmi.hw_management_service_get_managed_devices
46 Keyword Should Exist dmi.hw_management_service_get_msg_bus_endpoint
47 Keyword Should Exist dmi.hw_management_service_get_physical_inventory
48 Keyword Should Exist dmi.hw_management_service_set_hw_component_info
49 Keyword Should Exist dmi.hw_management_service_set_logging_endpoint
50 Keyword Should Exist dmi.hw_management_service_set_msg_bus_endpoint
51 Keyword Should Exist dmi.hw_management_service_start_managing_device
52 Keyword Should Exist dmi.hw_management_service_stop_managing_device
53 Keyword Should Exist dmi.hw_management_service_get_loggable_entities
54 Keyword Should Exist dmi.hw_management_service_set_log_level
55 Keyword Should Exist dmi.hw_management_service_get_log_level
56 Keyword Should Exist dmi.hw_metrics_mgmt_service_get_metric
57 Keyword Should Exist dmi.hw_metrics_mgmt_service_list_metrics
58 Keyword Should Exist dmi.hw_metrics_mgmt_service_update_metrics_configuration
59 Keyword Should Exist dmi.sw_management_service_activate_image
60 Keyword Should Exist dmi.sw_management_service_download_image
61 Keyword Should Exist dmi.sw_management_service_revert_to_standby_image
62 Keyword Should Exist dmi.sw_management_service_get_software_version
63 Keyword Should Exist tools.hw_metrics_mgmt_decode_metric
64 Keyword Should Exist tools.hw_events_mgmt_decode_event
65
66dmi
67 [Documentation] Checks the RPC keywords whether or not they handle their input and output correctly and uses the
68 ... fake device manager for that. The fake device manager returns _OK_STATUS_ for each RPC. The variables
69 ... _${keywords_to_skip}_ and _${params}_ are defined in the variables file _./variables.py_.
70 [Setup] dmi.Connection Open host=127.0.0.1 port=50051
71 ${keywords} Run Keyword dmi.Get Keyword Names
72 FOR ${keyword} IN @{keywords}
73 Continue For Loop If '${keyword}' in ${keywords_to_skip}
74 ${status} ${params} Run Keyword And Ignore Error Get From Dictionary ${param_dicts} ${keyword}
75 Run Keyword If '${status}' == 'FAIL' Log no parameters available for keyword '${keyword}' WARN
76 Continue For Loop If '${status}' == 'FAIL'
77 Run Keyword If ${params} == ${NONE} ${keyword} ELSE ${keyword} ${params}
78 END
79 [Teardown] dmi.Connection Close
80
81connection_params
82 [Documentation] Checks the connection parameter settings.
83 ${new_timeout} Set Variable 100
84 ${settings_before} dmi.Connection Parameters Get
85 ${settings_while_set} dmi.Connection Parameters Set timeout=${new_timeout}
86 ${settings_after} dmi.Connection Parameters Get
87 Should Be Equal ${settings_before} ${settings_while_set}
88 Should Be Equal As Integers ${settings_after}[timeout] ${new_timeout}
89
90enum_and_default_values
91 [Documentation] Checks the optional parameters _return_enum_integer_ and _return_defaults_ of the RPC keywords to
92 ... control their output. Check keyword documentation for the meaning of the parameters.
93 ... *Note*: The fake device manager must be running for this test case.
94 [Setup] dmi.Connection Open host=127.0.0.1 port=50051
95 ${params} Get From Dictionary ${param_dicts} hw_management_service_get_log_level
96 ${return} hw_management_service_get_log_level ${params}
97 Should Be Equal As Strings ${return}[status] OK_STATUS
98 Dictionary Should Not Contain Key ${return} reason
99 ${return} hw_management_service_get_log_level ${params} return_enum_integer=true
100 Should Be Equal As Integers ${return}[status] 1
101 Dictionary Should Not Contain Key ${return} reason
102 ${return} hw_management_service_get_log_level ${params} return_enum_integer=${TRUE}
103 Should Be Equal As Integers ${return}[status] 1
104 Dictionary Should Not Contain Key ${return} reason
105 ${return} hw_management_service_get_log_level ${params} return_defaults=true
106 Should Be Equal As Strings ${return}[status] OK_STATUS
107 Should Be Equal As Strings ${return}[reason] UNDEFINED_REASON
108 ${return} hw_management_service_get_log_level ${params} return_defaults=${TRUE}
109 Should Be Equal As Strings ${return}[status] OK_STATUS
110 Should Be Equal As Strings ${return}[reason] UNDEFINED_REASON
111 ${return} hw_management_service_get_log_level ${params} return_enum_integer=true return_defaults=true
112 Should Be Equal As Integers ${return}[status] 1
113 Should Be Equal As Integers ${return}[reason] 0
114 [Teardown] dmi.Connection Close
115
116tools
117 [Documentation] Checks some functions from the tools library which shall support the tester with general functionality.
118 ${dict_1} Create Dictionary name=abc type=123
119 ${dict_2} Create Dictionary name=def type=456
120 ${list} Create List ${dict_1} ${dict_2}
121 ${return_dict} grpc_robot.Collections.List Get Dict By Value ${list} name def
122 Should Be Equal ${return_dict}[type] 456
123
124dmi_tools
125 [Documentation] Checks functions from the DMI tools library with decoding Kafka messages. The variables
126 ... _kafka_metric_messages_ and _kafka_event_messages_ is defined in the variables file.
127 FOR ${kafka} IN @{kafka_metric_messages}
128 ${metric} tools.Hw Metrics Mgmt Decode Metric ${kafka}[message]
129 Should Be Equal ${metric}[metric_metadata][device_uuid][uuid] 4c411df2-22e6-58d2-b1bb-545a0263d18d
130 Should Be Equal ${metric}[metric_id] ${kafka}[metric]
131 END
132 FOR ${kafka} IN @{kafka_event_messages}
133 ${event} tools.Hw Events Mgmt Decode Event ${kafka}[message]
134 Should Be Equal ${event}[event_metadata][device_uuid][uuid] 84f46fde-89fa-5a2f-be4a-6d18abe6e953
135 Should Be Equal ${event}[event_id] ${kafka}[event]
136 END
137
138*** Keywords ***
139version_check
140 [Documentation] Determines the version of the installed package and compares it with the returned version of the
141 ... corresponding keyword.
142 [Arguments] ${package_name} ${kw_name}
143 ${pip show} os.Run python3 -m pip show ${package_name} | grep Version
144 ${pip show} Split To Lines ${pip show}
145 FOR ${line} IN @{pip show}
146 ${is_version} Evaluate '${line}'.startswith('Version')
147 Continue For Loop If not ${is_version}
148 ${pip_version} Evaluate '${line}'.split(':')[-1].strip()
149 END
150 ${lib_version} Run Keyword ${kw_name}
151 Should Be Equal ${pip_version} ${lib_version}