ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Module to test dcmi management controller functionality. |
| 3 | Resource ../../lib/ipmi_client.robot |
| 4 | Resource ../../lib/openbmc_ffdc.robot |
| 5 | Resource ../../lib/bmc_network_utils.robot |
| 6 | Resource ../../lib/boot_utils.robot |
| 7 | Resource ../../lib/bmc_redfish_utils.robot |
| 8 | Variables ../../data/ipmi_raw_cmd_table.py |
| 9 | Variables ../../data/dcmi_raw_cmd_table.py |
| 10 | Variables ../../data/ipmi_variable.py |
| 11 | Library ../../lib/ipmi_utils.py |
| 12 | Library ../../lib/utilities.py |
| 13 | Library ../../lib/utils.py |
| 14 | Library JSONLibrary |
| 15 | |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 16 | Force Tags DCMI_Management_Controller |
| 17 | |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 18 | *** Variables *** |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 19 | |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 20 | ${hostname_file_path} /etc/hostname |
| 21 | |
| 22 | *** Test Cases *** |
| 23 | Validate IPMI Response Length |
| 24 | [Documentation] Check ipmi response length. |
| 25 | [Tags] Validate_IPMI_Response_Length |
| 26 | |
| 27 | ${rsp}= Get DCMI Management Controller Identifier String |
| 28 | @{ipmi_cmd_rsp_list}= Split String ${rsp} |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 29 | # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03", |
| 30 | # "04", "05", "06", "07", "08", "09"] |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 31 | # rsp_length = 10 |
| 32 | # string_length = 0a |
| 33 | ${rsp_length}= Get Length ${ipmi_cmd_rsp_list[2:]} |
| 34 | ${string_length}= Get Response Length In Hex ${rsp_length} |
| 35 | |
| 36 | # ipmi_cmd_rsp_list[1] = 0a |
| 37 | # string_length = 0a |
| 38 | # the above condition is equal. |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 39 | # suppose if string_length and ipmi_cmd_rsp_list[1] not matches |
| 40 | # then it will fails. |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 41 | Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length} |
| 42 | ... msg=Id string length in ipmi response is showing wrongly |
| 43 | |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 44 | Test Hostname Is Same With Management Controller Identifier String |
| 45 | [Documentation] Check hostname was verified with get management |
| 46 | ... controller identifier string. |
| 47 | [Tags] Test_Hostname_Is_Same_With_Management_Controller_Identifier_String |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 48 | |
| 49 | ${rsp}= Get DCMI Management Controller Identifier String |
| 50 | @{ipmi_cmd_rsp_list}= Split String ${rsp} |
| 51 | ${bmc_console_hostname_bytes_list}= Get Hostname From BMC Console |
| 52 | |
| 53 | Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${bmc_console_hostname_bytes_list} |
| 54 | ... msg=response get from dcmi get mcid cmd and hostname from "cat /etc/os-release" cmd is not same. |
| 55 | |
| 56 | Test Get Management Controller Identifier String |
| 57 | [Documentation] Validate set and get mcid string. |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 58 | [Tags] Test_Get_Management_Controller_Identifier_String |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 59 | [Setup] Get Default MCID |
| 60 | [Teardown] Set Default MCID |
| 61 | |
| 62 | # Set Hostname via DCMI Management Controller Identifier String Command. |
| 63 | ${cmd_rsp}= Set DCMI Management Controller Identifier String |
| 64 | @{cmd_rsp_list}= Split String ${cmd_rsp} |
| 65 | Run Keyword And Continue On Failure |
| 66 | ... Valid Value cmd_rsp_list[1] valid_values=['${number_of_bytes_to_write}'] |
| 67 | |
| 68 | ${rsp}= Get DCMI Management Controller Identifier String |
| 69 | @{ipmi_cmd_rsp_list}= Split String ${rsp} |
| 70 | |
| 71 | # Verify number of bytes that was set and id string length are same. |
| 72 | ${string_length}= Get Response Length In Hex ${random_int} |
| 73 | Run Keyword And Continue On Failure |
| 74 | ... Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length} |
| 75 | ... msg=Number of bytes that was set and id string length are not same. |
| 76 | |
| 77 | # Verify ID String Length and data. |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 78 | # ipmi_cmd_rsp_list = ["00", "0a", "00", "01", "02", "03", "04", |
| 79 | # "05", "06", "07", "08", "09"] |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 80 | # rsp_length = 10 |
| 81 | # string_length = 0a |
| 82 | # ipmi_cmd_rsp_list[1] = 0a |
| 83 | # ipmi_cmd_rsp_list[1] is equal to string_length |
| 84 | # the above condition is equal. |
George Keishing | c6185fa | 2023-05-30 14:54:59 +0530 | [diff] [blame] | 85 | # suppose if string_length and ipmi_cmd_rsp_list[1] not matches then |
| 86 | # it will fails. |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 87 | ${rsp_length}= Get Length ${ipmi_cmd_rsp_list[2:]} |
| 88 | ${string_length}= Get Response Length In Hex ${rsp_length} |
| 89 | Run Keyword And Continue On Failure |
| 90 | ... Should Be Equal As Strings ${ipmi_cmd_rsp_list[1]} ${string_length} |
| 91 | ... msg=Id string length in ipmi response is showing wrongly |
| 92 | |
| 93 | # Verify get dcmi management controller identifier string command response |
| 94 | # and the bytes used for Set DCMI MCID string. |
| 95 | ${set_dcmi_mcid_cmd}= |
| 96 | ... convert_prefix_hex_list_to_non_prefix_hex_list ${string_hex_list} |
| 97 | Run Keyword And Continue On Failure |
| 98 | ... Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${set_dcmi_mcid_cmd} |
| 99 | ... msg=Bytes given in dcmi set mcid command and string bytes got from dcmi get mcid command are not same |
| 100 | |
| 101 | # Verify Hostname of cat /etc/hostname and get dcmi management controller identifier string command. |
| 102 | ${bytes_list}= Get Hostname From BMC Console |
| 103 | Run Keyword And Continue On Failure |
| 104 | ... Lists Should Be Equal ${ipmi_cmd_rsp_list[2:]} ${bytes_list} |
| 105 | ... msg=Bytes got from dcmi get mcid command and hostname from "cat /etc/os-release" command is not same. |
| 106 | |
| 107 | *** Keywords *** |
| 108 | Get Default MCID |
| 109 | [Documentation] Get default mcid. |
| 110 | |
| 111 | ${default_mcid}= Get DCMI Management Controller Identifier String |
| 112 | Set Test Variable ${default_mcid} |
| 113 | |
| 114 | Set Default MCID |
| 115 | [Documentation] Set default mcid. |
| 116 | |
| 117 | @{ipmi_cmd_rsp_list}= Split String ${default_mcid} |
| 118 | ${number_of_bytes_to_write}= Set Variable ${ipmi_cmd_rsp_list[1]} |
| 119 | ${bytes_in_int}= Convert To Integer ${number_of_bytes_to_write} 16 |
| 120 | ${bytes_to_write}= Evaluate ${bytes_in_int} + 1 |
| 121 | ${no_of_bytes_to_write}= Get Response Length In Hex ${bytes_to_write} |
| 122 | @{tmp_lst}= Create List |
| 123 | FOR ${bytes} IN @{ipmi_cmd_rsp_list[2:]} |
| 124 | Append To List ${tmp_lst} 0x${bytes} |
| 125 | END |
| 126 | ${default_hex}= Catenate @{tmp_lst} |
| 127 | |
| 128 | ${cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']} |
| 129 | ... 0x${no_of_bytes_to_write} ${default_hex} |
| 130 | Run External IPMI Raw Command ${cmd} |
| 131 | |
| 132 | Get DCMI Management Controller Identifier String |
| 133 | [Documentation] Get DCMI MCID String. |
| 134 | |
| 135 | ${mcid_get_cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['GET']} |
KManimozhi123 | e44a601 | 2024-03-13 10:50:46 +0000 | [diff] [blame^] | 136 | ${resp}= Run IPMI Command ${mcid_get_cmd} |
Wilson Suen | 8bd0130 | 2023-12-04 18:38:56 -0800 | [diff] [blame] | 137 | ${resp}= Strip String ${resp} mode=right characters=${SPACE}00\n |
ganesanb | 5502e3e | 2022-12-13 11:07:43 +0000 | [diff] [blame] | 138 | |
| 139 | [Return] ${resp} |
| 140 | |
| 141 | Set DCMI Management Controller Identifier String |
| 142 | [Documentation] Set DCMI MCID String. |
| 143 | |
| 144 | # 16 bytes maximum as per dcmi spec |
| 145 | ${random_int}= Evaluate random.randint(1, 15) modules=random |
| 146 | ${random_string}= Generate Random String ${random_int} |
| 147 | ${string_hex_list}= convert_name_into_bytes_with_prefix ${random_string} |
| 148 | ${random_hex}= Catenate @{string_hex_list} |
| 149 | ${number_of_random_string}= Evaluate ${random_int} + 1 |
| 150 | ${number_of_bytes_to_write}= Get Response Length In Hex ${number_of_random_string} |
| 151 | |
| 152 | ${mcid_set_cmd}= Catenate ${DCMI_RAW_CMD['DCMI']['MANAGEMENT_CONTROLLER_IDENTIFIER_STRING']['SET']} |
| 153 | ... 0x${number_of_bytes_to_write} ${random_hex} 0x00 |
| 154 | ${resp}= Run External IPMI Raw Command ${mcid_set_cmd} |
| 155 | |
| 156 | Set Test Variable ${string_hex_list} |
| 157 | Set Test Variable ${random_int} |
| 158 | Set Test Variable ${number_of_bytes_to_write} |
| 159 | |
| 160 | [Return] ${resp} |
| 161 | |
| 162 | Get Hostname From BMC Console |
| 163 | [Documentation] Get hostname. |
| 164 | |
| 165 | ${cmd}= Catenate cat ${hostname_file_path} |
| 166 | ${bmc_hostname}= BMC Execute Command ${cmd} |
| 167 | ${name}= Convert To List ${bmc_hostname} |
| 168 | ${hostname_bytes}= convert_name_into_bytes_without_prefix ${name[0]} |
| 169 | |
| 170 | [Return] ${hostname_bytes} |
| 171 | |
| 172 | Get Response Length In Hex |
| 173 | [Documentation] Get response length in hex. |
| 174 | [Arguments] ${resp_length} |
| 175 | |
| 176 | ${length}= Convert To Hex ${resp_length} |
| 177 | ${length_1}= Get Length ${length} |
| 178 | ${length_2}= Set Variable IF |
| 179 | ... '${length_1}' == '1' 0${length} |
| 180 | ... '${length_1}' != '1' ${length} |
| 181 | ${resp_length_3}= Convert To Lower Case ${length_2} |
| 182 | |
| 183 | [Return] ${resp_length_3} |