Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite is used for testing the error logging |
| 3 | ... capability from the host |
| 4 | |
| 5 | Resource ../lib/rest_client.robot |
| 6 | Resource ../lib/utils.robot |
| 7 | |
| 8 | |
| 9 | Library BuiltIn |
| 10 | Library Collections |
| 11 | Library SSHLibrary |
| 12 | |
| 13 | *** Variables *** |
| 14 | &{NIL} data=@{EMPTY} |
| 15 | ${SYSTEM_SHUTDOWN_TIME} 1min |
| 16 | ${WAIT_FOR_SERVICES_UP} 3min |
| 17 | |
| 18 | *** Test Cases *** |
| 19 | |
| 20 | valid path to logs |
| 21 | [Documentation] Test list all events |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 22 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | ${resp} = openbmc get request /org/openbmc/records/events/ |
| 24 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 25 | |
| 26 | clear any logs |
| 27 | [Documentation] Test delete all events |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 28 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 29 | ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL} |
| 30 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 31 | ${resp} = openbmc get request /org/openbmc/records/events/ |
| 32 | ${json} = to json ${resp.content} |
| 33 | Should Be Empty ${json['data']} |
| 34 | |
| 35 | write a log |
| 36 | [Documentation] Test create event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 37 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 38 | create a test log |
| 39 | |
| 40 | Message attribute should match |
| 41 | [Documentation] Check message attribute for created event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 42 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 43 | ${uri} = create a test log |
| 44 | ${content} = Read Attribute ${uri} message |
| 45 | Should Be Equal ${content} A Test event log just happened |
| 46 | |
| 47 | Severity attribute should match |
| 48 | [Documentation] Check severity attribute for created event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 49 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 50 | ${uri} = create a test log |
| 51 | ${content}= Read Attribute ${uri} severity |
| 52 | Should Be Equal ${content} Info |
| 53 | |
| 54 | data_bytes attribute should match |
| 55 | [Documentation] Check data_bytes attribute for created event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 56 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 57 | @{data_list} = Create List ${48} ${0} ${19} ${127} ${136} ${255} |
| 58 | ${uri} = create a test log |
| 59 | ${content} = Read Attribute ${uri} debug_data |
| 60 | Lists Should Be Equal ${content} ${data_list} |
| 61 | |
| 62 | delete the log |
| 63 | [Documentation] Test the delete event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 64 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 65 | ${uri} = create a test log |
| 66 | ${deluri} = catenate SEPARATOR= ${uri} /action/delete |
| 67 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 68 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 69 | ${resp} = openbmc get request ${deluri} |
| 70 | should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND} |
| 71 | |
| 72 | 2nd delete should fail |
| 73 | [Documentation] Negative scnenario to delete already deleted event |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 74 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 75 | ${uri} = create a test log |
| 76 | ${deluri} = catenate SEPARATOR= ${uri} /action/delete |
| 77 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 78 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 79 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 80 | should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND} |
| 81 | |
| 82 | Intermixed delete |
| 83 | [Documentation] This testcase is for excersicing caching impleted, |
| 84 | ... Steps: |
| 85 | ... write three logs |
| 86 | ... delete middle log |
| 87 | ... middle log should not exist |
| 88 | ... time stamp should not match between logs(1st and 3rd) |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 89 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 90 | ${event1}= create a test log |
| 91 | ${event2}= create a test log |
| 92 | ${event3}= create a test log |
| 93 | ${deluri} = catenate SEPARATOR= ${event2} /action/delete |
| 94 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 95 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 96 | ${time_event1}= Read Attribute ${event1} time |
| 97 | ${time_event3}= Read Attribute ${event3} time |
| 98 | should not be equal ${time_event1} ${time_event3} |
| 99 | |
| 100 | restarting event process retains logs |
| 101 | [Documentation] This is to test events are in place even after the |
| 102 | ... event service is restarted. |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 103 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 104 | ${resp} = openbmc get request /org/openbmc/records/events/ |
| 105 | ${json} = to json ${resp.content} |
| 106 | ${logs_pre_restart}= set variable ${json['data']} |
| 107 | |
| 108 | Open Connection And Log In |
| 109 | ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service |
| 110 | Sleep ${10} |
| 111 | |
| 112 | ${resp} = openbmc get request /org/openbmc/records/events/ |
| 113 | ${json} = to json ${resp.content} |
| 114 | ${logs_post_restart}= set variable ${json['data']} |
| 115 | List Should Contain Sub List ${logs_post_restart} ${logs_pre_restart} msg=Failed to find all the eventlogs which are present before restart of event service |
| 116 | |
| 117 | deleting log after obmc-phosphor-event.service restart |
| 118 | [Documentation] This is to test event can be deleted created prior to |
| 119 | ... event service is restarted. |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 120 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 121 | ${uri}= create a test log |
| 122 | |
| 123 | Open Connection And Log In |
| 124 | ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service |
| 125 | Sleep ${10} |
| 126 | |
| 127 | ${deluri} = catenate SEPARATOR= ${uri} /action/delete |
| 128 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 129 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 130 | |
| 131 | makeing new log after obmc-phosphor-event.service restart |
| 132 | [Documentation] This is for testing event creation after the |
| 133 | ... event service is restarted. |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 134 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 135 | Open Connection And Log In |
| 136 | ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service |
| 137 | Sleep ${10} |
| 138 | |
| 139 | create a test log |
| 140 | |
| 141 | deleting new log after obmc-phosphor-event.service restart |
| 142 | [Documentation] This testcase is for testing deleted newly created event |
| 143 | ... after event service is restarted. |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 144 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 145 | Open Connection And Log In |
| 146 | ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service |
| 147 | Sleep ${10} |
| 148 | |
| 149 | ${uri}= create a test log |
| 150 | ${deluri} = catenate SEPARATOR= ${uri} /action/delete |
| 151 | ${resp} = openbmc post request ${deluri} data=${NIL} |
| 152 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 153 | |
| 154 | Test events after openbmc reboot |
| 155 | [Documentation] This is to test event can be deleted created prior to |
| 156 | ... openbmc reboot |
| 157 | ... Steps: |
| 158 | ... Create event, |
| 159 | ... Reboot openbmc, |
| 160 | ... Events should exist post reboot, |
| 161 | ... Create two more events, |
| 162 | ... Delete old and new event |
| 163 | [Tags] reboot_tests |
| 164 | ${pre_reboot_event}= create a test log |
| 165 | |
| 166 | Open Connection And Log In |
| 167 | ${output}= Execute Command /sbin/reboot |
| 168 | Sleep ${SYSTEM_SHUTDOWN_TIME} |
| 169 | Wait For Host To Ping ${OPENBMC_HOST} |
| 170 | Sleep ${WAIT_FOR_SERVICES_UP} |
| 171 | |
| 172 | ${resp} = openbmc get request ${pre_reboot_event} |
| 173 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 174 | ${post_reboot_event1}= create a test log |
| 175 | ${post_reboot_event2}= create a test log |
| 176 | |
| 177 | ${del_prereboot_uri} = catenate SEPARATOR= ${pre_reboot_event} /action/delete |
| 178 | ${resp} = openbmc post request ${del_prereboot_uri} data=${NIL} |
| 179 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 180 | ${del_postreboot_uri} = catenate SEPARATOR= ${post_reboot_event1} /action/delete |
| 181 | ${resp} = openbmc post request ${del_postreboot_uri} data=${NIL} |
| 182 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 183 | |
| 184 | clearing logs results in no logs |
| 185 | [Documentation] This testcase is for clearning the events when no logs present |
Chris Austen | 859be60 | 2016-07-07 16:46:31 -0500 | [diff] [blame^] | 186 | [Tags] CI |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 187 | ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL} |
| 188 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 189 | ${resp} = openbmc get request /org/openbmc/records/events/ |
| 190 | ${json} = to json ${resp.content} |
| 191 | Should Be Empty ${json['data']} |
| 192 | ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL} |
| 193 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 194 | |
| 195 | |
| 196 | *** Keywords *** |
| 197 | |
| 198 | create a test log |
| 199 | [arguments] |
| 200 | ${data} = create dictionary data=@{EMPTY} |
| 201 | ${resp} = openbmc post request /org/openbmc/records/events/action/acceptTestMessage data=${data} |
| 202 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 203 | ${json} = to json ${resp.content} |
| 204 | ${LOGID} = convert to integer ${json['data']} |
| 205 | ${uri}= catenate SEPARATOR= /org/openbmc/records/events/ ${LOGID} |
| 206 | [return] ${uri} |
| 207 | |
| 208 | Open Connection And Log In |
| 209 | Open connection ${OPENBMC_HOST} |
| 210 | Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |