From 67345c2a79749a9fe3ef828f685034e0d78e5a9e Mon Sep 17 00:00:00 2001 From: Igor Drozdov Date: Fri, 5 Aug 2022 15:37:43 +0200 Subject: 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 --- cmd/gitlab-sshd/acceptance_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/gitlab-sshd/acceptance_test.go b/cmd/gitlab-sshd/acceptance_test.go index 9dcb84c..31f87a5 100644 --- a/cmd/gitlab-sshd/acceptance_test.go +++ b/cmd/gitlab-sshd/acceptance_test.go @@ -387,12 +387,25 @@ func TestGitReceivePackSuccess(t *testing.T) { ensureGitalyRepository(t) client := runSSHD(t, successAPI(t)) - session, err := client.NewSession() require.NoError(t, err) defer session.Close() - output, err := session.Output(fmt.Sprintf("git-receive-pack %s", testRepo)) + stdin, err := session.StdinPipe() + require.NoError(t, err) + + stdout, err := session.StdoutPipe() + require.NoError(t, err) + + err = session.Start(fmt.Sprintf("git-receive-pack %s", testRepo)) + require.NoError(t, err) + + // Gracefully close connection + _, err = fmt.Fprintln(stdin, "0000") + require.NoError(t, err) + stdin.Close() + + output, err := io.ReadAll(stdout) require.NoError(t, err) outputLines := strings.Split(string(output), "\n") -- cgit v1.2.1