blob: 02e263e752f9a7010bdbbe7b6ce20918b8ffc87e [file] [log] [blame]
Rahul Maheshwariad676bf2017-06-22 15:06:05 -05001*** Settings ***
2Documentation This module provides general keywords for dump.
3
Rahul Maheshwari1612ac92017-08-30 14:42:32 -05004Library bmc_ssh_utils.py
Rahul Maheshwariad676bf2017-06-22 15:06:05 -05005
6*** Variables ***
7
8*** Keywords ***
9
10Create User Initiated Dump
11 [Documentation] Generate user initiated dump and return
Steven Sombara011c022019-01-16 18:13:52 -060012 ... the dump id number (e.g., "5"). Optionally return EMPTY
13 ... if out of dump space.
14 [Arguments] ${check_out_of_space}=${False}
15
16 # Description of Argument(s):
17 # check_out_of_space If ${False}, a dump will be created and
18 # its dump_id will be returned.
19 # If ${True}, either the dump_id will be
20 # returned, or the value ${EMPTY} will be
21 # returned if out of dump space was
22 # detected when creating the dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050023
24 ${data}= Create Dictionary data=@{EMPTY}
25 ${resp}= OpenBMC Post Request
Steven Sombara011c022019-01-16 18:13:52 -060026 ... ${DUMP_URI}action/CreateDump data=${data} quiet=${1}
27
28 Run Keyword If '${check_out_of_space}' == '${False}'
29 ... Run Keyword And Return Get The Dump Id ${resp}
30 ... ELSE Run Keyword And Return Check For Too Many Dumps ${resp}
31
32
33Get The Dump Id
34 [Documentation] Wait for the dump to be created. Return the
35 ... dump id number (e.g., "5").
36 [Arguments] ${resp}
37
38 # Description of Argument(s):
39 # resp Response object from action/Create Dump attempt.
40 # Example object:
41 # {
42 # "data": 5,
43 # "message": "200 OK",
44 # "status": "ok"
45 # },
46 # The "data" field conveys the id number of the created dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050047
48 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
49 ${json}= To JSON ${resp.content}
George Keishing73c4ebf2017-11-13 07:10:28 -060050
George Keishing73c4ebf2017-11-13 07:10:28 -060051 Run Keyword If ${json["data"]} == ${None}
52 ... Fail Dump id returned null.
53
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050054 ${dump_id}= Set Variable ${json["data"]}
55
Rahul Maheshwarie2cd17f2017-09-26 21:26:50 -050056 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050057 ... ${dump_id}
58
59 [Return] ${dump_id}
60
61
Steven Sombara011c022019-01-16 18:13:52 -060062Check For Too Many Dumps
63 [Documentation] Return the dump_id number, or return ${EMPTY} if dump
64 ... creation failed due to too many dumps.
65 [Arguments] ${resp}
66
67 # Description of Argument(s):
68 # resp Response object from action/Create Dump attempt.
69 # Example object if there are too many dumps:
George Keishing506756e2019-08-06 01:07:55 -050070 # {
Steven Sombara011c022019-01-16 18:13:52 -060071 # "data": {
George Keishing506756e2019-08-06 01:07:55 -050072 # "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded"
73 # },
74 # "message": "Dump not captured due to a cap.",
Steven Sombara011c022019-01-16 18:13:52 -060075 # "status": "error"
George Keishing506756e2019-08-06 01:07:55 -050076 # }
Steven Sombara011c022019-01-16 18:13:52 -060077
78 # If dump was created normally, return the dump_id number.
79 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
80 ... Run Keyword And Return Get The Dump Id ${resp}
81
George Keishing506756e2019-08-06 01:07:55 -050082 ${json}= To JSON ${resp.content}
83 ${exception}= Set Variable ${json["message"]}
Steven Sombara011c022019-01-16 18:13:52 -060084 ${at_capacity}= Set Variable Dump not captured due to a cap
85 ${too_many_dumps}= Evaluate $at_capacity in $exception
Michael Walshc108e422019-03-28 12:27:18 -050086 Printn
Steven Sombara011c022019-01-16 18:13:52 -060087 Rprint Vars exception too_many_dumps
88 # If there are too many dumps, return ${EMPTY}, otherwise Fail.
89 ${status}= Run Keyword If ${too_many_dumps} Set Variable ${EMPTY}
90 ... ELSE Fail msg=${exception}.
91
92 [Return] ${status}
93
94
Rahul Maheshwari953038b2017-10-17 05:08:59 -050095Verify No Dump In Progress
96 [Documentation] Verify no dump in progress.
97
Rahul Maheshwari4cfdc392017-10-25 09:44:47 -050098 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp
99 Should Not Contain ${dump_progress} obmcdump
Rahul Maheshwari953038b2017-10-17 05:08:59 -0500100
101
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500102Check Dump Existence
103 [Documentation] Verify if given dump exist.
104 [Arguments] ${dump_id}
105
106 # Description of Argument(s):
107 # dump_id An integer value that identifies a particular dump
108 # object(e.g. 1, 3, 5).
109
George Keishing8d693382018-12-18 12:15:04 -0600110 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500111 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
112
113
114Delete BMC Dump
115 [Documentation] Deletes a given bmc dump.
116 [Arguments] ${dump_id}
117
118 # Description of Argument(s):
Gunnar Mills28e403b2017-10-25 16:16:38 -0500119 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500120
121 ${data}= Create Dictionary data=@{EMPTY}
122 ${resp}= OpenBMC Post Request
George Keishing8d693382018-12-18 12:15:04 -0600123 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500124
125 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
126
127Delete All Dumps
128 [Documentation] Delete all dumps.
129
130 # Check if dump entries exist, if not return.
George Keishing6a6e76d2017-09-14 08:19:17 -0500131 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500132 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
133
134 # Get the list of dump entries and delete them all.
135 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
136 :FOR ${entry} IN @{dump_entries}
137 \ ${dump_id}= Fetch From Right ${entry} /
138 \ Delete BMC Dump ${dump_id}
George Keishingc9fcd092017-09-20 09:24:37 -0500139
140
141Delete All BMC Dump
142 [Documentation] Delete all BMC dump entries using "DeleteAll" interface.
143
144 ${data}= Create Dictionary data=@{EMPTY}
145 ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data}
146 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingdc428762017-11-11 12:37:12 -0600147
George Keishingdc428762017-11-11 12:37:12 -0600148Dump Should Not Exist
149 [Documentation] Verify that BMC dumps do not exist.
150
George Keishing8d693382018-12-18 12:15:04 -0600151 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
George Keishingdc428762017-11-11 12:37:12 -0600152 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
153
Sivas SRR7aabd792017-10-18 21:28:23 -0500154Check Existence of BMC Dump file
155 [Documentation] Verify existence of BMC dump file.
156 [Arguments] ${dump_id}
157
158 # Description of argument(s):
159 # dump_id BMC dump identifier
160
161 ${dump_check_cmd}= Set Variable
162 ... ls /var/lib/phosphor-debug-collector/dumps
163
164 # Output of sample BMC Execute command with '2' as dump id is as follows
165 # ls /var/lib/phosphor-debug-collector/dumps/2
166 # obmcdump_2_XXXXXXXXXX.tar.xz
167 ${file_there} ${stderr} ${rc}= BMC Execute Command
168 ... ${dump_check_cmd}/${dump_id}
169 Should End With ${file_there} tar.xz msg=BMC dump file not found.
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500170
171Get Dump Entries
172 [Documentation] Return dump entries list.
173
174 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
175 [Return] ${dump_entries}
176
177
178Trigger Core Dump
179 [Documentation] Trigger core dump.
180
181 # Find the pid of the active ipmid and kill it.
George Keishingbfd5c8f2018-07-11 10:27:28 -0500182 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' |
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500183 ... egrep -v grep | \ cut -c1-6)
184
185 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf}
186 Should Be Empty ${stderr} msg=BMC execute command error.
187 Should Be Equal As Integers ${rc} ${0}
188 ... msg=BMC execute command return code is not zero.