Skip to content
Snippets Groups Projects
Commit 1f11f2d7 authored by Patrick Steinhardt's avatar Patrick Steinhardt
Browse files

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.
parent dadab063
No related merge requests found
......@@ -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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment