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:
authorWill Chandler <wchandler@gitlab.com>2023-08-30 00:11:56 +0300
committerWill Chandler <wchandler@gitlab.com>2023-08-30 00:11:56 +0300
commite5b9614de0ce665f2e5262e3f2dcd5ff00278c11 (patch)
treeb42e6004ef9e41e574e9cc8de282200cd6d5454b
parent0d1460b9eb53f46ee8dffee5e9f4646e1a22588d (diff)
parent4f9005d016b1b4861c4c55e707d454a99909e319 (diff)
Merge branch 'pks-git-drop-test-repository' into 'master'
git: Remove the test repository See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6273 Merged-by: Will Chandler <wchandler@gitlab.com> Approved-by: karthik nayak <knayak@gitlab.com> Approved-by: Will Chandler <wchandler@gitlab.com> Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
-rw-r--r--Makefile16
-rw-r--r--_support/gitlab-test.git-packed-refs101
-rw-r--r--cmd/gitaly-git2go/rebase_test.go301
-rw-r--r--internal/git/gittest/repo.go3
-rw-r--r--internal/git/gittest/testdata.go332
-rw-r--r--internal/gitaly/service/commit/find_commit_test.go6
-rw-r--r--internal/gitaly/service/commit/find_commits_test.go7
-rw-r--r--internal/gitaly/service/commit/list_all_commits_test.go6
-rw-r--r--internal/gitaly/service/commit/testhelper_test.go15
-rw-r--r--internal/gitaly/service/hook/pack_objects_test.go47
-rw-r--r--internal/gitaly/service/ref/find_all_tags_test.go2
11 files changed, 249 insertions, 587 deletions
diff --git a/Makefile b/Makefile
index dcea92d36..40ef9dc4e 100644
--- a/Makefile
+++ b/Makefile
@@ -227,7 +227,6 @@ TEST_TMP_DIR ?=
## Directory where Gitaly should write logs to during test execution.
TEST_LOG_DIR ?=
TEST_REPO_DIR := ${BUILD_DIR}/testrepos
-TEST_REPO := ${TEST_REPO_DIR}/gitlab-test.git
BENCHMARK_REPO := ${TEST_REPO_DIR}/benchmark.git
## Options to pass to the script which builds the Gitaly gem
BUILD_GEM_OPTIONS ?=
@@ -368,15 +367,12 @@ run_go_tests += \
endif
.PHONY: prepare-tests
-prepare-tests: libgit2 prepare-test-repos ${GOTESTSUM} ${GITALY_PACKED_EXECUTABLES}
+prepare-tests: libgit2 ${GOTESTSUM} ${GITALY_PACKED_EXECUTABLES}
${Q}mkdir -p "$(dir ${TEST_JUNIT_REPORT})"
.PHONY: prepare-debug
prepare-debug: ${DELVE}
-.PHONY: prepare-test-repos
-prepare-test-repos: ${TEST_REPO}
-
.PHONY: test
## Run Go tests.
test: test-go test-gitaly-linters
@@ -707,15 +703,5 @@ ${PROTOC_GEN_GO_GRPC}:TOOL_PACKAGE = google.golang.org/grpc/cmd/protoc-gen-go-gr
${PROTOC_GEN_DOC}: TOOL_PACKAGE = github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
${DELVE}: TOOL_PACKAGE = github.com/go-delve/delve/cmd/dlv
-${TEST_REPO}:
- # Skip writing the reverse index as otherwise our tests will get confused.
- ${GIT} -c pack.writeReverseIndex=false clone --bare ${GIT_QUIET} https://gitlab.com/gitlab-org/gitlab-test.git $@
- @ # Git notes aren't fetched by default with git clone
- ${GIT} -C $@ fetch ${GIT_QUIET} origin refs/notes/*:refs/notes/*
- ${Q}rm -rf $@/refs
- ${Q}mkdir -p $@/refs/heads $@/refs/tags
- ${Q}cp ${SOURCE_DIR}/_support/gitlab-test.git-packed-refs $@/packed-refs
- ${Q}${GIT} -C $@ fsck --no-progress --no-dangling
-
${BENCHMARK_REPO}:
${GIT} clone --bare ${GIT_QUIET} https://gitlab.com/gitlab-org/gitlab.git $@
diff --git a/_support/gitlab-test.git-packed-refs b/_support/gitlab-test.git-packed-refs
deleted file mode 100644
index b10394019..000000000
--- a/_support/gitlab-test.git-packed-refs
+++ /dev/null
@@ -1,101 +0,0 @@
-# pack-refs with: peeled fully-peeled sorted
-e56497bb5f03a90a51293fc6d516788730953899 refs/heads/'test'
-1b12f15a11fc6e62177bef08f47bc7b5ce50b141 refs/heads/100%branch
-1942eed5cc108b19c7405106e81fa96125d0be22 refs/heads/1942eed5cc108b19c7405106e81fa96125d0be22
-bf12d2567099e26f59692896f73ac819bae45b00 refs/heads/2-mb-file
-b89b56d795dcf0351e9d627b58fd2fc67616da05 refs/heads/add-balsamiq-file
-93ee73207dcfa56fe60ab8245e0623160ab8b212 refs/heads/add-ipython-files
-e774ebd33ca5de8e6ef1e633fd887bb52b9d0a7a refs/heads/add-pdf-file
-79faa7bfb522480533f4d60368d8f6ecc1e03d9b refs/heads/add-pdf-text-binary
-010d10642f5950c8d5041f0469593ccc5c646521 refs/heads/add_images_and_changes
-ba3faa7dbecdb555c748b36e8bc0f427e69de5e7 refs/heads/after-create-delete-modify-move
-77e835ef0856f33c4f0982f84d10bdb0567fe440 refs/heads/author-committer-different
-845009f4d7bdc9e0d8f26b1c6fb6e108aaff9314 refs/heads/before-create-delete-modify-move
-ef16b8d2b204706bd8dc211d4011a5bffb6fc0c2 refs/heads/big-files
-7b1cf4336b528e0f3d1d140ee50cafdbc703597c refs/heads/binary-encoding
-4e07b243e436fd6ca00ca421fa507daad3310839 refs/heads/blob-with-tricky-encoding
-498214de67004b1da3d820901307bed2a68a8ef6 refs/heads/branch-merged
-259a6fba859cc91c54cd86a2cbd4c2f720e3a19d refs/heads/conflict-binary-file
-78a30867c755d774340108cdad5f11254818fb0c refs/heads/conflict-contains-conflict-markers
-eb227b3e214624708c474bdab7bde7afc17cefcc refs/heads/conflict-missing-side
-d0a293c0ac821fadfdc086fe528f79423004229d refs/heads/conflict-non-utf8
-1450cd639e0bc6721eb02800169e464f212cde06 refs/heads/conflict-resolvable
-824be604a34828eb682305f0d963056cfac87b2d refs/heads/conflict-start
-39fa04f48a13ea003c4db3623b4decc9df887c48 refs/heads/conflict-too-large
-5b4bb08538b9249995b94aa69121365ba9d28082 refs/heads/conflict_branch_a
-f0f390655872bb2772c85a0128b2fbc2d88670cb refs/heads/conflict_branch_b
-593890758a6f845c600f38ffa05be2749211caee refs/heads/crlf-diff
-3dd08961455abf80ef9115f4afdc1c6f968b503c refs/heads/csv
-1eda481c3d5499e81cbbe15d34c53282e87627d2 refs/heads/custom-encoding
-6c177980d2073c20c4e4f0f45253a5500f1b23e1 refs/heads/deleted-image-test
-7efb185dd22fd5c51ef044795d62b7847900c341 refs/heads/empty-branch
-98b0d8b3aec8e7f7b339fd40c446ad22cbc565fe refs/heads/ends-with.json
-4842455ecb8ec1428d0e83ee6389885bf98919d3 refs/heads/expand-collapse-diffs
-025db92c6c720f030b936133cb44a16de3445daa refs/heads/expand-collapse-files
-238e82dcc48eebf0036fdd23dd234ee950f0e0d3 refs/heads/expand-collapse-lines
-0b4bc9a49b562e85de7cc9e834518ea6828729b9 refs/heads/feature
-1a35b5a77cf6af7edf6703f88e82f6aff613666f refs/heads/feature-and-encoding
-8309e68585b28d61eb85b7e2834849dda6bf1733 refs/heads/feature-encoding-conflict
-5a62481d563af92b8e32d735f2fa63b94e806835 refs/heads/feature.custom-highlighting
-bb5206fee213d983da88c47f9cf4cc6caf9c66dc refs/heads/feature_conflict
-0031876facac3f2b2702a0e53a26e89939a42209 refs/heads/few-commits
-06041ab2037429d243a38abb55957818dd9f948d refs/heads/file-mode-change
-48f0be4bd10c1decee6fae52f9ae6d10f77b60f4 refs/heads/fix
-ce369011c189f62c815f5971d096b26759bab0d1 refs/heads/flat-path
-d25b6d94034242f3930dfcfeb6d8d9aac3583992 refs/heads/flat-path-2
-e56497bb5f03a90a51293fc6d516788730953899 refs/heads/flatten-dirs
-9a944d90955aaf45f6d0c88f30e27f8d2c41cec0 refs/heads/gitaly-branches-test
-ab2c9622c02288a2bbaaf35d96088cfdff31d9d9 refs/heads/gitaly-diff-stuff
-0999bb770f8dc92ab5581cc0b474b3e31a96bf5c refs/heads/gitaly-non-utf8-commit
-94bb47ca1297b7b3731ff2a36923640991e9236f refs/heads/gitaly-rename-test
-cb19058ecc02d01f8e4290b7e79cafd16a8839b6 refs/heads/gitaly-stuff
-e63f41fe459e62e1228fcef60d7189127aeba95a refs/heads/gitaly-test-ref
-c809470461118b7bcab850f6e9a7ca97ac42f8ea refs/heads/gitaly-windows-1251
-3d05a143ac193c1a6fe4d046a6e3fe71e825258a refs/heads/gitaly/squash-test
-5937ac0a7beb003549fc5fd26fc247adbce4a52e refs/heads/improve/awesome
-7df99c9ad5b8c9bfc5ae4fb7a91cc87adcce02ef refs/heads/jv-conflict-1
-bd493d44ae3c4dd84ce89cb75be78c4708cbd548 refs/heads/jv-conflict-2
-d23bddc916b96c98ff192e198b1adee0f6871085 refs/heads/many_files
-0ed8c6c6752e8c6ea63e7b92a517bf5ac1209c80 refs/heads/markdown
-1e292f8fedd741b75372e19097c76d327140c312 refs/heads/master
-646ece5cfed840eca0a4feb21bcd6a81bb19bda3 refs/heads/merge-commit-analyze-after
-21751bf5cb2b556543a11018c1f13b35e44a99d7 refs/heads/merged-target
-46abbb087fcc0fd02c340f0f2f052bd2c7708da3 refs/heads/moar-lfs-ptrs
-b83d6e391c22777fca1ed3012fce84f633d7fed0 refs/heads/not-merged-branch
-b83d6e391c22777fca1ed3012fce84f633d7fed0 refs/heads/not-mergéd-branch
-45127a93e4fa99ee1709a3a9aed3d677d78cbf1b refs/heads/orphaned-branch
-7897d5b9c5e420760eb63782ebae25371ad2325c refs/heads/pages-deploy
-7975be0116940bf2ad4321f79d02a55c5f7779aa refs/heads/pages-deploy-target
-fe42f41cdc7ca97ae200fb50a268431add95901a refs/heads/png-lfs
-c84ff944ff4529a70788a5e9003c2b7feae29047 refs/heads/rd-add-file-larger-than-1-mb
-ca47bfd5e930148c42ed74c3b561a8783e381f7f refs/heads/rebase-encoding-failure-trigger
-842616594688d2351480dfebd67b3d8d15571e6d refs/heads/sha-starting-with-large-number
-6101e87e575de14b38b4e1ce180519a813671e10 refs/heads/signed-commits
-ed775cc81e5477df30c2abba7b6fdbb5d0baadae refs/heads/smime-signed-commits
-ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69 refs/heads/spooky-stuff
-35236eac0ce603467ba37d2f99cb591df4cb8f63 refs/heads/squash-encoding-error-trigger
-54cec5282aa9f21856362fe321c800c236a61615 refs/heads/squash-large-files
-7b5160f9bb23a3d58a0accdbe89da13b96b1ece9 refs/heads/ssh-signed-commit
-b491b929a311ca258a0731e58d73b7b089c7c358 refs/heads/submodule_inside_folder
-81e6355ce4e1544a3524b230952c12455de0777b refs/heads/symlink-expand-diff
-899d3d27b04690ac1cd9ef4d8a74fde0667c57f1 refs/heads/test-do-not-touch
-304d257dcb821665ab5110318fc58a007bd104ed refs/heads/two-commits
-2f61d70f862c6a4f782ef7933e020a118282db29 refs/heads/use-gitlab-shell-v-6-0-1
-de78448b0b504f3f60093727bddfda1ceee42345 refs/heads/use-gitlab-shell-v-6-0-3
-f05a98786e4274708e1fa118c7ad3a29d1d1b9a3 refs/heads/utf-16
-816c271cd6398818b04f974780a2b87162718c80 refs/heads/utf-16-2
-4451372901c41a32f985a54c526da03ce8312291 refs/heads/utf-dir
-b83d6e391c22777fca1ed3012fce84f633d7fed0 refs/heads/v1.1.0
-f3ec7ba3fd368de6663df341bc25f6bb2fa18135 refs/heads/very-large-diff-ordered
-88790590ed1337ab189bccaa355f068481c90bec refs/heads/video
-b9238ee5bf1d7359dd3b8c89fd76c1c7f8b75aba refs/heads/wip
-219560e1a2bd7db7753f179a164483761089a53b refs/heads/with-codeowners
-6b8dc4a827797aa025ff6b8f425e583858a10d4f refs/heads/with-executables
-7975be0116940bf2ad4321f79d02a55c5f7779aa refs/heads/Ääh-test-utf-8
-e63f41fe459e62e1228fcef60d7189127aeba95a refs/heads/ʕ•ᴥ•ʔ
-f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 refs/tags/v1.0.0
-^6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
-8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b refs/tags/v1.1.0
-^5937ac0a7beb003549fc5fd26fc247adbce4a52e
-8f03acbcd11c53d9c9468078f32a2622005a4841 refs/tags/v1.1.1
-^189a6c924013fc3fe40d6f1ec1dc20214183bc97
diff --git a/cmd/gitaly-git2go/rebase_test.go b/cmd/gitaly-git2go/rebase_test.go
index 3a0d6b8f5..6de901e32 100644
--- a/cmd/gitaly-git2go/rebase_test.go
+++ b/cmd/gitaly-git2go/rebase_test.go
@@ -7,10 +7,9 @@ import (
"testing"
"time"
- git "github.com/libgit2/git2go/v34"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/cmd/gitaly-git2go/git2goutil"
- gitalygit "gitlab.com/gitlab-org/gitaly/v16/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
@@ -29,7 +28,6 @@ func TestRebase_validation(t *testing.T) {
repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
})
committer := git2go.NewSignature("Foo", "foo@example.com", time.Now())
@@ -91,159 +89,267 @@ func TestRebase_validation(t *testing.T) {
func TestRebase_rebase(t *testing.T) {
gittest.SkipWithSHA256(t)
+ t.Parallel()
+
+ ctx := testhelper.Context(t)
+ cfg := testcfg.Build(t)
+ testcfg.BuildGitalyGit2Go(t, cfg)
+ executor := buildExecutor(t, cfg)
+
+ committer := git2go.NewSignature(
+ string(gittest.TestUser.Name),
+ string(gittest.TestUser.Email),
+ time.Date(2021, 3, 1, 13, 45, 50, 0, time.FixedZone("", +2*60*60)),
+ )
+
+ type setup struct {
+ base, upstream, downstream git.ObjectID
+ expecetedCommitsAhead int
+ expectedObjectID git.ObjectID
+ expectedErr string
+ }
+
testcases := []struct {
- desc string
- branch string
- commitsAhead int
- setupRepo func(testing.TB, *git.Repository)
- expected string
- expectedErr string
+ desc string
+ setup func(testing.TB, string) setup
}{
{
- desc: "Single commit rebase",
- branch: "gitaly-rename-test",
- commitsAhead: 1,
- expected: "a08ed4bc45f9e686db93c5d0519f63d7b537270c",
+ desc: "Single commit rebase",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ upstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("upstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+
+ return setup{
+ base: base,
+ upstream: upstream,
+ downstream: downstream,
+ expectedObjectID: "ef018adb419cd97453a0624c28271fafe622b83e",
+ expecetedCommitsAhead: 1,
+ }
+ },
},
{
- desc: "Multiple commits",
- branch: "csv",
- commitsAhead: 5,
- expected: "2f8365edc69d3683e22c4209ae9641642d84dd4a",
+ desc: "Multiple commits",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ upstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("upstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream1 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream-1"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-1\n"},
+ ))
+ downstream2 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream-2"), gittest.WithParents(downstream1), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-2\n"},
+ ))
+ downstream3 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream-3"), gittest.WithParents(downstream2), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-3\n"},
+ ))
+
+ return setup{
+ base: base,
+ upstream: upstream,
+ downstream: downstream3,
+ expectedObjectID: "d3c737fdb3a0c4da3a371fc01de6df4cbb5bc3e4",
+ expecetedCommitsAhead: 3,
+ }
+ },
},
{
- desc: "Branch zero commits behind",
- branch: "sha-starting-with-large-number",
- commitsAhead: 1,
- expected: "842616594688d2351480dfebd67b3d8d15571e6d",
+ desc: "Branch zero commits behind",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+
+ return setup{
+ base: base,
+ upstream: base,
+ downstream: downstream,
+ expectedObjectID: downstream,
+ expecetedCommitsAhead: 1,
+ }
+ },
},
{
- desc: "Merged branch",
- branch: "branch-merged",
- expected: masterRevision,
+ desc: "Merged branch",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+ merge := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base, downstream), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+
+ return setup{
+ base: base, upstream: merge, downstream: downstream,
+ expectedObjectID: merge,
+ }
+ },
},
{
- desc: "Partially merged branch",
- branch: "branch-merged-plus-one",
- setupRepo: func(tb testing.TB, repo *git.Repository) {
- head, err := lookupCommit(repo, "branch-merged")
- require.NoError(tb, err)
-
- other, err := lookupCommit(repo, "gitaly-rename-test")
- require.NoError(tb, err)
- tree, err := other.Tree()
- require.NoError(tb, err)
- newOid, err := repo.CreateCommitFromIds("refs/heads/branch-merged-plus-one", &DefaultAuthor, &DefaultAuthor, "Message", tree.Object.Id(), head.Object.Id())
- require.NoError(tb, err)
- require.Equal(tb, "8665d9b4b56f6b8ab8c4128a5549d1820bf68bf5", newOid.String())
+ desc: "Partially merged branch",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream1 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-1\n"},
+ ))
+ downstream2 := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(downstream1), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-2\n"},
+ ))
+ merge := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base, downstream1), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream-1\n"},
+ ))
+
+ return setup{
+ base: base,
+ upstream: merge,
+ downstream: downstream2,
+ expectedObjectID: "721e8bd36a394a7cc243b8c3960b44c5520c6246",
+ expecetedCommitsAhead: 1,
+ }
},
- commitsAhead: 1,
- expected: "56bafb70922008232d171b78930be6cdb722bb39",
},
{
- desc: "With upstream merged into",
- branch: "csv-plus-merge",
- setupRepo: func(tb testing.TB, repo *git.Repository) {
- ours, err := lookupCommit(repo, "csv")
- require.NoError(tb, err)
- theirs, err := lookupCommit(repo, "b83d6e391c22777fca1ed3012fce84f633d7fed0")
- require.NoError(tb, err)
-
- index, err := repo.MergeCommits(ours, theirs, nil)
- require.NoError(tb, err)
- tree, err := index.WriteTreeTo(repo)
- require.NoError(tb, err)
-
- newOid, err := repo.CreateCommitFromIds("refs/heads/csv-plus-merge", &DefaultAuthor, &DefaultAuthor, "Message", tree, ours.Object.Id(), theirs.Object.Id())
- require.NoError(tb, err)
- require.Equal(tb, "5b2d6bd7be0b1b9f7e46b64d02fe9882c133a128", newOid.String())
+ desc: "With upstream merged into",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ upstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("upstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\nb\nc\nd\ne\nf\ng\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithMessage("downstream"), gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "a\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+ downstreamMerge := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(downstream, upstream), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\nb\nc\nd\ne\nf\ndownstream\n"},
+ ))
+
+ return setup{
+ base: base,
+ upstream: upstream,
+ downstream: downstreamMerge,
+ expectedObjectID: "aa375bc059fa8830d9489d89af1278632722407d",
+ expecetedCommitsAhead: 2,
+ }
},
- commitsAhead: 5, // Same as "Multiple commits"
- expected: "2f8365edc69d3683e22c4209ae9641642d84dd4a",
},
{
- desc: "Rebase with conflict",
- branch: "rebase-encoding-failure-trigger",
- expectedErr: "rebase: commit \"eb8f5fb9523b868cef583e09d4bf70b99d2dd404\": there are conflicting files",
+ desc: "Rebase with conflict",
+ setup: func(tb testing.TB, repoPath string) setup {
+ base := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "base\n"},
+ ))
+ upstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithParents(base), gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "downstream\n"},
+ ))
+
+ return setup{
+ upstream: upstream,
+ downstream: downstream,
+ expectedErr: fmt.Sprintf("rebase: commit %q: there are conflicting files", downstream),
+ }
+ },
},
{
- desc: "Orphaned branch",
- branch: "orphaned-branch",
- expectedErr: "rebase: find merge base: no merge base found",
+ desc: "Orphaned branch",
+ setup: func(tb testing.TB, repoPath string) setup {
+ upstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "upstream\n"},
+ ))
+ downstream := gittest.WriteCommit(t, cfg, repoPath, gittest.WithTreeEntries(
+ gittest.TreeEntry{Path: "path", Mode: "100644", Content: "downstream\n"},
+ ))
+
+ return setup{
+ upstream: upstream,
+ downstream: downstream,
+ expectedErr: "rebase: find merge base: no merge base found",
+ }
+ },
},
}
for _, tc := range testcases {
- t.Run(tc.desc, func(t *testing.T) {
- ctx := testhelper.Context(t)
+ tc := tc
- committer := git2go.NewSignature(string(gittest.TestUser.Name),
- string(gittest.TestUser.Email),
- time.Date(2021, 3, 1, 13, 45, 50, 0, time.FixedZone("", +2*60*60)))
+ t.Run(tc.desc, func(t *testing.T) {
+ t.Parallel()
- cfg := testcfg.Build(t)
repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
})
- testcfg.BuildGitalyGit2Go(t, cfg)
- executor := buildExecutor(t, cfg)
-
- repo, err := git2goutil.OpenRepository(repoPath)
- require.NoError(t, err)
+ setup := tc.setup(t, repoPath)
- if tc.setupRepo != nil {
- tc.setupRepo(t, repo)
- }
+ gittest.WriteRef(t, cfg, repoPath, "refs/heads/upstream", setup.upstream)
+ gittest.WriteRef(t, cfg, repoPath, "refs/heads/downstream", setup.downstream)
- branchCommit, err := lookupCommit(repo, tc.branch)
+ repo, err := git2goutil.OpenRepository(repoPath)
require.NoError(t, err)
for desc, request := range map[string]git2go.RebaseCommand{
"with branch and upstream": {
Repository: repoPath,
Committer: committer,
- BranchName: tc.branch,
- UpstreamRevision: masterRevision,
+ BranchName: "downstream",
+ UpstreamRevision: setup.upstream.String(),
},
"with branch and upstream commit ID": {
Repository: repoPath,
Committer: committer,
- BranchName: tc.branch,
- UpstreamCommitID: gitalygit.ObjectID(masterRevision),
+ BranchName: "downstream",
+ UpstreamCommitID: setup.upstream,
},
"with commit ID and upstream": {
Repository: repoPath,
Committer: committer,
- BranchName: tc.branch,
- UpstreamRevision: masterRevision,
+ CommitID: setup.downstream,
+ UpstreamRevision: setup.upstream.String(),
},
"with commit ID and upstream commit ID": {
Repository: repoPath,
Committer: committer,
- CommitID: gitalygit.ObjectID(branchCommit.Id().String()),
- UpstreamCommitID: gitalygit.ObjectID(masterRevision),
+ CommitID: setup.downstream,
+ UpstreamCommitID: setup.upstream,
},
} {
t.Run(desc, func(t *testing.T) {
response, err := executor.Rebase(ctx, repoProto, request)
- if tc.expectedErr != "" {
- require.EqualError(t, err, tc.expectedErr)
+ if setup.expectedErr != "" {
+ require.EqualError(t, err, setup.expectedErr)
} else {
require.NoError(t, err)
+ require.Equal(t, setup.expectedObjectID, response)
- result := response.String()
- require.Equal(t, tc.expected, result)
-
- commit, err := lookupCommit(repo, result)
+ commit, err := lookupCommit(repo, response.String())
require.NoError(t, err)
- for i := tc.commitsAhead; i > 0; i-- {
+ for i := setup.expecetedCommitsAhead; i > 0; i-- {
commit = commit.Parent(0)
}
- masterCommit, err := lookupCommit(repo, masterRevision)
+ baseCommit, err := lookupCommit(repo, setup.base.String())
require.NoError(t, err)
- require.Equal(t, masterCommit, commit)
+ require.Equal(t, baseCommit, commit)
}
})
}
@@ -261,7 +367,6 @@ func TestRebase_skipEmptyCommit(t *testing.T) {
repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
SkipCreationViaService: true,
- Seed: gittest.SeedGitLabTest,
})
// Set up history with two diverging lines of branches, where both sides have implemented
@@ -286,7 +391,7 @@ func TestRebase_skipEmptyCommit(t *testing.T) {
desc string
skipEmptyCommits bool
expectedErr string
- expectedResponse gitalygit.ObjectID
+ expectedResponse git.ObjectID
}{
{
desc: "do not skip empty commit",
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go
index 8ee2dfb20..68edeeecb 100644
--- a/internal/git/gittest/repo.go
+++ b/internal/git/gittest/repo.go
@@ -34,9 +34,6 @@ const (
// GlProjectPath is the default project path for newly created test
// repos.
GlProjectPath = "gitlab-org/gitlab-test"
-
- // SeedGitLabTest is the path of the gitlab-test.git repository in _build/testrepos
- SeedGitLabTest = "gitlab-test.git"
)
// InitRepoDir creates a temporary directory for a repo, without initializing it
diff --git a/internal/git/gittest/testdata.go b/internal/git/gittest/testdata.go
deleted file mode 100644
index 8c5e66d40..000000000
--- a/internal/git/gittest/testdata.go
+++ /dev/null
@@ -1,332 +0,0 @@
-package gittest
-
-import (
- "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-// CommitsByID is a map of GitCommit structures by their respective IDs.
-var CommitsByID = map[string]*gitalypb.GitCommit{
- "0031876facac3f2b2702a0e53a26e89939a42209": {
- Id: "0031876facac3f2b2702a0e53a26e89939a42209",
- Subject: []byte("Merge branch 'few-commits-4' into few-commits-2"),
- Body: []byte("Merge branch 'few-commits-4' into few-commits-2\n"),
- Author: ahmadSherif(1500320762),
- Committer: ahmadSherif(1500320762),
- ParentIds: []string{
- "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb",
- "48ca272b947f49eee601639d743784a176574a09",
- },
- BodySize: 48,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "48ca272b947f49eee601639d743784a176574a09": {
- Id: "48ca272b947f49eee601639d743784a176574a09",
- Subject: []byte("Commit #9 alternate"),
- Body: []byte("Commit #9 alternate\n"),
- Author: ahmadSherif(1500320271),
- Committer: ahmadSherif(1500320271),
- ParentIds: []string{"335bc94d5b7369b10251e612158da2e4a4aaa2a5"},
- BodySize: 20,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "335bc94d5b7369b10251e612158da2e4a4aaa2a5": {
- Id: "335bc94d5b7369b10251e612158da2e4a4aaa2a5",
- Subject: []byte("Commit #8 alternate"),
- Body: []byte("Commit #8 alternate\n"),
- Author: ahmadSherif(1500320269),
- Committer: ahmadSherif(1500320269),
- ParentIds: []string{"1039376155a0d507eba0ea95c29f8f5b983ea34b"},
- BodySize: 20,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb": {
- Id: "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb",
- Subject: []byte("Commit #10"),
- Body: []byte("Commit #10\n"),
- Author: ahmadSherif(1500320272),
- Committer: ahmadSherif(1500320272),
- ParentIds: []string{"9d526f87b82e2b2fd231ca44c95508e5e85624ca"},
- BodySize: 11,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "9d526f87b82e2b2fd231ca44c95508e5e85624ca": {
- Id: "9d526f87b82e2b2fd231ca44c95508e5e85624ca",
- Subject: []byte("Commit #9"),
- Body: []byte("Commit #9\n"),
- Author: ahmadSherif(1500320270),
- Committer: ahmadSherif(1500320270),
- ParentIds: []string{"1039376155a0d507eba0ea95c29f8f5b983ea34b"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "1039376155a0d507eba0ea95c29f8f5b983ea34b": {
- Id: "1039376155a0d507eba0ea95c29f8f5b983ea34b",
- Subject: []byte("Commit #8"),
- Body: []byte("Commit #8\n"),
- Author: ahmadSherif(1500320268),
- Committer: ahmadSherif(1500320268),
- ParentIds: []string{"54188278422b1fa877c2e71c4e37fc6640a58ad1"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "54188278422b1fa877c2e71c4e37fc6640a58ad1": {
- Id: "54188278422b1fa877c2e71c4e37fc6640a58ad1",
- Subject: []byte("Commit #7"),
- Body: []byte("Commit #7\n"),
- Author: ahmadSherif(1500320266),
- Committer: ahmadSherif(1500320266),
- ParentIds: []string{"8b9270332688d58e25206601900ee5618fab2390"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "8b9270332688d58e25206601900ee5618fab2390": {
- Id: "8b9270332688d58e25206601900ee5618fab2390",
- Subject: []byte("Commit #6"),
- Body: []byte("Commit #6\n"),
- Author: ahmadSherif(1500320264),
- Committer: ahmadSherif(1500320264),
- ParentIds: []string{"f9220df47bce1530e90c189064d301bfc8ceb5ab"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "f9220df47bce1530e90c189064d301bfc8ceb5ab": {
- Id: "f9220df47bce1530e90c189064d301bfc8ceb5ab",
- Subject: []byte("Commit #5"),
- Body: []byte("Commit #5\n"),
- Author: ahmadSherif(1500320262),
- Committer: ahmadSherif(1500320262),
- ParentIds: []string{"40d408f89c1fd26b7d02e891568f880afe06a9f8"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "40d408f89c1fd26b7d02e891568f880afe06a9f8": {
- Id: "40d408f89c1fd26b7d02e891568f880afe06a9f8",
- Subject: []byte("Commit #4"),
- Body: []byte("Commit #4\n"),
- Author: ahmadSherif(1500320260),
- Committer: ahmadSherif(1500320260),
- ParentIds: []string{"df914c609a1e16d7d68e4a61777ff5d6f6b6fde3"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "df914c609a1e16d7d68e4a61777ff5d6f6b6fde3": {
- Id: "df914c609a1e16d7d68e4a61777ff5d6f6b6fde3",
- Subject: []byte("Commit #3"),
- Body: []byte("Commit #3\n"),
- Author: ahmadSherif(1500320258),
- Committer: ahmadSherif(1500320258),
- ParentIds: []string{"6762605237fc246ae146ac64ecb467f71d609120"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "6762605237fc246ae146ac64ecb467f71d609120": {
- Id: "6762605237fc246ae146ac64ecb467f71d609120",
- Subject: []byte("Commit #2"),
- Body: []byte("Commit #2\n"),
- Author: ahmadSherif(1500320256),
- Committer: ahmadSherif(1500320256),
- ParentIds: []string{"79b06233d3dc769921576771a4e8bee4b439595d"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "79b06233d3dc769921576771a4e8bee4b439595d": {
- Id: "79b06233d3dc769921576771a4e8bee4b439595d",
- Subject: []byte("Commit #1"),
- Body: []byte("Commit #1\n"),
- Author: ahmadSherif(1500320254),
- Committer: ahmadSherif(1500320254),
- ParentIds: []string{"1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"},
- BodySize: 10,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863": {
- Id: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
- Subject: []byte("Initial commit"),
- Body: []byte("Initial commit\n"),
- Author: dmitriyZaporozhets(1393488198),
- Committer: dmitriyZaporozhets(1393488198),
- ParentIds: nil,
- BodySize: 15,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "304d257dcb821665ab5110318fc58a007bd104ed": {
- Id: "304d257dcb821665ab5110318fc58a007bd104ed",
- Subject: []byte("Commit #11"),
- Body: []byte("Commit #11\n"),
- Author: ahmadSherif(1500322381),
- Committer: ahmadSherif(1500322381),
- ParentIds: []string{"1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"},
- BodySize: 11,
- TreeId: "91639b9835ff541f312fd2735f639a50bf35d472",
- },
- "1e292f8fedd741b75372e19097c76d327140c312": {
- Id: "1e292f8fedd741b75372e19097c76d327140c312",
- Subject: []byte("Merge branch 'cherry-pikc-ce369011' into 'master'"),
- Body: []byte("Merge branch 'cherry-pikc-ce369011' into 'master'\n\nAdd file with a _flattable_ path\n\n See merge request gitlab-org/gitlab-test!35\n"),
- Author: drewBlessing(1540830087),
- Committer: drewBlessing(1540830087),
- ParentIds: []string{
- "79b06233d3dc769921576771a4e8bee4b439595d",
- "c1c67abbaf91f624347bb3ae96eabe3a1b742478",
- },
- BodySize: 388,
- TreeId: "07f8147e8e73aab6c935c296e8cdc5194dee729b",
- },
- "60ecb67744cb56576c30214ff52294f8ce2def98": {
- Id: "60ecb67744cb56576c30214ff52294f8ce2def98",
- Subject: []byte("Merge branch 'lfs' into 'master'"),
- Body: []byte("Merge branch 'lfs' into 'master'\n\nAdd LFS tracking of \"*.lfs\" to .gitattributes\n\nSee merge request gitlab-org/gitlab-test!28"),
- Author: stanHu(1515740810),
- Committer: stanHu(1515740810),
- ParentIds: []string{
- "e63f41fe459e62e1228fcef60d7189127aeba95a",
- "55bc176024cfa3baaceb71db584c7e5df900ea65",
- },
- BodySize: 124,
- TreeId: "7e2f26d033ee47cd0745649d1a28277c56197921",
- },
- "e63f41fe459e62e1228fcef60d7189127aeba95a": {
- Id: "e63f41fe459e62e1228fcef60d7189127aeba95a",
- Subject: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'"),
- Body: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'\r\n\r\nUpdate README.md to include `Usage in testing and development`\r\n\r\nSee merge request !21"),
- Author: seanMcGivern(1491906794),
- Committer: seanMcGivern(1491906794),
- ParentIds: []string{
- "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- "4a24d82dbca5c11c61556f3b35ca472b7463187e",
- },
- BodySize: 154,
- TreeId: "86ec18bfe87ad42a782fdabd8310f9b7ac750f51",
- },
- "55bc176024cfa3baaceb71db584c7e5df900ea65": {
- Id: "55bc176024cfa3baaceb71db584c7e5df900ea65",
- Subject: []byte("LFS tracks \"*.lfs\" through .gitattributes"),
- Body: []byte("LFS tracks \"*.lfs\" through .gitattributes\n"),
- Author: jamesEdwardsJones(1515687321),
- Committer: jamesEdwardsJones(1515738427),
- ParentIds: []string{
- "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- },
- BodySize: 42,
- TreeId: "1970c07e0e1ce7fcf82edc2e3792564bd8ea3744",
- },
- "4a24d82dbca5c11c61556f3b35ca472b7463187e": {
- Id: "4a24d82dbca5c11c61556f3b35ca472b7463187e",
- Subject: []byte("Update README.md to include `Usage in testing and development`"),
- Body: []byte("Update README.md to include `Usage in testing and development`"),
- Author: lukeBennett(1491905339),
- Committer: lukeBennett(1491905339),
- ParentIds: []string{
- "b83d6e391c22777fca1ed3012fce84f633d7fed0",
- },
- BodySize: 62,
- TreeId: "86ec18bfe87ad42a782fdabd8310f9b7ac750f51",
- },
- "ce369011c189f62c815f5971d096b26759bab0d1": {
- Id: "ce369011c189f62c815f5971d096b26759bab0d1",
- Subject: []byte("Add file with a _flattable_ path"),
- Body: []byte("Add file with a _flattable_ path\n"),
- Author: alejandroRodriguez(1504382739),
- Committer: alejandroRodriguez(1504397760),
- ParentIds: []string{
- "913c66a37b4a45b9769037c55c2d238bd0942d2e",
- },
- BodySize: 33,
- TreeId: "729bb692f55d49149609dd1ceaaf1febbdec7d0d",
- },
- "ca47bfd5e930148c42ed74c3b561a8783e381f7f": {
- Id: "ca47bfd5e930148c42ed74c3b561a8783e381f7f",
- TreeId: "a5d06eba4fd37a4f7a39863c226e5ff66010deed",
- ParentIds: []string{
- "00850ec866c95e6516fca79614af7a868f6d3f43",
- },
- Subject: []byte("Add Modula-2 source file for language detection"),
- Body: []byte("Add Modula-2 source file for language detection\n"),
- BodySize: 48,
- Author: &gitalypb.CommitAuthor{
- Name: []byte("Jacob Vosmaer"),
- Email: []byte("jacob@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: 1501503403},
- Timezone: []byte("+0200"),
- },
- Committer: &gitalypb.CommitAuthor{
- Name: []byte("Ahmad Sherif"),
- Email: []byte("me@ahmadsherif.com"),
- Date: &timestamppb.Timestamp{Seconds: 1521033060},
- Timezone: []byte("+0100"),
- },
- },
-}
-
-func alejandroRodriguez(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Alejandro Rodríguez"),
- Email: []byte("alejorro70@gmail.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("-0300"),
- }
-}
-
-func ahmadSherif(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Ahmad Sherif"),
- Email: []byte("ahmad+gitlab-test@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0200"),
- }
-}
-
-func drewBlessing(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Drew Blessing"),
- Email: []byte("drew@blessing.io"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0000"),
- }
-}
-
-func dmitriyZaporozhets(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Dmitriy Zaporozhets"),
- Email: []byte("dmitriy.zaporozhets@gmail.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("-0800"),
- }
-}
-
-func jamesEdwardsJones(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("James Edwards-Jones"),
- Email: []byte("jedwardsjones@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0000"),
- }
-}
-
-func lukeBennett(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Luke \"Jared\" Bennett"),
- Email: []byte("lbennett@gitlab.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0000"),
- }
-}
-
-func seanMcGivern(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Sean McGivern"),
- Email: []byte("sean@mcgivern.me.uk"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0000"),
- }
-}
-
-func stanHu(ts int64) *gitalypb.CommitAuthor {
- return &gitalypb.CommitAuthor{
- Name: []byte("Stan Hu"),
- Email: []byte("stanhu@gmail.com"),
- Date: &timestamppb.Timestamp{Seconds: ts},
- Timezone: []byte("+0000"),
- }
-}
diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go
index e8fcbb203..1347c0a3f 100644
--- a/internal/gitaly/service/commit/find_commit_test.go
+++ b/internal/gitaly/service/commit/find_commit_test.go
@@ -328,7 +328,11 @@ func BenchmarkFindCommitWithCache(b *testing.B) {
func benchmarkFindCommit(b *testing.B, withCache bool) {
ctx := testhelper.Context(b)
- cfg, repo, _, client := setupCommitServiceWithRepo(b, ctx)
+ cfg, client := setupCommitService(b, ctx)
+
+ repo, _ := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{
+ Seed: "benchmark.git",
+ })
// get a list of revisions
gitCmdFactory := gittest.NewCommandFactory(b, cfg)
diff --git a/internal/gitaly/service/commit/find_commits_test.go b/internal/gitaly/service/commit/find_commits_test.go
index 0f68c6a87..50648526c 100644
--- a/internal/gitaly/service/commit/find_commits_test.go
+++ b/internal/gitaly/service/commit/find_commits_test.go
@@ -730,7 +730,12 @@ func getCommits(t *testing.T, ctx context.Context, client gitalypb.CommitService
func BenchmarkCommitStats(b *testing.B) {
ctx := testhelper.Context(b)
- _, repo, _, client := setupCommitServiceWithRepo(b, ctx)
+ cfg, client := setupCommitService(b, ctx)
+
+ repo, _ := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{
+ Seed: "benchmark.git",
+ })
+
request := &gitalypb.FindCommitsRequest{
Repository: repo,
Limit: 100,
diff --git a/internal/gitaly/service/commit/list_all_commits_test.go b/internal/gitaly/service/commit/list_all_commits_test.go
index 11f4b26ac..952d83cad 100644
--- a/internal/gitaly/service/commit/list_all_commits_test.go
+++ b/internal/gitaly/service/commit/list_all_commits_test.go
@@ -196,7 +196,11 @@ func BenchmarkListAllCommits(b *testing.B) {
b.StopTimer()
ctx := testhelper.Context(b)
- _, repo, _, client := setupCommitServiceWithRepo(b, ctx)
+ cfg, client := setupCommitService(b, ctx)
+
+ repo, _ := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{
+ Seed: "benchmark.git",
+ })
b.Run("ListAllCommits", func(b *testing.B) {
b.ReportAllocs()
diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go
index fc584d95e..d0b457d0e 100644
--- a/internal/gitaly/service/commit/testhelper_test.go
+++ b/internal/gitaly/service/commit/testhelper_test.go
@@ -37,21 +37,6 @@ func setupCommitService(
return cfg, newCommitServiceClient(tb, cfg.SocketPath)
}
-// setupCommitServiceWithRepo makes a basic configuration, creates a test repository and starts the service with the client.
-func setupCommitServiceWithRepo(
- tb testing.TB,
- ctx context.Context,
- opts ...testserver.GitalyServerOpt,
-) (config.Cfg, *gitalypb.Repository, string, gitalypb.CommitServiceClient) {
- cfg, client := setupCommitService(tb, ctx, opts...)
-
- repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
-
- return cfg, repo, repoPath, client
-}
-
func startTestServices(tb testing.TB, cfg config.Cfg, opts ...testserver.GitalyServerOpt) string {
tb.Helper()
return testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) {
diff --git a/internal/gitaly/service/hook/pack_objects_test.go b/internal/gitaly/service/hook/pack_objects_test.go
index 4d4d1a500..5e95b4927 100644
--- a/internal/gitaly/service/hook/pack_objects_test.go
+++ b/internal/gitaly/service/hook/pack_objects_test.go
@@ -34,18 +34,16 @@ import (
"google.golang.org/grpc/status"
)
-func runTestsWithRuntimeDir(t *testing.T, testFunc func(*testing.T, context.Context, string)) func(*testing.T, context.Context) {
+func runTestsWithRuntimeDir(t *testing.T, testFunc func(*testing.T, string)) {
t.Helper()
- return func(t *testing.T, ctx context.Context) {
- t.Run("no runtime dir", func(t *testing.T) {
- testFunc(t, ctx, "")
- })
+ t.Run("no runtime dir", func(t *testing.T) {
+ testFunc(t, "")
+ })
- t.Run("with runtime dir", func(t *testing.T) {
- testFunc(t, ctx, testhelper.TempDir(t))
- })
- }
+ t.Run("with runtime dir", func(t *testing.T) {
+ testFunc(t, testhelper.TempDir(t))
+ })
}
func cfgWithCache(t *testing.T, minOccurrences int) config.Cfg {
@@ -85,17 +83,24 @@ func TestParsePackObjectsArgs(t *testing.T) {
}
func TestServer_PackObjectsHook_separateContext(t *testing.T) {
+ testhelper.SkipQuarantinedTest(t, "https://gitlab.com/gitlab-org/gitaly/-/issues/5548")
+
t.Parallel()
runTestsWithRuntimeDir(t, testServerPackObjectsHookSeparateContextWithRuntimeDir)
}
-func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, ctx context.Context, runtimeDir string) {
+func testServerPackObjectsHookSeparateContextWithRuntimeDir(t *testing.T, runtimeDir string) {
+ ctx := testhelper.Context(t)
+
cfg := cfgWithCache(t, 0)
cfg.SocketPath = runHooksServer(t, cfg, nil)
ctx1, cancel := context.WithCancel(ctx)
defer cancel()
repo, repoPath := gittest.CreateRepository(t, ctx1, cfg)
+
+ // We write a commit with a large blob such that the response needs to be split over multiple messages.
+ // Otherwise it may happen that the request will finish before we can actually cancel the context.
commitID := gittest.WriteCommit(t, cfg, repoPath)
req := &gitalypb.PackObjectsHookWithSidechannelRequest{
@@ -213,7 +218,9 @@ func TestServer_PackObjectsHook_usesCache(t *testing.T) {
runTestsWithRuntimeDir(t, testServerPackObjectsHookUsesCache)
}
-func testServerPackObjectsHookUsesCache(t *testing.T, ctx context.Context, runtimeDir string) {
+func testServerPackObjectsHookUsesCache(t *testing.T, runtimeDir string) {
+ ctx := testhelper.Context(t)
+
testCases := []struct {
name string
makeRequests func(repository *gitalypb.Repository) []*gitalypb.PackObjectsHookWithSidechannelRequest
@@ -426,9 +433,11 @@ func TestServer_PackObjectsHookWithSidechannel(t *testing.T) {
runTestsWithRuntimeDir(t, testServerPackObjectsHookWithSidechannelWithRuntimeDir)
}
-func testServerPackObjectsHookWithSidechannelWithRuntimeDir(t *testing.T, ctx context.Context, runtimeDir string) {
+func testServerPackObjectsHookWithSidechannelWithRuntimeDir(t *testing.T, runtimeDir string) {
t.Parallel()
+ ctx := testhelper.Context(t)
+
type setupData struct {
repo *gitalypb.Repository
repoPath string
@@ -612,8 +621,13 @@ func TestServer_PackObjectsHookWithSidechannel_Canceled(t *testing.T) {
runTestsWithRuntimeDir(t, testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir)
}
-func testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir(t *testing.T, ctx context.Context, runtimeDir string) {
+func testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir(t *testing.T, runtimeDir string) {
+ ctx := testhelper.Context(t)
cfg := cfgWithCache(t, 0)
+ cfg.SocketPath = runHooksServer(t, cfg, nil)
+
+ repo, repoPath := gittest.CreateRepository(t, ctx, cfg)
+ commitID := gittest.WriteCommit(t, cfg, repoPath)
ctx, wt, err := hookPkg.SetupSidechannel(
ctx,
@@ -623,18 +637,13 @@ func testServerPackObjectsHookWithSidechannelCanceledWithRuntimeDir(t *testing.T
func(c *net.UnixConn) error {
// Simulate a client that successfully initiates a request, but hangs up
// before fully consuming the response.
- _, err := io.WriteString(c, "3dd08961455abf80ef9115f4afdc1c6f968b503c\n--not\n\n")
+ _, err := io.WriteString(c, fmt.Sprintf("%s\n--not\n\n", commitID))
return err
},
)
require.NoError(t, err)
defer testhelper.MustClose(t, wt)
- cfg.SocketPath = runHooksServer(t, cfg, nil)
- repo, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
- })
-
client, conn := newHooksClient(t, cfg.SocketPath)
defer conn.Close()
diff --git a/internal/gitaly/service/ref/find_all_tags_test.go b/internal/gitaly/service/ref/find_all_tags_test.go
index cfae77c17..5f1e982ce 100644
--- a/internal/gitaly/service/ref/find_all_tags_test.go
+++ b/internal/gitaly/service/ref/find_all_tags_test.go
@@ -727,7 +727,7 @@ func BenchmarkFindAllTags(b *testing.B) {
cfg, client := setupRefService(b)
repoProto, repoPath := gittest.CreateRepository(b, ctx, cfg, gittest.CreateRepositoryConfig{
- Seed: gittest.SeedGitLabTest,
+ Seed: "benchmark.git",
})
for i := 0; i < 1000; i++ {