1*** Settings ***
2Documentation       This suite tests IPMI SOL in OpenBMC.
3
4Resource            ../lib/ipmi_client.robot
5Resource            ../lib/openbmc_ffdc.robot
6Resource            ../lib/state_manager.robot
7Resource            ../lib/boot_utils.robot
8Resource            ../lib/bmc_redfish_resource.robot
9Library             ../lib/ipmi_utils.py
10
11Test Setup          Start SOL Console Logging
12Test Teardown       Test Teardown Execution
13
14Force Tags          SOL_Test
15
16
17*** Variables ***
18
19*** Test Cases ***
20
21Set SOL Enabled
22    [Documentation]  Verify enabling SOL via IPMI.
23    [Tags]  Set_SOL_Enabled
24
25    ${msg}=  Run Keyword  Run IPMI Standard Command
26    ...  sol set enabled true
27
28    # Verify SOL status from ipmitool sol info command.
29    ${sol_info_dict}=  Get SOL Info
30    ${sol_enable_status}=  Get From Dictionary
31    ...  ${sol_info_dict}  Enabled
32
33    Should Be Equal  '${sol_enable_status}'  'true'
34
35
36Set SOL Disabled
37    [Documentation]  Verify disabling SOL via IPMI.
38    [Tags]  Set_SOL_Disabled
39
40    ${msg}=  Run Keyword  Run IPMI Standard Command
41    ...  sol set enabled false
42
43    # Verify SOL status from ipmitool sol info command.
44    ${sol_info_dict}=  Get SOL Info
45    ${sol_enable_status}=  Get From Dictionary
46    ...  ${sol_info_dict}  Enabled
47    Should Be Equal  '${sol_enable_status}'  'false'
48
49    # Verify error while activating SOL with SOL disabled.
50    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
51    ...  sol activate
52    Should Contain  ${msg}  SOL payload disabled  ignore_case=True
53
54
55Set Valid SOL Privilege Level
56    [Documentation]  Verify valid SOL's privilege level via IPMI.
57    [Tags]  Set_Valid_SOL_Privilege_Level
58
59    ${privilege_level_list}=  Create List  user  operator  admin  oem
60    : FOR  ${item}  IN  @{privilege_level_list}
61    \  Set SOL Setting  privilege-level  ${item}
62    \  ${output}=  Get SOL Setting  Privilege Level
63    \  Should Contain  ${output}  ${item}  ignore_case=True
64
65
66Set Invalid SOL Privilege Level
67    [Documentation]  Verify invalid SOL's retry count via IPMI.
68    [Tags]  Set_Invalid_SOL_Privilege_Level
69
70    ${value}=  Generate Random String  ${8}
71    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
72    ...  sol set privilege-level ${value}
73    Should Contain  ${msg}  Invalid value  ignore_case=True
74
75
76Set Invalid SOL Retry Count
77    [Documentation]  Verify invalid SOL's retry count via IPMI.
78    [Tags]  Set_Invalid_SOL_Retry_Count
79
80    # Any integer above 7 is invalid for SOL retry count.
81    ${value}=  Evaluate  random.randint(8, 10000)  modules=random
82
83    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
84    ...  sol set retry-count ${value}
85    Should Contain  ${msg}  Invalid value  ignore_case=True
86
87
88Set Invalid SOL Retry Interval
89    [Documentation]  Verify invalid SOL's retry interval via IPMI.
90    [Tags]  Set_Invalid_SOL_Retry_Interval
91
92    # Any integer above 255 is invalid for SOL retry interval.
93    ${value}=  Evaluate  random.randint(256, 10000)  modules=random
94
95    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
96    ...  sol set retry-interval ${value}
97    Should Contain  ${msg}  Invalid value  ignore_case=True
98
99
100Set Invalid SOL Character Accumulate Level
101    [Documentation]  Verify invalid SOL's character accumulate level via IPMI.
102    [Tags]  Set_Invalid_SOL_Character_Accumulate_Level
103
104    # Any integer above 255 is invalid for SOL character accumulate level.
105    ${value}=  Evaluate  random.randint(256, 10000)  modules=random
106
107    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
108    ...  sol set character-accumulate-level ${value}
109    Should Contain  ${msg}  Invalid value  ignore_case=True
110
111
112Set Invalid SOL Character Send Threshold
113    [Documentation]  Verify invalid SOL's character send threshold via IPMI.
114    [Tags]  Set_Invalid_SOL_Character_Send_Threshold
115
116    # Any integer above 255 is invalid for SOL character send threshold.
117    ${value}=  Evaluate  random.randint(256, 10000)  modules=random
118
119    ${msg}=  Run Keyword And Expect Error  *  Run IPMI Standard Command
120    ...  sol set character-send-threshold ${value}
121    Should Contain  ${msg}  Invalid value  ignore_case=True
122
123
124Verify SOL During Boot
125    [Documentation]  Verify SOL during boot.
126    [Tags]  Verify_SOL_During_Boot
127
128    Activate SOL Via IPMI
129    Redfish Power On
130
131    Check IPMI SOL Output Content  Welcome to Hostboot
132    Check IPMI SOL Output Content  ISTEP
133
134
135Verify Deactivate Non Existing SOL
136    [Documentation]  Verify deactivate non existing SOL session.
137    [Tags]  Verify_Deactivate_Non_Existing_SOL
138
139    ${resp}=  Deactivate SOL Via IPMI
140    Should Contain  ${resp}  SOL payload already de-activated
141    ...  case_insensitive=True
142
143
144Set Valid SOL Retry Count
145    [Documentation]  Verify valid SOL's retry count via IPMI.
146    [Tags]  Set_Valid_SOL_Retry_Count
147    [Template]  Verify SOL Setting
148
149    # Setting name    Min valid value    Max valid value
150    retry-count       0                  7
151
152
153Set Valid SOL Retry Interval
154    [Documentation]  Verify valid SOL's retry interval via IPMI.
155    [Tags]  Set_Valid_SOL_Retry_Interval
156    [Template]  Verify SOL Setting
157
158    # Setting name    Min valid value    Max valid value
159    retry-interval    0                  255
160
161
162Set Valid SOL Character Accumulate Level
163    [Documentation]  Verify valid SOL's character accumulate level via IPMI.
164    [Tags]  Set_Valid_SOL_Character_Accumulate_Level
165    [Template]  Verify SOL Setting
166
167    # Setting name              Min valid value    Max valid value
168    character-accumulate-level  1                  255
169
170
171Set Valid SOL Character Send Threshold
172    [Documentation]  Verify valid SOL's character send threshold via IPMI.
173    [Tags]  Set_Valid_SOL_Character_Send_Threshold
174    [Template]  Verify SOL Setting
175
176    # Setting name              Min valid value    Max valid value
177    character-send-threshold    0                  255
178
179*** Keywords ***
180
181Check IPMI SOL Output Content
182    [Documentation]  Check if SOL has given content.
183    [Arguments]  ${data}  ${file_path}=/tmp/sol_${OPENBMC_HOST}
184    # Description of argument(s):
185    # data       Content which need to be checked(e.g. Petitboot, ISTEP).
186    # file_path  The file path on the local machine to check SOL content.
187    #            By default it check SOL content from /tmp/sol_<BMC_IP>.
188
189    ${output}=  OperatingSystem.Get File  ${file_path}  encoding_errors=ignore
190    Should Contain  ${output}  ${data}  case_insensitive=True
191
192
193Verify SOL Setting
194    [Documentation]  Verify SOL Setting via IPMI.
195    [Arguments]  ${setting_name}  ${min_value}  ${max_value}
196    # Description of Arguments:
197    # setting_name    Setting to verify (e.g. "retry-count").
198    # min_value       min valid value for given setting.
199    # max_value       max valid value for given setting.
200
201    ${value}=
202    ...  Evaluate  random.randint(${min_value}, ${max_value})  modules=random
203
204    # Character accumulate level setting is set in multiples of 5.
205    # Retry interval setting is set in multiples of 10.
206    # Reference IPMI specification v2.0
207
208    ${expected_value}=  Run Keyword If
209    ...  '${setting_name}' == 'character-accumulate-level'  Evaluate  ${value}*5
210    ...  ELSE IF  '${setting_name}' == 'retry-interval'  Evaluate  ${value}*10
211    ...  ELSE  Set Variable  ${value}
212
213    Set SOL Setting  ${setting_name}  '${value}'
214
215    # Replace "-" with space " " in setting name.
216    # E.g. "retry-count" to "retry count"
217    ${setting_name}=  Evaluate  $setting_name.replace('-',' ')
218
219    ${sol_info_dict}=  Get SOL Info
220
221    # Get exact SOL setting name from sol info output.
222    ${list}=  Get Matches  ${sol_info_dict}  ${setting_name}*
223    ...  case_insensitive=${True}
224    ${setting_name_from_dict}=  Get From List  ${list}  0
225
226    # Get SOL setting value from above setting name.
227    ${setting_value}=  Get From Dictionary
228    ...  ${sol_info_dict}  ${setting_name_from_dict}
229
230    Should Be Equal  '${setting_value}'  '${expected_value}'
231
232    # Power on host to check if SOL is working fine with new setting.
233    ${current_state}=  Get Host State Via External IPMI
234    Run Keyword If  '${current_state}' == 'on'
235    ...  Initiate Host PowerOff Via External IPMI
236    Initiate Host Boot Via External IPMI  wait=${0}
237
238    Activate SOL Via IPMI
239    Wait Until Keyword Succeeds  10 mins  30 secs
240    ...  Check IPMI SOL Output Content  Welcome to Hostboot
241
242    Wait Until Keyword Succeeds  3 mins  30 secs
243    ...  Check IPMI SOL Output Content  ISTEP
244
245Get SOL Setting
246    [Documentation]  Returns status for given SOL setting.
247    [Arguments]  ${setting}
248    # Description of argument(s):
249    # setting  SOL setting which needs to be read(e.g. "Retry Count").
250
251    ${sol_info_dict}=  Get SOL Info
252    ${setting_status}=  Get From Dictionary  ${sol_info_dict}  ${setting}
253
254    [Return]  ${setting_status}
255
256
257Restore Default SOL Configuration
258    [Documentation]  Restore default SOL configuration.
259
260    Set SOL Setting  enabled  true
261    Set SOL Setting  retry-count  7
262    Set SOL Setting  retry-interval  10
263    Set SOL Setting  character-accumulate-level  20
264    Set SOL Setting  character-send-threshold  1
265    Set SOL Setting  privilege-level  user
266
267
268Test Teardown Execution
269    [Documentation]  Do the post test teardown.
270
271    Deactivate SOL Via IPMI
272    ${sol_log}=  Stop SOL Console Logging
273    Log   ${sol_log}
274    FFDC On Test Case Fail
275    Restore Default SOL Configuration
276