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