Skip to content

Commit

Permalink
proxy: speedup TestBackendRatelimitScenarios (#2561)
Browse files Browse the repository at this point in the history
Reuse redis instance for multiple tests.

Before
```
$ go test ./proxy -short -count=1 -run=TestBackendRatelimitScenarios
ok      github.com/zalando/skipper/proxy        9.700s
```

After:
```
ok      github.com/zalando/skipper/proxy        2.510s
```

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Sep 1, 2023
1 parent 79d98b1 commit b6f0d65
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions proxy/backendratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func TestBackendRatelimitRoundRobin(t *testing.T) {
}

func TestBackendRatelimitScenarios(t *testing.T) {
// Use shared instance for all tests.
// If this test flakes because of backend IP reuse between test cases,
// implement database cleanup, see https://redis.io/commands/flushdb/.
redisAddr, done := redistest.NewTestRedis(t)
defer done()

for _, ti := range []struct {
name string
routes string
Expand Down Expand Up @@ -180,9 +186,6 @@ func TestBackendRatelimitScenarios(t *testing.T) {
filterRegistry := builtin.MakeRegistry()
filterRegistry.Register(ratelimitfilters.NewBackendRatelimit())

redisAddr, done := redistest.NewTestRedis(t)
defer done()

ratelimitRegistry := ratelimit.NewSwarmRegistry(nil, &snet.RedisOptions{Addrs: []string{redisAddr}})
defer ratelimitRegistry.Close()

Expand Down

0 comments on commit b6f0d65

Please sign in to comment.