MCPcopy
hub / github.com/tsenart/vegeta / TestAttackDuration

Function TestAttackDuration

lib/attack_test.go:43–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestAttackDuration(t *testing.T) {
44 t.Parallel()
45 server := httptest.NewServer(
46 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}),
47 )
48 defer server.Close()
49
50 tr := NewStaticTargeter(Target{Method: "GET", URL: server.URL})
51 atk := NewAttacker()
52 rate := Rate{Freq: 100, Per: time.Second}
53
54 var m Metrics
55 for res := range atk.Attack(tr, rate, rate.Per, "") {
56 m.Add(res)
57 }
58 m.Close()
59
60 if got, want := m.Requests, uint64(rate.Freq); got != want {
61 t.Errorf("got %v hits, want: %v", got, want)
62 } else if got, want := m.Duration.Round(time.Second), time.Second; got != want {
63 t.Errorf("got duration %s, want %s", got, want)
64 }
65}
66
67func TestTLSConfig(t *testing.T) {
68 atk := NewAttacker()

Callers

nothing calls this directly

Calls 6

AttackMethod · 0.95
AddMethod · 0.95
CloseMethod · 0.95
NewStaticTargeterFunction · 0.85
NewAttackerFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected