Skip to content

commandstatshandler: Fix flaky test caused by Git version check

Patrick Steinhardt requested to merge pks-commandstatshandler-flake into master

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.

Fixes #4239 (closed)

Merge request reports