Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-06-28 09:48:08 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-06-28 10:19:51 +0300
commit70fde9dba668fa337b08806f6dd080889ab45eb9 (patch)
tree4b57b5ab4c769545bc36336145b26ad76af60479
parent811ecd227de57e6833bf398acd8412a8d45b9282 (diff)
repository: Fix leaking command in `cloneFromURLCommand()` tests
The test to verify that `cloneFromURLCommand()` behaves as expected is spawning a git-clone(1) command, but doesn't make sure that this command terminates as expected. This has resulted in failed pipelines due to the process leak checker detecting this escaped process. Fix this flake by killing the process by cancelling the context and then waiting for the process to return.
-rw-r--r--internal/gitaly/service/repository/create_repository_from_url_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/gitaly/service/repository/create_repository_from_url_test.go b/internal/gitaly/service/repository/create_repository_from_url_test.go
index 0b6f52cea..6449a75c3 100644
--- a/internal/gitaly/service/repository/create_repository_from_url_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_url_test.go
@@ -186,7 +186,6 @@ func TestCreateRepositoryFromURL_redirect(t *testing.T) {
func TestServer_CloneFromURLCommand(t *testing.T) {
t.Parallel()
- ctx := testhelper.Context(t)
cfg := testcfg.Build(t)
s := server{cfg: cfg, gitCmdFactory: gittest.NewCommandFactory(t, cfg)}
@@ -218,6 +217,8 @@ func TestServer_CloneFromURLCommand(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
+ ctx, cancel := context.WithCancel(testhelper.Context(t))
+
cmd, err := s.cloneFromURLCommand(
ctx,
tc.url,
@@ -229,6 +230,13 @@ func TestServer_CloneFromURLCommand(t *testing.T) {
)
require.NoError(t, err)
+ // Kill the command so that it won't leak outside of the current test
+ // context. We know that it will return an error, but we cannot quite tell
+ // what kind of error it will be because it might fail either be to the kill
+ // signal or because it failed to clone the repository.
+ cancel()
+ require.Error(t, cmd.Wait())
+
args := cmd.Args()
require.Contains(t, args, "--bare")
require.Contains(t, args, "https://192.0.2.1/secretrepo.git")