Skip to content

Commit

Permalink
wait
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain committed Sep 18, 2024
1 parent 710173f commit f077721
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/e2e/tests/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
package tests

import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/util/wait"
"net"
"testing"
"time"

"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -139,9 +142,14 @@ var RateLimitHeaderMatchTest = suite.ConformanceTest{
t.Errorf("failed to get expected response for the last (fourth) request: %v", err)
}

curCount, err := OverLimitCount(suite)
err = wait.PollUntilContextTimeout(context.TODO(), time.Second, 1*time.Minute, true, func(_ context.Context) (bool, error) {
curCount, err := OverLimitCount(suite)
if err != nil {
return false, err
}
return curCount > preCount, nil
})
require.NoError(t, err)
require.Greater(t, curCount, preCount)
})

t.Run("only one matched header cannot got limited", func(t *testing.T) {
Expand Down

0 comments on commit f077721

Please sign in to comment.