Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-02 13:00:45 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-10 14:48:28 +0300
commitdd79c72017823c44b9381885b9c54037ea4ed83b (patch)
treea8f13dfa7b91e52b02ccc1862e43d2adfa46c705 /client
parent1de88e4247d4b940f843003781cb2bf75582b826 (diff)
tests: Remove unneeded usage of `ContextWithTimeout()`
There's a bunch of tests which use `ContextWithTimeout()` without them really requiring it. We do not want to benchmark how fast the system under test is, and the timeouts may cause flaky tests on busy and/or slow machines. Remove usage of `ContextWithTimeout()` from tests which don't need it.
Diffstat (limited to 'client')
-rw-r--r--client/pool_test.go30
1 files changed, 13 insertions, 17 deletions
diff --git a/client/pool_test.go b/client/pool_test.go
index d07994168..3b02b81a7 100644
--- a/client/pool_test.go
+++ b/client/pool_test.go
@@ -5,7 +5,6 @@ import (
"net"
"sync"
"testing"
- "time"
grpcmw "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/stretchr/testify/assert"
@@ -42,7 +41,7 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, insecure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
},
},
{
@@ -51,7 +50,7 @@ func TestPoolDial(t *testing.T) {
for i := 0; i < 10; i++ {
conn, err := pool.Dial(ctx, insecure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
}
},
},
@@ -60,13 +59,13 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, insecure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
require.NoError(t, pool.Close())
conn, err = pool.Dial(ctx, insecure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
},
},
{
@@ -97,7 +96,7 @@ func TestPoolDial(t *testing.T) {
defer wg.Done()
conn, err := pool.Dial(ctx, insecure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
}()
}
@@ -109,7 +108,7 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, secure, creds)
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
},
},
{
@@ -117,7 +116,7 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, secure, "invalid-credential")
require.NoError(t, err)
- verifyConnection(t, conn, codes.PermissionDenied)
+ verifyConnection(t, ctx, conn, codes.PermissionDenied)
},
},
{
@@ -125,7 +124,7 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, secure, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.Unauthenticated)
+ verifyConnection(t, ctx, conn, codes.Unauthenticated)
},
},
{
@@ -136,7 +135,7 @@ func TestPoolDial(t *testing.T) {
test: func(t *testing.T, ctx context.Context, pool *Pool) {
conn, err := pool.Dial(ctx, secure, "") // no creds here
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK) // auth passes
+ verifyConnection(t, ctx, conn, codes.OK) // auth passes
},
},
{
@@ -165,7 +164,7 @@ func TestPoolDial(t *testing.T) {
require.NoError(t, pool.Close())
}()
- ctx, cancel := testhelper.Context(testhelper.ContextWithTimeout(time.Second))
+ ctx, cancel := testhelper.Context()
defer cancel()
tc.test(t, ctx, pool)
@@ -215,12 +214,9 @@ func runServerWithAddr(t *testing.T, creds, addr string) (*health.Server, string
}
}
-func verifyConnection(t *testing.T, conn *grpc.ClientConn, expectedCode codes.Code) {
+func verifyConnection(t *testing.T, ctx context.Context, conn *grpc.ClientConn, expectedCode codes.Code) {
t.Helper()
- ctx, cancel := context.WithTimeout(context.Background(), time.Second)
- defer cancel()
-
_, err := grpc_health_v1.NewHealthClient(conn).Check(ctx, &grpc_health_v1.HealthCheckRequest{})
if expectedCode == codes.OK {
@@ -243,7 +239,7 @@ func TestPool_Dial_same_addr_another_token(t *testing.T) {
// all good - server is running and serving requests
conn, err := pool.Dial(ctx, addr, "")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
stop1() // stop the server and all open connections
stop1 = func() {}
@@ -258,5 +254,5 @@ func TestPool_Dial_same_addr_another_token(t *testing.T) {
// all good - another server with token verification is running on the same address and new connection was established
conn, err = pool.Dial(ctx, addr, "token")
require.NoError(t, err)
- verifyConnection(t, conn, codes.OK)
+ verifyConnection(t, ctx, conn, codes.OK)
}