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}  product_serial=SerialNumber  product_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  ${COMPONENT_NAME_OF_POWER_SUPPLY}
25    ...  ${fru_objs}
26
27    # Redfish FRU info.
28    ${redfish_power_details}=  Redfish.Get Members List  /redfish/v1/Chassis/${CHASSIS_ID}/PowerSubsystem/PowerSupplies
29    ${redfish_power_dict}=  Create List
30    FOR  ${power_supply}  IN  @{redfish_power_details}
31        ${redfish_power_supply_reading}=  Redfish.Get Properties  ${power_supply}
32        Append To List  ${redfish_power_dict}  ${redfish_power_supply_reading}
33    END
34    Verify IPMI and Redfish subcomponents  ${redfish_power_dict}
35    ...  ${ipmi_fru_component_info}
36
37*** Keywords ***
38
39Verify IPMI and Redfish subcomponents
40    [Documentation]  Get IPMI And Redfish subcomponents of FRU and verify.
41    [Arguments]  ${redfish_fru_info}  ${ipmi_fru_info}
42
43    # Description of argument(s):
44    # ${ipmi_fru_info}       IPMI FRU component values.
45    # ${redfish_fru_info}    Redfish FRU component values.
46
47    ${sub_component_count}=  Get Length  ${redfish_fru_info}
48
49    # Fetch each subcomponent value of IPMI and Redfish and compare.
50    FOR  ${sub_component_index}  IN RANGE  0  ${sub_component_count}
51      ${ipmi_fru_sub_component}=
52      ...  Get From List  ${ipmi_fru_info}  ${sub_component_index}
53      ${redfish_fru_sub_component}=
54      ...  Get From List  ${redfish_fru_info}  ${sub_component_index}
55      Compare IPMI And Redfish FRU Component  ${ipmi_fru_sub_component}
56      ...  ${redfish_fru_sub_component}
57    END
58
59
60Compare IPMI And Redfish FRU Component
61    [Documentation]  Compare IPMI And Redfish FRU Component data objects.
62    [Arguments]  ${ipmi_fru_component_obj}  ${redfish_fru_component_obj}
63
64    # Description of argument(s):
65    # ${ipmi_fru_component_obj}  IPMI FRU component data in dictionary.
66    # Example:
67    # FRU Device Description : powersupply0 (ID 75)
68    # Board Mfg Date        : Sun Dec 31 18:00:00 1995
69    # Board Product         : powersupply0
70    # Board Serial          : 71G303
71    # Board Part Number     : 01KL471
72    # ${redfish_fru_component_obj}  Redfish FRU component data in dictionary.
73    # Example:
74    # "Name": "powersupply0",
75    # "PartNumber": "01KL471",
76    # "PowerInputWatts": 114.0,
77    # "SerialNumber": "71G303",
78
79    # Get key_map from ipmi_redfish_fru_field_map.
80    ${key_map}=  Get Dictionary Items   ${ipmi_redfish_fru_field_map}
81
82    FOR    ${key}    ${value}    IN    @{key_map}
83      Exit For Loop IF    "${value}" == "${EMPTY}"
84      Should Contain  ${redfish_fru_component_obj['${value}']}
85      ...  ${ipmi_fru_component_obj['${key}']}
86      ...  msg=Comparison failed.
87    END
88
89
90Suite Setup Execution
91    [Documentation]  Do test setup initialization.
92
93    ${status}  ${fru_objs}=  Run Keyword And Ignore Error  Get Fru Info
94    Log To Console  FRU: ${fru_objs}
95    Set Suite Variable  ${fru_objs}
96    Redfish.Login
97
98
99Suite Teardown Execution
100    [Documentation]  Do the post suite teardown.
101
102    Redfish.Logout
103
104
105Test Teardown Execution
106    [Documentation]  Do the post test teardown.
107
108    FFDC On Test Case Fail
109