diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-01 09:57:02 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-01 10:10:10 +0300 |
commit | 6d37df842bde9784dec0ceda5bf7a194481b92af (patch) | |
tree | a1721536b4ca2255f5300619d95f5d67b9cbef0b | |
parent | 7236cb353846d96ffec3c53aed569372972016db (diff) |
ssh: Fix test overriding Git environmentuse-ubi-image
Our tests that exercise pushing objects to SSHReceivePack are using the
helper funciton `sshPushCommand()` to construct a git-push(1) process.
As part of this setup we also inject various environment variables that
are required for the `gitaly-ssh` auxiliary binary so that it knows how
to connect back to the Gitaly server. The setup of those environment
variables is accidentally overriding the complete environment that was
returned by `gittest.NewCommand()` though, which also means that any
setup done by the Git command factory is lost.
Part of this setup also includes the `GIT_EXEC_PATH` environment
variable that tells Git where to find its binaries. This essentially
means that when running tests with bundled Git, we have by accident been
picking up the wrong Git executables. While this has worked just fine
until now, this breaks with the introduction of FIPS-enabled UBI images
which don't have Git installed in `/usr`, but in `/usr/local`. As a
consequence, we fail to find the correct Git executable and thus fail
the test.
Fix this bug by appending to the environment instead of overriding it
completely.
-rw-r--r-- | internal/gitaly/service/ssh/receive_pack_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index 737ec2106..f9320ba53 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -682,12 +682,12 @@ func sshPushCommand(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDeta } cmd := gittest.NewCommand(t, cfg, "-C", cloneDetails.LocalRepoPath, "push", "-v", "git@localhost:test/test.git", "master") - cmd.Env = []string{ + cmd.Env = append(cmd.Env, fmt.Sprintf("GITALY_PAYLOAD=%s", payload), fmt.Sprintf("GITALY_ADDRESS=%s", serverSocketPath), fmt.Sprintf("GITALY_FEATUREFLAGS=%s", strings.Join(flagsWithValues, ",")), fmt.Sprintf("GIT_SSH_COMMAND=%s receive-pack", cfg.BinaryPath("gitaly-ssh")), - } + ) return cmd } |