1*** Settings ***
2Documentation  Test IPMI FRU data.
3
4Resource               ../lib/ipmi_client.robot
5Resource               ../lib/openbmc_ffdc.robot
6Library                ../lib/ipmi_utils.py
7
8
9Suite Setup            Suite Setup Execution
10Suite Teardown         Suite Teardown Execution
11Test Teardown          Test Teardown Execution
12
13
14*** Variables ***
15&{ipmi_redfish_fru_field_map}  board_serial=SerialNumber  board_part_number=PartNumber
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      Exit For Loop IF    "${value}" == "${EMPTY}"
81      Should Contain  ${redfish_fru_component_obj['${value}']}
82      ...  ${ipmi_fru_component_obj['${key}']}
83      ...  msg=Comparison failed.
84    END
85
86
87Suite Setup Execution
88    [Documentation]  Do test setup initialization.
89
90    ${fru_objs}=  Get Fru Info
91    Set Suite Variable  ${fru_objs}
92    Redfish.Login
93
94
95Suite Teardown Execution
96    [Documentation]  Do the post suite teardown.
97
98    Redfish.Logout
99
100
101Test Teardown Execution
102    [Documentation]  Do the post test teardown.
103
104    FFDC On Test Case Fail