Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test IPMI FRU data. |
| 3 | |
| 4 | Resource ../../lib/rest_client.robot |
| 5 | Resource ../../lib/ipmi_client.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | Resource ../../lib/boot_utils.robot |
| 8 | Library ../../lib/ipmi_utils.py |
| 9 | |
| 10 | Variables ../data/ipmi_rest_fru_field_map.py |
| 11 | |
| 12 | Test Teardown Test Teardown Execution |
| 13 | Suite Setup Suite Setup Execution |
| 14 | |
| 15 | |
| 16 | *** Test Cases *** |
| 17 | |
| 18 | Test FRU Info At Power On |
| 19 | [Documentation] Verify FRU info via IPMI and REST at power on. |
| 20 | [Tags] Test_FRU_Info_At_Power_On |
| 21 | [Template] Verify FRU Info |
| 22 | |
| 23 | # component_name |
| 24 | cpu |
| 25 | dimm |
| 26 | fan |
| 27 | bmc |
| 28 | system |
| 29 | powersupply |
| 30 | gv100card |
| 31 | |
| 32 | |
| 33 | *** Keywords *** |
| 34 | |
| 35 | Get Component Fru Info Via REST |
| 36 | [Documentation] Get FRU Information Via REST for the given component. |
| 37 | [Arguments] ${component_name} |
| 38 | |
| 39 | # Description of argument(s): |
| 40 | # component_name The name of the component (e.g. "cpu", "dimm", etc.). |
| 41 | |
| 42 | ${inventory_uris}= Read Properties ${HOST_INVENTORY_URI}list quiet=${1} |
| 43 | # From the inventory_uris, select just the ones for the component of |
| 44 | # interest. |
| 45 | ${component_uris}= Get Matches ${inventory_uris} |
Michael Walsh | d917c6e | 2018-12-11 10:09:09 -0600 | [diff] [blame] | 46 | ... regexp=^.*[0-9a-z_].${component_name}\[0-9]*$ |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 47 | |
| 48 | # Get the component information for each record. |
| 49 | ${component_frus}= Create List |
Sushil Singh | be97ffc | 2019-06-04 06:34:24 -0500 | [diff] [blame] | 50 | FOR ${component_uri} IN @{component_uris} |
| 51 | ${result}= Read Properties ${component_uri} quiet=${1} |
| 52 | ${component}= Fetch From Right ${component_uri} / |
| 53 | Set To Dictionary ${result} fru_device_description ${component} |
| 54 | Append To List ${component_frus} ${result} |
| 55 | END |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 56 | [Return] ${component_frus} |
| 57 | |
| 58 | |
| 59 | Verify FRU Info |
| 60 | [Documentation] Verify FRU information of given component. |
| 61 | [Arguments] ${component_name} |
| 62 | |
| 63 | # Description of argument(s): |
| 64 | # component_name The name of the component (e.g. "cpu", "dimm", etc.). |
| 65 | |
| 66 | ${ipmi_fru_component_info}= Get Component FRU Info ${component_name} |
| 67 | ... ${fru_objs} |
| 68 | # Example of output from "Get Component FRU Info" keyword for CPU component. |
| 69 | # |
| 70 | # ipmi_fru_info: |
| 71 | # ipmi_fru_info[0]: |
| 72 | # [fru_device_description]: cpu0 (ID 1) |
| 73 | # [board_mfg_date]: Sun Dec 31 18:00:00 1995 |
| 74 | # [board_mfg]: <Manufacturer Name> |
| 75 | # [board_product]: PROCESSOR MODULE |
| 76 | # [board_serial]: YA1934301835 |
| 77 | # [board_part_number]: 02CY211 |
| 78 | # ipmi_fru_info[1]: |
| 79 | # [fru_device_description]: cpu1 (ID 2) |
| 80 | # [board_mfg_date]: Sun Dec 31 18:00:00 1995 |
| 81 | # [board_mfg]: <Manufacturer Name> |
| 82 | # [board_product]: PROCESSOR MODULE |
| 83 | # [board_serial]: YA1934301834 |
| 84 | # [board_part_number]: 02CY211 |
| 85 | |
| 86 | ${rest_fru_component_info}= Get Component FRU Info Via REST |
| 87 | ... ${component_name} |
| 88 | # Example of output from "Get Component FRU Info Via REST" keyword for |
| 89 | # CPU component. |
| 90 | # |
| 91 | # rest_fru_info: |
| 92 | # rest_fru_info[0]: |
| 93 | # [FieldReplaceable]: 1 |
| 94 | # [BuildDate]: 1996-01-01 - 00:00:00 |
| 95 | # [fru_device_description]: cpu0 |
| 96 | # [Cached]: 0 |
| 97 | # [SerialNumber]: YA1934301835 |
| 98 | # [Functional]: 1 |
| 99 | # [Version]: 22 |
| 100 | # [Model]: <blank> |
| 101 | # [PrettyName]: PROCESSOR MODULE |
| 102 | # [PartNumber]: 02CY211 |
| 103 | # [Present]: 1 |
| 104 | # [Manufacturer]: <Manufacturer Name> |
| 105 | # rest_fru_info[1]: |
| 106 | # [FieldReplaceable]: 1 |
| 107 | # [BuildDate]: 1996-01-01 - 00:00:00 |
| 108 | # [fru_device_description]: cpu1 |
| 109 | # [Cached]: 0 |
| 110 | # [SerialNumber]: YA1934301834 |
| 111 | # [Functional]: 1 |
| 112 | # [Version]: 22 |
| 113 | # [Model]: <blank> |
| 114 | # [PrettyName]: PROCESSOR MODULE |
| 115 | # [PartNumber]: 02CY211 |
| 116 | # [Present]: 1 |
| 117 | # [Manufacturer]: <Manufacturer Name> |
| 118 | |
| 119 | ${inventory_uris}= Read Properties |
| 120 | ... ${HOST_INVENTORY_URI}list quiet=${1} |
| 121 | |
| 122 | # From the inventory_uris, select just the ones for the component of |
| 123 | # interest. Example for cpu: |
| 124 | # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0 |
| 125 | # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1 |
| 126 | ${component_uris}= Get Matches ${inventory_uris} |
Michael Walsh | d917c6e | 2018-12-11 10:09:09 -0600 | [diff] [blame] | 127 | ... regexp=^.*[0-9a-z_].${component_name}\[0-9]*$ |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 128 | |
Sushil Singh | be97ffc | 2019-06-04 06:34:24 -0500 | [diff] [blame] | 129 | FOR ${uri} IN @{component_uris} |
| 130 | ${sub_component}= Fetch From Right ${uri} / |
| 131 | ${ipmi_index}= Get Index Of FRU Sub Component Info |
| 132 | ... ${ipmi_fru_component_info} ${sub_component} |
| 133 | ${rest_index}= Get Index Of FRU Sub Component Info |
| 134 | ... ${rest_fru_component_info} ${sub_component} |
| 135 | ${ipmi_fru_sub_component}= |
| 136 | ... Get From List ${ipmi_fru_component_info} ${ipmi_index} |
| 137 | ${rest_fru_sub_component}= |
| 138 | ... Get From List ${rest_fru_component_info} ${rest_index} |
| 139 | Compare IPMI And REST FRU Component Info ${ipmi_fru_sub_component} |
| 140 | ... ${rest_fru_sub_component} ${component_name} |
| 141 | END |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 142 | |
| 143 | |
| 144 | Get Index Of FRU Sub Component Info |
| 145 | [Documentation] Get index of FRU sub component info from FRU component |
| 146 | ... data. |
| 147 | [Arguments] ${fru_component_info} ${sub_component} |
| 148 | # fru_component_info FRU component data as a list of dictionaries. |
| 149 | # ipmi_cpu_fru_info[0]: |
| 150 | # fru_device_description: cpu0 (ID 1) |
| 151 | # board_mfg_date: Sun Dec 31 18:00:00 1995 |
| 152 | # board_mfg: <Manufacturer Name> |
| 153 | # board_product: PROCESSOR MODULE |
| 154 | # board_serial: YA1934302970 |
| 155 | # board_part_number: 02CY211 |
| 156 | # ipmi_cpu_fru_info[1]: |
| 157 | # fru_device_description: cpu1 (ID 2) |
| 158 | # board_mfg_date: Sun Dec 31 18:00:00 1995 |
| 159 | # board_mfg: <Manufacturer Name> |
| 160 | # board_product: PROCESSOR MODULE |
| 161 | # board_serial: YA1934302965 |
| 162 | # board_part_number: 02CY211 |
| 163 | # sub_component Sub component name (e.g. "cpu0", "cpu1", etc.). |
| 164 | |
| 165 | ${sub_component_count}= Get Length ${fru_component_info} |
| 166 | ${index}= Set Variable ${0} |
| 167 | |
Sushil Singh | be97ffc | 2019-06-04 06:34:24 -0500 | [diff] [blame] | 168 | FOR ${rest_fru_sub_component} IN @{fru_component_info} |
| 169 | ${fru_component_section}= |
| 170 | ... Get From List ${fru_component_info} ${index} |
| 171 | # Get FRU name from IPMI's fru_device_description field. |
| 172 | # Example "cpu0" from "cpu0 (ID 1)". |
| 173 | ${fru_name}= Fetch From Left |
| 174 | ... ${fru_component_section['fru_device_description']} ${SPACE} |
| 175 | ${status}= Run Keyword And Return Status Should Be Equal |
| 176 | ... ${fru_name} ${sub_component} |
| 177 | Exit For Loop If '${status}' == '${True}' |
| 178 | ${index}= Evaluate ${index} + 1 |
| 179 | Exit For Loop If ${index} >= ${sub_component_count} |
| 180 | END |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 181 | [Return] ${index} |
| 182 | |
| 183 | |
| 184 | Compare IPMI And REST FRU Component Info |
| 185 | [Documentation] Compare IPMI And REST FRU Component data objects. |
| 186 | [Arguments] ${ipmi_fru_component_obj} ${rest_fru_component_obj} |
| 187 | ... ${component_name} |
| 188 | |
| 189 | # Description of argument(s): |
| 190 | # ipmi_fru_component_obj IPMI FRU component data in dictionary. |
| 191 | # Example: |
| 192 | # fru_device_description: cpu0 (ID 1) |
| 193 | # board_mfg_date: Sun Dec 31 18:00:00 1995 |
| 194 | # board_mfg: <Manufacturer Name> |
| 195 | # board_product: PROCESSOR MODULE |
| 196 | # board_serial: YA1934302970 |
| 197 | # board_part_number: 02CY211 |
| 198 | # rest_fru_component_obj REST FRU component data in dictionary. |
| 199 | # Example: |
| 200 | # FieldReplaceable: 1 |
| 201 | # BuildDate: 1996-01-01 - 00:00:00 |
| 202 | # Cached: 0 |
| 203 | # SerialNumber: YA1934302970 |
| 204 | # Functional: 1 |
| 205 | # Version: 22 |
| 206 | # Model: <blank> |
| 207 | # PrettyName: PROCESSOR MODULE |
| 208 | # PartNumber: 02CY211 |
| 209 | # Present: 1 |
| 210 | # Manufacturer: <Manufacturer Name> |
| 211 | # component_name The name of the component (e.g. "cpu", "dimm", etc.). |
| 212 | |
| 213 | # Get key_map from ipmi_rest_fru_field_map. |
| 214 | ${key_map}= Set Variable ${ipmi_rest_fru_field_map['${component_name}']} |
Sushil Singh | be97ffc | 2019-06-04 06:34:24 -0500 | [diff] [blame] | 215 | FOR ${ipmi_key} IN @{ipmi_rest_fru_field_map['${component_name}'].keys()} |
| 216 | ${rest_key}= Set Variable ${key_map['${ipmi_key}']} |
| 217 | Should Contain ${rest_fru_component_obj['${rest_key}']} |
| 218 | ... ${ipmi_fru_component_obj['${ipmi_key}']} |
| 219 | ... msg=Comparison failed. |
| 220 | END |
Rahul Maheshwari | 35aa8d5 | 2018-03-11 23:56:51 -0500 | [diff] [blame] | 221 | |
| 222 | |
| 223 | Test Teardown Execution |
| 224 | [Documentation] Do the post test teardown. |
| 225 | |
| 226 | FFDC On Test Case Fail |
| 227 | |
| 228 | |
| 229 | Suite Setup Execution |
| 230 | [Documentation] Do test setup initialization. |
| 231 | |
| 232 | REST Power On stack_mode=skip quiet=1 |
| 233 | ${fru_objs}= Get Fru Info |
| 234 | Set Suite Variable ${fru_objs} |
| 235 | |