Skip to content

Commit 67345c2

Browse files
author
Igor Drozdov
committed
Fix failing TestGitReceivePackSuccess
After https://gitlab.com/gitlab-org/gitaly/-/merge_requests/4766 has been introduced, the test started fail because we basically cancel the git-receive-pack after the output is received This commit gracefully closes the connection to make the test pass
1 parent 8f2a4e9 commit 67345c2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmd/gitlab-sshd/acceptance_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,25 @@ func TestGitReceivePackSuccess(t *testing.T) {
387387
ensureGitalyRepository(t)
388388

389389
client := runSSHD(t, successAPI(t))
390-
391390
session, err := client.NewSession()
392391
require.NoError(t, err)
393392
defer session.Close()
394393

395-
output, err := session.Output(fmt.Sprintf("git-receive-pack %s", testRepo))
394+
stdin, err := session.StdinPipe()
395+
require.NoError(t, err)
396+
397+
stdout, err := session.StdoutPipe()
398+
require.NoError(t, err)
399+
400+
err = session.Start(fmt.Sprintf("git-receive-pack %s", testRepo))
401+
require.NoError(t, err)
402+
403+
// Gracefully close connection
404+
_, err = fmt.Fprintln(stdin, "0000")
405+
require.NoError(t, err)
406+
stdin.Close()
407+
408+
output, err := io.ReadAll(stdout)
396409
require.NoError(t, err)
397410

398411
outputLines := strings.Split(string(output), "\n")

0 commit comments

Comments
 (0)