MCPcopy
hub / github.com/etcd-io/bbolt / activeFailpoint

Function activeFailpoint

tests/robustness/powerfailure_test.go:217–231  ·  view source on GitHub ↗

activeFailpoint actives the failpoint by http.

(t *testing.T, targetUrl string, fpName, fpVal string)

Source from the content-addressed store, hash-verified

215
216// activeFailpoint actives the failpoint by http.
217func activeFailpoint(t *testing.T, targetUrl string, fpName, fpVal string) {
218 u, err := url.JoinPath(targetUrl, fpName)
219 require.NoError(t, err, "parse url %s", targetUrl)
220
221 req, err := http.NewRequest("PUT", u, bytes.NewBuffer([]byte(fpVal)))
222 require.NoError(t, err)
223
224 resp, err := http.DefaultClient.Do(req)
225 require.NoError(t, err)
226 defer resp.Body.Close()
227
228 data, err := io.ReadAll(resp.Body)
229 require.NoError(t, err)
230 require.Equal(t, 204, resp.StatusCode, "response body: %s", string(data))
231}
232
233// FlakeyDevice extends dmflakey.Flakey interface.
234type FlakeyDevice interface {

Callers 1

doPowerFailureFunction · 0.85

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected