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...  board_product=Name
17
18*** Test Cases ***
19
20Test FRU Info Of Power Supplies
21    [Documentation]  Verify FRU info of power supply via IPMI and Redfish.
22    [Tags]  Test_FRU_Info_Of_Power_Supplies
23
24    # IPMI FRU info.
25    ${ipmi_fru_component_info}=  Get Component FRU Info  powersupply
26    ...  ${fru_objs}
27
28    # Redfish FRU info.
29    ${redfish_power_details}=  Redfish.Get Properties  /redfish/v1/Chassis/chassis/Power
30    ${redfish_power_supply_reading}=  Set Variable  ${redfish_power_details['PowerSupplies']}
31
32    Verify IPMI and Redfish subcomponents  ${redfish_power_supply_reading}
33    ...  ${ipmi_fru_component_info}
34
35*** Keywords ***
36
37Verify IPMI and Redfish subcomponents
38    [Documentation]  Get IPMI And Redfish subcomponents of FRU and verify.
39    [Arguments]  ${redfish_fru_info}  ${ipmi_fru_info}
40
41    # Description of argument(s):
42    # ${ipmi_fru_info}       IPMI FRU component values.
43    # ${redfish_fru_info}    Redfish FRU component values.
44
45    ${sub_component_count}=  Get Length  ${redfish_fru_info}
46
47    # Fetch each subcomponent value of IPMI and Redfish and compare.
48    FOR  ${sub_component_index}  IN RANGE  0  ${sub_component_count}
49      ${ipmi_fru_sub_component}=
50      ...  Get From List  ${ipmi_fru_info}  ${sub_component_index}
51      ${redfish_fru_sub_component}=
52      ...  Get From List  ${redfish_fru_info}  ${sub_component_index}
53      Compare IPMI And Redfish FRU Component  ${ipmi_fru_sub_component}
54      ...  ${redfish_fru_sub_component}
55    END
56
57
58Compare IPMI And Redfish FRU Component
59    [Documentation]  Compare IPMI And Redfish FRU Component data objects.
60    [Arguments]  ${ipmi_fru_component_obj}  ${redfish_fru_component_obj}
61
62    # Description of argument(s):
63    # ${ipmi_fru_component_obj}  IPMI FRU component data in dictionary.
64    # Example:
65    # FRU Device Description : powersupply0 (ID 75)
66    # Board Mfg Date        : Sun Dec 31 18:00:00 1995
67    # Board Product         : powersupply0
68    # Board Serial          : 71G303
69    # Board Part Number     : 01KL471
70    # ${redfish_fru_component_obj}  Redfish FRU component data in dictionary.
71    # Example:
72    # "Name": "powersupply0",
73    # "PartNumber": "01KL471",
74    # "PowerInputWatts": 114.0,
75    # "SerialNumber": "71G303",
76
77    # Get key_map from ipmi_redfish_fru_field_map.
78    ${key_map}=  Get Dictionary Items   ${ipmi_redfish_fru_field_map}
79
80    FOR    ${key}    ${value}    IN    @{key_map}
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
105