Skip to content

Commit

Permalink
fix: test flakyness by changing sleeps and speedup test (#2541)
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs authored Aug 22, 2023
1 parent d2ea47f commit 9a3c595
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions filters/auth/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ func TestWebhook(t *testing.T) {
}))
defer backend.Close()

d := 100 * time.Millisecond
authServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ti.timeout {
time.Sleep(time.Second + time.Millisecond)
time.Sleep(2 * d)
}

if r.Method != "GET" {
Expand Down Expand Up @@ -91,7 +92,7 @@ func TestWebhook(t *testing.T) {
}))
defer authServer.Close()

spec := NewWebhook(time.Second)
spec := NewWebhook(d)

args := []interface{}{
"http://" + authServer.Listener.Addr().String(),
Expand All @@ -103,8 +104,7 @@ func TestWebhook(t *testing.T) {

_, err := spec.CreateFilter(args)
if err != nil {
t.Errorf("error creating filter for %s: %v", ti.msg, err)
return
t.Fatalf("error creating filter for %s: %v", ti.msg, err)
}

fr := make(filters.Registry)
Expand Down

0 comments on commit 9a3c595

Please sign in to comment.