Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This module provides general keywords for dump. |
| 3 | |
Rahul Maheshwari | 1612ac9 | 2017-08-30 14:42:32 -0500 | [diff] [blame] | 4 | Library bmc_ssh_utils.py |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 5 | |
| 6 | *** Variables *** |
| 7 | |
| 8 | *** Keywords *** |
| 9 | |
| 10 | Create User Initiated Dump |
| 11 | [Documentation] Generate user initiated dump and return |
| 12 | ... dump id (e.g 1, 2 etc). |
| 13 | |
| 14 | ${data}= Create Dictionary data=@{EMPTY} |
| 15 | ${resp}= OpenBMC Post Request |
George Keishing | 8d69338 | 2018-12-18 12:15:04 -0600 | [diff] [blame] | 16 | ... ${DUMP_URI}action/CreateDump data=${data} |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 17 | |
| 18 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 19 | ${json}= To JSON ${resp.content} |
George Keishing | 73c4ebf | 2017-11-13 07:10:28 -0600 | [diff] [blame] | 20 | |
| 21 | # REST "CreateDump" JSON response. |
| 22 | # { |
| 23 | # "data": null, |
| 24 | # "message": "200 OK", |
| 25 | # "status": "ok" |
| 26 | # } |
| 27 | Run Keyword If ${json["data"]} == ${None} |
| 28 | ... Fail Dump id returned null. |
| 29 | |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 30 | ${dump_id}= Set Variable ${json["data"]} |
| 31 | |
Rahul Maheshwari | e2cd17f | 2017-09-26 21:26:50 -0500 | [diff] [blame] | 32 | Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 33 | ... ${dump_id} |
| 34 | |
| 35 | [Return] ${dump_id} |
| 36 | |
| 37 | |
Rahul Maheshwari | 953038b | 2017-10-17 05:08:59 -0500 | [diff] [blame] | 38 | Verify No Dump In Progress |
| 39 | [Documentation] Verify no dump in progress. |
| 40 | |
Rahul Maheshwari | 4cfdc39 | 2017-10-25 09:44:47 -0500 | [diff] [blame] | 41 | ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp |
| 42 | Should Not Contain ${dump_progress} obmcdump |
Rahul Maheshwari | 953038b | 2017-10-17 05:08:59 -0500 | [diff] [blame] | 43 | |
| 44 | |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 45 | Check Dump Existence |
| 46 | [Documentation] Verify if given dump exist. |
| 47 | [Arguments] ${dump_id} |
| 48 | |
| 49 | # Description of Argument(s): |
| 50 | # dump_id An integer value that identifies a particular dump |
| 51 | # object(e.g. 1, 3, 5). |
| 52 | |
George Keishing | 8d69338 | 2018-12-18 12:15:04 -0600 | [diff] [blame] | 53 | ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id} |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 54 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 55 | |
| 56 | |
| 57 | Delete BMC Dump |
| 58 | [Documentation] Deletes a given bmc dump. |
| 59 | [Arguments] ${dump_id} |
| 60 | |
| 61 | # Description of Argument(s): |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 62 | # dump_id An integer value that identifies a particular dump (e.g. 1, 3). |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 63 | |
| 64 | ${data}= Create Dictionary data=@{EMPTY} |
| 65 | ${resp}= OpenBMC Post Request |
George Keishing | 8d69338 | 2018-12-18 12:15:04 -0600 | [diff] [blame] | 66 | ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data} |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 67 | |
| 68 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 69 | |
| 70 | Delete All Dumps |
| 71 | [Documentation] Delete all dumps. |
| 72 | |
| 73 | # Check if dump entries exist, if not return. |
George Keishing | 6a6e76d | 2017-09-14 08:19:17 -0500 | [diff] [blame] | 74 | ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1} |
Rahul Maheshwari | ad676bf | 2017-06-22 15:06:05 -0500 | [diff] [blame] | 75 | Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} |
| 76 | |
| 77 | # Get the list of dump entries and delete them all. |
| 78 | ${dump_entries}= Get URL List ${DUMP_ENTRY_URI} |
| 79 | :FOR ${entry} IN @{dump_entries} |
| 80 | \ ${dump_id}= Fetch From Right ${entry} / |
| 81 | \ Delete BMC Dump ${dump_id} |
George Keishing | c9fcd09 | 2017-09-20 09:24:37 -0500 | [diff] [blame] | 82 | |
| 83 | |
| 84 | Delete All BMC Dump |
| 85 | [Documentation] Delete all BMC dump entries using "DeleteAll" interface. |
| 86 | |
| 87 | ${data}= Create Dictionary data=@{EMPTY} |
| 88 | ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data} |
| 89 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
George Keishing | dc42876 | 2017-11-11 12:37:12 -0600 | [diff] [blame] | 90 | |
George Keishing | dc42876 | 2017-11-11 12:37:12 -0600 | [diff] [blame] | 91 | Dump Should Not Exist |
| 92 | [Documentation] Verify that BMC dumps do not exist. |
| 93 | |
George Keishing | 8d69338 | 2018-12-18 12:15:04 -0600 | [diff] [blame] | 94 | ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1} |
George Keishing | dc42876 | 2017-11-11 12:37:12 -0600 | [diff] [blame] | 95 | Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} |
| 96 | |
Sivas SRR | 7aabd79 | 2017-10-18 21:28:23 -0500 | [diff] [blame] | 97 | Check Existence of BMC Dump file |
| 98 | [Documentation] Verify existence of BMC dump file. |
| 99 | [Arguments] ${dump_id} |
| 100 | |
| 101 | # Description of argument(s): |
| 102 | # dump_id BMC dump identifier |
| 103 | |
| 104 | ${dump_check_cmd}= Set Variable |
| 105 | ... ls /var/lib/phosphor-debug-collector/dumps |
| 106 | |
| 107 | # Output of sample BMC Execute command with '2' as dump id is as follows |
| 108 | # ls /var/lib/phosphor-debug-collector/dumps/2 |
| 109 | # obmcdump_2_XXXXXXXXXX.tar.xz |
| 110 | ${file_there} ${stderr} ${rc}= BMC Execute Command |
| 111 | ... ${dump_check_cmd}/${dump_id} |
| 112 | Should End With ${file_there} tar.xz msg=BMC dump file not found. |
Rahul Maheshwari | 1612ac9 | 2017-08-30 14:42:32 -0500 | [diff] [blame] | 113 | |
| 114 | Get Dump Entries |
| 115 | [Documentation] Return dump entries list. |
| 116 | |
| 117 | ${dump_entries}= Get URL List ${DUMP_ENTRY_URI} |
| 118 | [Return] ${dump_entries} |
| 119 | |
| 120 | |
| 121 | Trigger Core Dump |
| 122 | [Documentation] Trigger core dump. |
| 123 | |
| 124 | # Find the pid of the active ipmid and kill it. |
George Keishing | bfd5c8f | 2018-07-11 10:27:28 -0500 | [diff] [blame] | 125 | ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' | |
Rahul Maheshwari | 1612ac9 | 2017-08-30 14:42:32 -0500 | [diff] [blame] | 126 | ... egrep -v grep | \ cut -c1-6) |
| 127 | |
| 128 | ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf} |
| 129 | Should Be Empty ${stderr} msg=BMC execute command error. |
| 130 | Should Be Equal As Integers ${rc} ${0} |
| 131 | ... msg=BMC execute command return code is not zero. |