1a6be41edSchithrag*** Settings ***
2a6be41edSchithragDocumentation       This suite tests IPMI POH Counter Support in OpenBMC.
3a6be41edSchithrag...                 Feature: IPMI POH Counter Support
4a6be41edSchithrag...
56e641262SGeorge Keishing...                 POH (Power-On Hours) counter is the incremental count of power ON
66e641262SGeorge Keishing...                 hours in the system.
7a6be41edSchithrag...
8a6be41edSchithrag...                 Request and Response data defined under data/ipmi_raw_cmd_table.py
9a6be41edSchithrag...
10a6be41edSchithrag...                 Testcases added -
11a6be41edSchithrag...                 Get POH Counter Command Via IPMI
12a6be41edSchithrag...                 Verify Get POH Counter With Invalid Data Request Via IPMI
13a6be41edSchithrag...                 Verify POH Counter Reading With Wait Time
14a6be41edSchithrag...                 Verify POH Counter Reading With Host Power Off
15a6be41edSchithrag...                 Verify POH Counter Reading With Host Power On
16a6be41edSchithrag...
17a6be41edSchithrag...                 Script compares Minutes per count and Counter reading for the above scenarios.
18a6be41edSchithrag...
19a6be41edSchithrag...                 Minutes per count usually 60 minutes.
20a6be41edSchithrag...
216e641262SGeorge Keishing...                 Wait Time given - 1 hour, 1 hour 30minutes when Host power OFF, 1 hour
226e641262SGeorge Keishing...                 after Host Power ON
23a6be41edSchithrag...
246e641262SGeorge Keishing...                 Comparison between Initial POH Counter reading and reading after wait
256e641262SGeorge Keishing...                 time / Power operation.
26a6be41edSchithrag
27a6be41edSchithrag
28a6be41edSchithragResource            ../lib/ipmi_client.robot
29a6be41edSchithragResource            ../lib/openbmc_ffdc.robot
30*d0c4b800SganesanbLibrary             Collections
31*d0c4b800SganesanbLibrary             ../lib/ipmi_utils.py
32a6be41edSchithragVariables           ../data/ipmi_raw_cmd_table.py
33a6be41edSchithrag
34a6be41edSchithragSuite Setup      Suite Setup Execution
35a6be41edSchithragSuite Teardown   Suite Teardown Execution
36a6be41edSchithrag
37a6be41edSchithragTest Teardown    FFDC On Test Case Fail
38a6be41edSchithrag
39a6be41edSchithrag
40a6be41edSchithrag*** Variables ***
41a6be41edSchithrag
42a6be41edSchithrag
43a6be41edSchithrag*** Test Cases ***
44a6be41edSchithrag
45a6be41edSchithragGet POH Counter Command Via IPMI
46a6be41edSchithrag    [Documentation]  Verify get POH counter command Via IPMI.
47a6be41edSchithrag    [Tags]  Get_POH_Counter_Command_Via_IPMI
48a6be41edSchithrag
49a6be41edSchithrag    # Verify get POH counter command via IPMI.
50a6be41edSchithrag    ${resp}=  Run IPMI Command
51a6be41edSchithrag    ...  ${IPMI_RAW_CMD['Get']['POH_Counter'][0]}
52a6be41edSchithrag    Should Not Contain  ${resp}  ${IPMI_RAW_CMD['Get']['POH_Counter'][1]}
53a6be41edSchithrag
54a6be41edSchithrag
55a6be41edSchithragVerify Get POH Counter With Invalid Data Request Via IPMI
56a6be41edSchithrag    [Documentation]  Verify get POH counter with invalid data request via IPMI.
57a6be41edSchithrag    [Tags]  Verify_Get_POH_Counter_With_Invalid_Data_Request_Via_IPMI
58a6be41edSchithrag
59a6be41edSchithrag    # verify get POH counter command with invalid data request Via IPMI.
60a6be41edSchithrag    ${resp}=  Run Keyword and Expect Error  *Request data length invalid*
61a6be41edSchithrag    ...  Run IPMI Command  ${IPMI_RAW_CMD['Get']['POH_Counter'][0]} 0x00
62a6be41edSchithrag
63a6be41edSchithrag
64a6be41edSchithragVerify POH Counter Reading With Wait Time
65a6be41edSchithrag    [Documentation]  Verify POH counter reading with wait time via IPMI.
66a6be41edSchithrag    [Tags]  Verify_POH_Counter_Reading_With_Wait_Time
67a6be41edSchithrag
68a6be41edSchithrag    # Get initial POH command counter reading.
69a6be41edSchithrag    ${poh_counter_1}=  Run Get POH Command And Return Counter Reading
70a6be41edSchithrag
71a6be41edSchithrag    # Sleep for given time.
72a6be41edSchithrag    Sleep  1h
73a6be41edSchithrag
74a6be41edSchithrag    # Get POH Counter Reading after waiting for given time period.
75a6be41edSchithrag    ${poh_counter_2}=  Run Get POH Command And Return Counter Reading
76a6be41edSchithrag
77a6be41edSchithrag    # Verify difference between initial and present counter readings.
78a6be41edSchithrag    # The counter reading should always be incremented by 1 for each hour.
79a6be41edSchithrag    ${difference}=  Evaluate   ${poh_counter_2} - ${poh_counter_1}
80a6be41edSchithrag    Should Be Equal As Integers  ${difference}  1
81a6be41edSchithrag
82a6be41edSchithrag
83a6be41edSchithragVerify POH Counter Reading With Host Power Off
84a6be41edSchithrag    [Documentation]  Verify POH counter reading with wait time after host power off.
85a6be41edSchithrag    [Tags]  Verify_POH_Counter_Reading_With_Host_Power_Off
86a6be41edSchithrag
87a6be41edSchithrag    # Get initial POH command counter reading.
88a6be41edSchithrag    ${poh_counter_1}=  Run Get POH Command And Return Counter Reading
89a6be41edSchithrag
90a6be41edSchithrag    # Power off the system.
91a6be41edSchithrag    IPMI Power Off
92a6be41edSchithrag
93a6be41edSchithrag    # Sleep for given time.
94a6be41edSchithrag    Sleep  1 hours 30 minutes
95a6be41edSchithrag
96a6be41edSchithrag    # Get POH counter reading after waiting for given time period.
97a6be41edSchithrag    ${poh_counter_2}=  Run Get POH Command And Return Counter Reading
98a6be41edSchithrag
99a6be41edSchithrag    # Once the system is powered off,
100a6be41edSchithrag    # the poh counter reading should not increment.
101a6be41edSchithrag    Should Be Equal As Integers  ${poh_counter_2}  ${poh_counter_1}
102a6be41edSchithrag
103a6be41edSchithrag
104a6be41edSchithragVerify POH Counter Reading With Host Power On
105a6be41edSchithrag    [Documentation]  Verify Get POH Counter with wait time after host power on.
106a6be41edSchithrag    [Tags]  Verify_POH_Counter_Reading_With_Host_Power_On
107a6be41edSchithrag
108a6be41edSchithrag    # Get initial POH command counter reading.
109a6be41edSchithrag    ${poh_counter_1}=  Run Get POH Command And Return Counter Reading
110a6be41edSchithrag
111a6be41edSchithrag    # Power on the system.
112a6be41edSchithrag    IPMI Power On
113a6be41edSchithrag
114a6be41edSchithrag    # Sleep for given time.
115a6be41edSchithrag    Sleep  1h
116a6be41edSchithrag
117a6be41edSchithrag    # Get POH Counter reading after waiting for given time period.
118a6be41edSchithrag    ${poh_counter_2}=  Run Get POH Command And Return Counter Reading
119a6be41edSchithrag
120a6be41edSchithrag    # Once the system is powered on,
121a6be41edSchithrag    # the pon counter reading should increment by 1.
122a6be41edSchithrag    ${difference}=  Evaluate   ${poh_counter_2} - ${poh_counter_1}
123a6be41edSchithrag    Should Be Equal As Integers  ${difference}  1
124a6be41edSchithrag
125a6be41edSchithrag
126a6be41edSchithrag*** Keywords ***
127a6be41edSchithrag
128a6be41edSchithragRun Get POH Command And Return Counter Reading
129a6be41edSchithrag    [Documentation]  Run the IPMI command to Get POH Counter.
130a6be41edSchithrag
131a6be41edSchithrag    # Get POH counter Via IPMI.
132a6be41edSchithrag    ${resp}=  Run IPMI Command
133a6be41edSchithrag    ...  ${IPMI_RAW_CMD['Get']['POH_Counter'][0]}
134a6be41edSchithrag
135a6be41edSchithrag    # Verify Minutes per count.
136a6be41edSchithrag    ${data}=  Split String  ${resp}
137a6be41edSchithrag    Should Be Equal  ${data[0]}  3c
138a6be41edSchithrag
139a6be41edSchithrag    # Get POH Command counter reading.
140a6be41edSchithrag    ${poh_counter_reading}=  Set Variable  ${data[1:]}
141a6be41edSchithrag    Reverse List  ${poh_counter_reading}
142a6be41edSchithrag    ${poh_counter_reading}=  Evaluate  "".join(${poh_counter_reading})
143a6be41edSchithrag    ${poh_counter_reading}=  Convert To Integer  ${poh_counter_reading}  16
144a6be41edSchithrag
145a6be41edSchithrag    [Return]  ${poh_counter_reading}
146a6be41edSchithrag
147a6be41edSchithrag
148a6be41edSchithragSuite Setup Execution
149a6be41edSchithrag    [Documentation]  Suite Setup Execution.
150a6be41edSchithrag
151a6be41edSchithrag    Redfish.Login
152a6be41edSchithrag
153a6be41edSchithrag    # Check Host current status.
154a6be41edSchithrag    ${current_host_state}=  Get Host State Via Redfish
155a6be41edSchithrag
156a6be41edSchithrag    # If Host state is 'On' then the condition will not be executed.
157a6be41edSchithrag    # Host may take approx 5 - 6 minutes to complete power ON process.
158a6be41edSchithrag    Run Keyword If  '${current_host_state}' == 'Off'
159a6be41edSchithrag    ...  IPMI Power On
160a6be41edSchithrag
161a6be41edSchithrag
162a6be41edSchithragSuite Teardown Execution
163a6be41edSchithrag    [Documentation]  Suite Teardown Execution.
164a6be41edSchithrag
165a6be41edSchithrag    IPMI Power On
166a6be41edSchithrag    Redfish.Logout
167