1*** Settings ***
2Documentation  Test IPMI FRU data.
3
4Resource               ../lib/openbmc_ffdc.robot
5Library                ../lib/ipmi_utils.py
6
7
8Suite Setup            Suite Setup Execution
9Suite Teardown         Suite Teardown Execution
10Test Teardown          Test Teardown Execution
11
12
13*** Variables ***
14&{ipmi_redfish_fru_field_map}  board_serial=SerialNumber  board_part_number=PartNumber
15...  board_product=Name
16
17*** Test Cases ***
18
19Test FRU Info Of Power Supplies
20    [Documentation]  Verify FRU info of power supply via IPMI and Redfish.
21    [Tags]  Test_FRU_Info_Of_Power_Supplies
22
23    # IPMI FRU info.
24    ${ipmi_fru_component_info}=  Get Component FRU Info  powersupply
25    ...  ${fru_objs}
26
27    # Redfish FRU info.
28    ${redfish_power_details}=  Redfish.Get Properties  /redfish/v1/Chassis/chassis/Power
29    ${redfish_power_supply_reading}=  Set Variable  ${redfish_power_details['PowerSupplies']}
30
31    Verify IPMI and Redfish subcomponents  ${redfish_power_supply_reading}
32    ...  ${ipmi_fru_component_info}
33
34*** Keywords ***
35
36Verify IPMI and Redfish subcomponents
37    [Documentation]  Get IPMI And Redfish subcomponents of FRU and verify.
38    [Arguments]  ${redfish_fru_info}  ${ipmi_fru_info}
39
40    # Description of argument(s):
41    # ${ipmi_fru_info}       IPMI FRU component values.
42    # ${redfish_fru_info}    Redfish FRU component values.
43
44    ${sub_component_count}=  Get Length  ${redfish_fru_info}
45
46    # Fetch each subcomponent value of IPMI and Redfish and compare.
47    FOR  ${sub_component_index}  IN RANGE  0  ${sub_component_count}
48      ${ipmi_fru_sub_component}=
49      ...  Get From List  ${ipmi_fru_info}  ${sub_component_index}
50      ${redfish_fru_sub_component}=
51      ...  Get From List  ${redfish_fru_info}  ${sub_component_index}
52      Compare IPMI And Redfish FRU Component  ${ipmi_fru_sub_component}
53      ...  ${redfish_fru_sub_component}
54    END
55
56
57Compare IPMI And Redfish FRU Component
58    [Documentation]  Compare IPMI And Redfish FRU Component data objects.
59    [Arguments]  ${ipmi_fru_component_obj}  ${redfish_fru_component_obj}
60
61    # Description of argument(s):
62    # ${ipmi_fru_component_obj}  IPMI FRU component data in dictionary.
63    # Example:
64    # FRU Device Description : powersupply0 (ID 75)
65    # Board Mfg Date        : Sun Dec 31 18:00:00 1995
66    # Board Product         : powersupply0
67    # Board Serial          : 71G303
68    # Board Part Number     : 01KL471
69    # ${redfish_fru_component_obj}  Redfish FRU component data in dictionary.
70    # Example:
71    # "Name": "powersupply0",
72    # "PartNumber": "01KL471",
73    # "PowerInputWatts": 114.0,
74    # "SerialNumber": "71G303",
75
76    # Get key_map from ipmi_redfish_fru_field_map.
77    ${key_map}=  Get Dictionary Items   ${ipmi_redfish_fru_field_map}
78
79    FOR    ${key}    ${value}    IN    @{key_map}
80      Should Contain  ${redfish_fru_component_obj['${value}']}
81      ...  ${ipmi_fru_component_obj['${key}']}
82      ...  msg=Comparison failed.
83    END
84
85
86Suite Setup Execution
87    [Documentation]  Do test setup initialization.
88
89    ${fru_objs}=  Get Fru Info
90    Set Suite Variable  ${fru_objs}
91    Redfish.Login
92
93
94Suite Teardown Execution
95    [Documentation]  Do the post suite teardown.
96
97    Redfish.Logout
98
99
100Test Teardown Execution
101    [Documentation]  Do the post test teardown.
102
103    FFDC On Test Case Fail
104