MCPcopy
hub / github.com/etcd-io/etcd / SetupHTTP

Method SetupHTTP

tests/framework/e2e/etcd_process.go:370–400  ·  view source on GitHub ↗
(ctx context.Context, failpoint, payload string)

Source from the content-addressed store, hash-verified

368}
369
370func (f *BinaryFailpoints) SetupHTTP(ctx context.Context, failpoint, payload string) error {
371 host := fmt.Sprintf("127.0.0.1:%d", f.member.Config().GoFailPort)
372 failpointURL := url.URL{
373 Scheme: "http",
374 Host: host,
375 Path: failpoint,
376 }
377 r, err := http.NewRequestWithContext(ctx, http.MethodPut, failpointURL.String(), bytes.NewBuffer([]byte(payload)))
378 if err != nil {
379 return err
380 }
381 httpClient := http.Client{
382 Timeout: 1 * time.Second,
383 }
384 if f.clientTimeout != 0 {
385 httpClient.Timeout = f.clientTimeout
386 }
387 resp, err := httpClient.Do(r)
388 if err != nil {
389 return err
390 }
391 defer resp.Body.Close()
392 if resp.StatusCode != http.StatusNoContent {
393 errMsg, err := io.ReadAll(resp.Body)
394 if err != nil {
395 return fmt.Errorf("bad status code: %d, err: %w", resp.StatusCode, err)
396 }
397 return fmt.Errorf("bad status code: %d, err: %s", resp.StatusCode, errMsg)
398 }
399 return nil
400}
401
402func (f *BinaryFailpoints) DeactivateHTTP(ctx context.Context, failpoint string) error {
403 host := fmt.Sprintf("127.0.0.1:%d", f.member.Config().GoFailPort)

Callers 13

TestDefragNoSpaceFunction · 0.80
testLeaseRevokeIssueFunction · 0.80
triggerDefragFunction · 0.80
TestReproduce17780Function · 0.80
TestIssue20271Function · 0.80
triggerSlowApplyFunction · 0.80
triggerRaftLoopDeadLockFunction · 0.80
InjectMethod · 0.80

Calls 6

ReadAllMethod · 0.80
ConfigMethod · 0.65
StringMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by 11

TestDefragNoSpaceFunction · 0.64
testLeaseRevokeIssueFunction · 0.64
triggerDefragFunction · 0.64
TestReproduce17780Function · 0.64
TestIssue20271Function · 0.64
triggerSlowApplyFunction · 0.64
triggerRaftLoopDeadLockFunction · 0.64