diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-18 11:22:14 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-05-18 11:55:19 +0300 |
commit | 83d9978d8003b0b30ad7e8b0c2a904cf8a9729a0 (patch) | |
tree | 582a8d9b97b0ad17fde0e383a4bbd60650208a3e | |
parent | 1bfd54e59d540100c90387f374e43458283290a3 (diff) |
commandstatshandler: Fix flaky test caused by Git version check
In our commandstatshandler we're asserting that when executing RPCs, we
record the number of spawned commands. To do so we use an RPC that
spawns a Git command. Due to recent changes in our Git command factory
we had to adapt the test though as we are now additionaly spawning a
git-version(1) command to auto-detect the version.
This change is causing flakiness though because we cache the Git
version per binary that is executed: we don't reuse the context, and
when running with bundled Git we now thus randomly use either the old or
the new bundled Git binaries based on a feature flag that uses a random
value. So based on whether this value is the same across both RPC calls
or not we may or may not re-execute git-version(1).
Fix this by reusing the same context for both RPC calls to guarantee
that the feature flag has the same state.
-rw-r--r-- | internal/middleware/commandstatshandler/commandstatshandler_test.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go index 9369cbb8e..fbc61b6ed 100644 --- a/internal/middleware/commandstatshandler/commandstatshandler_test.go +++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go @@ -85,6 +85,8 @@ func TestInterceptor(t *testing.T) { require.NoError(t, err) }() + ctx := testhelper.Context(t) + tests := []struct { name string performRPC func(ctx context.Context, client gitalypb.RefServiceClient) @@ -135,7 +137,6 @@ func TestInterceptor(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { hook.Reset() - ctx := testhelper.Context(t) conn, err := grpc.DialContext(ctx, "", grpc.WithContextDialer(getBufDialer(listener)), grpc.WithInsecure()) require.NoError(t, err) |