From 7c797ae2a1f0609fbf154dae1e92824e7c6962e6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 14 Dec 2022 13:01:22 +0100 Subject: repository: Refactor test for CreateRepositoryFromURL Refactor one of the tests for CreateRepositoryFromURL to better match our modern coding style. --- .../repository/create_repository_from_url_test.go | 43 +++++++++------------- 1 file changed, 17 insertions(+), 26 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 0f5687a62..3d29cb66b 100644 --- a/internal/gitaly/service/repository/create_repository_from_url_test.go +++ b/internal/gitaly/service/repository/create_repository_from_url_test.go @@ -9,11 +9,13 @@ import ( "net/http" "os" "path/filepath" + "strings" "testing" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/v15/internal/git" "gitlab.com/gitlab-org/gitaly/v15/internal/git/gittest" + "gitlab.com/gitlab-org/gitaly/v15/internal/helper/text" "gitlab.com/gitlab-org/gitaly/v15/internal/praefect/praefectutil" "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg" @@ -61,48 +63,37 @@ func TestCreateRepositoryFromURL_successful(t *testing.T) { func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) { t.Parallel() - ctx := testhelper.Context(t) + ctx := testhelper.Context(t) cfg, _, repoPath, client := setupRepositoryServiceFromMirror(t, ctx) gitCmdFactory := gittest.NewCommandFactory(t, cfg) - importedRepo := &gitalypb.Repository{ - RelativePath: "imports/test-repo-imported-mirror.git", - StorageName: cfg.Storages[0].Name, - } - user := "username123" password := "password321localhost" port := gitServerWithBasicAuth(t, ctx, gitCmdFactory, user, password, repoPath) - url := fmt.Sprintf("http://%s:%s@localhost:%d/%s", user, password, port, filepath.Base(repoPath)) - host := "www.example.com" - authToken := "GL-Geo EhEhKSUk_385GSLnS7BI:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoie1wic2NvcGVcIjpcInJvb3QvZ2l0bGFiLWNlXCJ9IiwianRpIjoiNmQ4ZDM1NGQtZjUxYS00MDQ5LWExZjctMjUyMjk4YmQwMTI4IiwiaWF0IjoxNjQyMDk1MzY5LCJuYmYiOjE2NDIwOTUzNjQsImV4cCI6MTY0MjA5NTk2OX0.YEpfzg8305dUqkYOiB7_dhbL0FVSaUPgpSpMuKrgNrg" - mirror := true - - req := &gitalypb.CreateRepositoryFromURLRequest{ - Repository: importedRepo, - Url: url, - HttpHost: host, - HttpAuthorizationHeader: authToken, - Mirror: mirror, + importedRepo := &gitalypb.Repository{ + RelativePath: "imports/test-repo-imported-mirror.git", + StorageName: cfg.Storages[0].Name, } - _, err := client.CreateRepositoryFromURL(ctx, req) + _, err := client.CreateRepositoryFromURL(ctx, &gitalypb.CreateRepositoryFromURLRequest{ + Repository: importedRepo, + Url: fmt.Sprintf("http://%s:%s@localhost:%d/%s", user, password, port, filepath.Base(repoPath)), + HttpHost: "www.example.com", + HttpAuthorizationHeader: "GL-Geo EhEhKSUk_385GSLnS7BI:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoie1wic2NvcGVcIjpcInJvb3QvZ2l0bGFiLWNlXCJ9IiwianRpIjoiNmQ4ZDM1NGQtZjUxYS00MDQ5LWExZjctMjUyMjk4YmQwMTI4IiwiaWF0IjoxNjQyMDk1MzY5LCJuYmYiOjE2NDIwOTUzNjQsImV4cCI6MTY0MjA5NTk2OX0.YEpfzg8305dUqkYOiB7_dhbL0FVSaUPgpSpMuKrgNrg", + Mirror: true, + }) require.NoError(t, err) importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, importedRepo)) - gittest.Exec(t, cfg, "-C", importedRepoPath, "fsck") + require.Empty(t, gittest.Exec(t, cfg, "-C", importedRepoPath, "remote")) - remotes := gittest.Exec(t, cfg, "-C", importedRepoPath, "remote") - require.NotContains(t, string(remotes), "origin") - - references := gittest.Exec(t, cfg, "-C", importedRepoPath, "show-ref", "--abbrev") - require.Contains(t, string(references), "refs/merge-requests") + references := strings.Split(text.ChompBytes(gittest.Exec(t, cfg, "-C", importedRepoPath, "for-each-ref", "--format=%(refname)")), "\n") + require.Contains(t, references, "refs/merge-requests/1/head") - _, err = os.Lstat(filepath.Join(importedRepoPath, "hooks")) - require.True(t, os.IsNotExist(err), "hooks directory should not have been created") + require.NoDirExists(t, filepath.Join(importedRepoPath, "hooks")) } func TestCreateRepositoryFromURL_existingTarget(t *testing.T) { -- cgit v1.2.3 From 6839a10949f2141a50f674d0777a338ee7566345 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 14 Dec 2022 13:07:13 +0100 Subject: repository: Manually seed repo in CreateRepositoryFromURL test The test that verifies CreateRepositoryFromURL's behaviour with a bunch of optional parameters is the last remnant that still uses our beloved "gitlab-test-mirror.git" test repository. And as we're converting our test setups to generate test data at runtime instead of using pre-seeded repositories we're not going to add any other callsites that need this seed repository. Refactor the test to generate the test data at runtime. What we really care about in this context is a repository that has references that would not be cloned by default to verify that we indeed clone them when the `Mirror` parameter is set to `true`. So let's generate the data like that and get rid of the now-unused helper function that sets up the old "gitlab-test-mirror.git" repository seed. --- .../repository/create_repository_from_url_test.go | 18 +++++++++++------- internal/gitaly/service/repository/testhelper_test.go | 10 ---------- 2 files changed, 11 insertions(+), 17 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 3d29cb66b..6d4ba8da0 100644 --- a/internal/gitaly/service/repository/create_repository_from_url_test.go +++ b/internal/gitaly/service/repository/create_repository_from_url_test.go @@ -65,12 +65,16 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) t.Parallel() ctx := testhelper.Context(t) - cfg, _, repoPath, client := setupRepositoryServiceFromMirror(t, ctx) + cfg, client := setupRepositoryServiceWithoutRepo(t) gitCmdFactory := gittest.NewCommandFactory(t, cfg) + _, remoteRepoPath := gittest.CreateRepository(t, ctx, cfg) + gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithBranch(git.DefaultBranch)) + gittest.WriteCommit(t, cfg, remoteRepoPath, gittest.WithReference("refs/merge-requests/1/head")) + user := "username123" password := "password321localhost" - port := gitServerWithBasicAuth(t, ctx, gitCmdFactory, user, password, repoPath) + port := gitServerWithBasicAuth(t, ctx, gitCmdFactory, user, password, remoteRepoPath) importedRepo := &gitalypb.Repository{ RelativePath: "imports/test-repo-imported-mirror.git", @@ -79,7 +83,7 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) _, err := client.CreateRepositoryFromURL(ctx, &gitalypb.CreateRepositoryFromURLRequest{ Repository: importedRepo, - Url: fmt.Sprintf("http://%s:%s@localhost:%d/%s", user, password, port, filepath.Base(repoPath)), + Url: fmt.Sprintf("http://%s:%s@localhost:%d/%s", user, password, port, filepath.Base(remoteRepoPath)), HttpHost: "www.example.com", HttpAuthorizationHeader: "GL-Geo EhEhKSUk_385GSLnS7BI:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoie1wic2NvcGVcIjpcInJvb3QvZ2l0bGFiLWNlXCJ9IiwianRpIjoiNmQ4ZDM1NGQtZjUxYS00MDQ5LWExZjctMjUyMjk4YmQwMTI4IiwiaWF0IjoxNjQyMDk1MzY5LCJuYmYiOjE2NDIwOTUzNjQsImV4cCI6MTY0MjA5NTk2OX0.YEpfzg8305dUqkYOiB7_dhbL0FVSaUPgpSpMuKrgNrg", Mirror: true, @@ -89,10 +93,10 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T) importedRepoPath := filepath.Join(cfg.Storages[0].Path, gittest.GetReplicaPath(t, ctx, cfg, importedRepo)) gittest.Exec(t, cfg, "-C", importedRepoPath, "fsck") require.Empty(t, gittest.Exec(t, cfg, "-C", importedRepoPath, "remote")) - - references := strings.Split(text.ChompBytes(gittest.Exec(t, cfg, "-C", importedRepoPath, "for-each-ref", "--format=%(refname)")), "\n") - require.Contains(t, references, "refs/merge-requests/1/head") - + require.Equal(t, + []string{"refs/heads/" + git.DefaultBranch, "refs/merge-requests/1/head"}, + strings.Split(text.ChompBytes(gittest.Exec(t, cfg, "-C", importedRepoPath, "for-each-ref", "--format=%(refname)")), "\n"), + ) require.NoDirExists(t, filepath.Join(importedRepoPath, "hooks")) } diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index 0d306d327..d50f016b2 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -145,16 +145,6 @@ func setupRepositoryService(tb testing.TB, ctx context.Context, opts ...testserv return cfg, repo, repoPath, client } -// Sets up a repository that has been cloned using `--mirror` which contains GitLab internal references -func setupRepositoryServiceFromMirror(tb testing.TB, ctx context.Context, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { - cfg, client := setupRepositoryServiceWithoutRepo(tb, opts...) - - repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ - Seed: gittest.SeedGitLabTestMirror, - }) - return cfg, repo, repoPath, client -} - func setupRepositoryServiceWithoutRepo(tb testing.TB, opts ...testserver.GitalyServerOpt) (config.Cfg, gitalypb.RepositoryServiceClient) { cfg := testcfg.Build(tb) -- cgit v1.2.3 From 455dd16d8763eeb030dcb893972fafd823cdb9bc Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 14 Dec 2022 13:15:04 +0100 Subject: ruby: Drop helpers to generate seed repository There are some long-forgotten spec helpers in our Ruby code to generate a seed repository. It is obvious that they haven't been used by anyone since ages as they still have the intent to put the generated seed repo into our `internal/testhelper/testdata`. We have long since migrated seed repositories to live in our `_build/testrepos` directory though. Remove the helper scripts. --- ruby/spec/support/generate-seed-repo-rb | 162 -------------------------------- ruby/spec/support/helpers/seed_repo.rb | 154 ------------------------------ 2 files changed, 316 deletions(-) delete mode 100755 ruby/spec/support/generate-seed-repo-rb delete mode 100644 ruby/spec/support/helpers/seed_repo.rb diff --git a/ruby/spec/support/generate-seed-repo-rb b/ruby/spec/support/generate-seed-repo-rb deleted file mode 100755 index b82297f53..000000000 --- a/ruby/spec/support/generate-seed-repo-rb +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env ruby -# -# # generate-seed-repo-rb -# -# This script generates the seed_repo.rb file used by lib/gitlab/git -# tests. The seed_repo.rb file needs to be updated anytime there is a -# Git push to https://gitlab.com/gitlab-org/gitlab-git-test. -# -# Usage: -# -# ./spec/support/generate-seed-repo-rb > spec/support/helpers/seed_repo.rb -# -# - -require 'erb' -require 'tempfile' - -SOURCE = File.expand_path('../../../internal/testhelper/testdata/data/gitlab-git-test.git', __dir__).freeze -SCRIPT_NAME = 'generate-seed-repo-rb'.freeze -REPO_NAME = 'gitlab-git-test.git'.freeze - -def main - Dir.mktmpdir do |dir| - abort "git clone failed" unless system("git", "clone", "--bare", SOURCE.to_s, REPO_NAME.to_s, chdir: dir) - - repo = File.join(dir, REPO_NAME) - erb = ERB.new(DATA.read) - erb.run(binding) - end -end - -def capture!(cmd, dir) - output = IO.popen(cmd, 'r', chdir: dir, &:read) - raise "command failed with #{$?}: #{cmd.join(' ')}" unless $?.success? - - output.chomp -end - -main - -__END__ -# This file is generated by <%= SCRIPT_NAME %>. Do not edit this file manually. -# -# Seed repo: -<%= capture!(%w{git log --format=#\ %H\ %s}, repo) %> - -module SeedRepo - module BigCommit - ID = "913c66a37b4a45b9769037c55c2d238bd0942d2e".freeze - PARENT_ID = "cfe32cf61b73a0d5e9f13e774abde7ff789b1660".freeze - MESSAGE = "Files, encoding and much more".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES_COUNT = 2 - end - - module Commit - ID = "570e7b2abdd848b95f2f578043fc23bd6f6fd24d".freeze - PARENT_ID = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9".freeze - MESSAGE = "Change some files\n\nSigned-off-by: Dmitriy Zaporozhets \n".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES = ["files/ruby/popen.rb", "files/ruby/regex.rb"].freeze - FILES_COUNT = 2 - C_FILE_PATH = "files/ruby".freeze - C_FILES = ["popen.rb", "regex.rb", "version_info.rb"].freeze - BLOB_FILE = %{%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n}.freeze - BLOB_FILE_PATH = "app/views/keys/show.html.haml".freeze - end - - module EmptyCommit - ID = "b0e52af38d7ea43cf41d8a6f2471351ac036d6c9".freeze - PARENT_ID = "40f4a7a617393735a95a0bb67b08385bc1e7c66d".freeze - MESSAGE = "Empty commit".freeze - AUTHOR_FULL_NAME = "Rémy Coutable".freeze - FILES = [].freeze - FILES_COUNT = FILES.count - end - - module EncodingCommit - ID = "40f4a7a617393735a95a0bb67b08385bc1e7c66d".freeze - PARENT_ID = "66028349a123e695b589e09a36634d976edcc5e8".freeze - MESSAGE = "Add ISO-8859-encoded file".freeze - AUTHOR_FULL_NAME = "Stan Hu".freeze - FILES = ["encoding/iso8859.txt"].freeze - FILES_COUNT = FILES.count - end - - module FirstCommit - ID = "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863".freeze - PARENT_ID = nil - MESSAGE = "Initial commit".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES = ["LICENSE", ".gitignore", "README.md"].freeze - FILES_COUNT = 3 - end - - module LastCommit - ID = <%= capture!(%w[git show -s --format=%H HEAD], repo).inspect %>.freeze - PARENT_ID = <%= capture!(%w[git show -s --format=%P HEAD], repo).split.last.inspect %>.freeze - MESSAGE = <%= capture!(%w[git show -s --format=%s HEAD], repo).inspect %>.freeze - AUTHOR_FULL_NAME = <%= capture!(%w[git show -s --format=%an HEAD], repo).inspect %>.freeze - FILES = <%= - parents = capture!(%w[git show -s --format=%P HEAD], repo).split - merge_base = parents.size > 1 ? capture!(%w[git merge-base] + parents, repo) : parents.first - capture!( %W[git diff --name-only #{merge_base}..HEAD --], repo).split("\n").inspect - %>.freeze - FILES_COUNT = FILES.count - end - - module Repo - HEAD = "master".freeze - BRANCHES = %w[ -<%= capture!(%W[git for-each-ref --format=#{' ' * 3}%(refname:strip=2) refs/heads/], repo) %> - ].freeze - TAGS = %w[ -<%= capture!(%W[git for-each-ref --format=#{' ' * 3}%(refname:strip=2) refs/tags/], repo) %> - ].freeze - end - - module RubyBlob - ID = "7e3e39ebb9b2bf433b4ad17313770fbe4051649c".freeze - NAME = "popen.rb".freeze - CONTENT = <<-BLOB_CONTENT.freeze -require 'fileutils' -require 'open3' - -module Popen - extend self - - def popen(cmd, path=nil) - unless cmd.is_a?(Array) - raise RuntimeError, "System commands must be given as an array of strings" - end - - path ||= Dir.pwd - - vars = { - "PWD" => path - } - - options = { - chdir: path - } - - unless File.directory?(path) - FileUtils.mkdir_p(path) - end - - @cmd_output = "" - @cmd_status = 0 - - Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| - @cmd_output << stdout.read - @cmd_output << stderr.read - @cmd_status = wait_thr.value.exitstatus - end - - return @cmd_output, @cmd_status - end -end - BLOB_CONTENT - end -end diff --git a/ruby/spec/support/helpers/seed_repo.rb b/ruby/spec/support/helpers/seed_repo.rb deleted file mode 100644 index 19a9b2de6..000000000 --- a/ruby/spec/support/helpers/seed_repo.rb +++ /dev/null @@ -1,154 +0,0 @@ -# This file is generated by generate-seed-repo-rb. Do not edit this file manually. -# -# Seed repo: -# 4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 Merge branch 'master' into 'master' -# 0e1b353b348f8477bdbec1ef47087171c5032cd9 adds an executable with different permissions -# 0e50ec4d3c7ce42ab74dda1d422cb2cbffe1e326 Merge branch 'lfs_pointers' into 'master' -# 33bcff41c232a11727ac6d660bd4b0c2ba86d63d Add valid and invalid lfs pointers -# 732401c65e924df81435deb12891ef570167d2e2 Update year in license file -# b0e52af38d7ea43cf41d8a6f2471351ac036d6c9 Empty commit -# 40f4a7a617393735a95a0bb67b08385bc1e7c66d Add ISO-8859-encoded file -# 66028349a123e695b589e09a36634d976edcc5e8 Merge branch 'add-comments-to-gitmodules' into 'master' -# de5714f34c4e34f1d50b9a61a2e6c9132fe2b5fd Add comments to the end of .gitmodules to test parsing -# fa1b1e6c004a68b7d8763b86455da9e6b23e36d6 Merge branch 'add-files' into 'master' -# eb49186cfa5c4338011f5f590fac11bd66c5c631 Add submodules nested deeper than the root -# 18d9c205d0d22fdf62bc2f899443b83aafbf941f Add executables and links files -# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com -# 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files -# 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules -# d14d6c0abdd253381df51a723d58691b2ee1ab08 Remove ds_store files -# c1acaa58bbcbc3eafe538cb8274ba387047b69f8 Ignore DS files -# ae73cb07c9eeaf35924a10f713b364d32b2dd34f Binary file added -# 874797c3a73b60d2187ed6e2fcabd289ff75171e Ruby files modified -# 2f63565e7aac07bcdadb654e253078b727143ec4 Modified image -# 33f3729a45c02fc67d00adb1b8bca394b0e761d9 Image added -# 913c66a37b4a45b9769037c55c2d238bd0942d2e Files, encoding and much more -# cfe32cf61b73a0d5e9f13e774abde7ff789b1660 Add submodule -# 6d394385cf567f80a8fd85055db1ab4c5295806f Added contributing guide -# 1a0b36b3cdad1d2ee32457c102a8c0b7056fa863 Initial commit - -module SeedRepo - module BigCommit - ID = "913c66a37b4a45b9769037c55c2d238bd0942d2e".freeze - PARENT_ID = "cfe32cf61b73a0d5e9f13e774abde7ff789b1660".freeze - MESSAGE = "Files, encoding and much more".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES_COUNT = 2 - end - - module Commit - ID = "570e7b2abdd848b95f2f578043fc23bd6f6fd24d".freeze - PARENT_ID = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9".freeze - MESSAGE = "Change some files\n\nSigned-off-by: Dmitriy Zaporozhets \n".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES = ["files/ruby/popen.rb", "files/ruby/regex.rb"].freeze - FILES_COUNT = 2 - C_FILE_PATH = "files/ruby".freeze - C_FILES = ["popen.rb", "regex.rb", "version_info.rb"].freeze - BLOB_FILE = %(%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n).freeze - BLOB_FILE_PATH = "app/views/keys/show.html.haml".freeze - end - - module EmptyCommit - ID = "b0e52af38d7ea43cf41d8a6f2471351ac036d6c9".freeze - PARENT_ID = "40f4a7a617393735a95a0bb67b08385bc1e7c66d".freeze - MESSAGE = "Empty commit".freeze - AUTHOR_FULL_NAME = "Rémy Coutable".freeze - FILES = [].freeze - FILES_COUNT = FILES.count - end - - module EncodingCommit - ID = "40f4a7a617393735a95a0bb67b08385bc1e7c66d".freeze - PARENT_ID = "66028349a123e695b589e09a36634d976edcc5e8".freeze - MESSAGE = "Add ISO-8859-encoded file".freeze - AUTHOR_FULL_NAME = "Stan Hu".freeze - FILES = ["encoding/iso8859.txt"].freeze - FILES_COUNT = FILES.count - end - - module FirstCommit - ID = "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863".freeze - PARENT_ID = nil - MESSAGE = "Initial commit".freeze - AUTHOR_FULL_NAME = "Dmitriy Zaporozhets".freeze - FILES = ["LICENSE", ".gitignore", "README.md"].freeze - FILES_COUNT = 3 - end - - module LastCommit - ID = "4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6".freeze - PARENT_ID = "0e1b353b348f8477bdbec1ef47087171c5032cd9".freeze - MESSAGE = "Merge branch 'master' into 'master'".freeze - AUTHOR_FULL_NAME = "Stan Hu".freeze - FILES = ["bin/executable"].freeze - FILES_COUNT = FILES.count - end - - module Repo - HEAD = "master".freeze - BRANCHES = %w[ - feature - fix - fix-blob-path - fix-existing-submodule-dir - fix-mode - gitattributes - gitattributes-updated - master - merge-test - rd-add-file-larger-than-1-mb - Ääh-test-utf-8 - ].freeze - TAGS = %w[ - v1.0.0 - v1.1.0 - v1.2.0 - v1.2.1 - ].freeze - end - - module RubyBlob - ID = "7e3e39ebb9b2bf433b4ad17313770fbe4051649c".freeze - NAME = "popen.rb".freeze - CONTENT = <<~BLOB_CONTENT.freeze - require 'fileutils' - require 'open3' - - module Popen - extend self - - def popen(cmd, path=nil) - unless cmd.is_a?(Array) - raise RuntimeError, "System commands must be given as an array of strings" - end - - path ||= Dir.pwd - - vars = { - "PWD" => path - } - - options = { - chdir: path - } - - unless File.directory?(path) - FileUtils.mkdir_p(path) - end - - @cmd_output = "" - @cmd_status = 0 - - Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| - @cmd_output << stdout.read - @cmd_output << stderr.read - @cmd_status = wait_thr.value.exitstatus - end - - return @cmd_output, @cmd_status - end - end - BLOB_CONTENT - end -end -- cgit v1.2.3 From 362a1c692293c5e375ac46dfad5ab37faa35d7c1 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 14 Dec 2022 13:08:26 +0100 Subject: tests: Remove unneeded seed repositories Remove infrastructure to clone the "gitlab-test-mirror.git" and "gitlab-git-test.git" seed repositories. They are not used anymore. --- Makefile | 14 +------------- _support/gitlab-git-test.git-packed-refs | 20 -------------------- doc/test_repos.md | 1 - internal/git/gittest/repo.go | 3 --- ruby/spec/test_repo_helper.rb | 5 +---- 5 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 _support/gitlab-git-test.git-packed-refs diff --git a/Makefile b/Makefile index 566c83937..18440fb3f 100644 --- a/Makefile +++ b/Makefile @@ -234,8 +234,6 @@ TEST_TMP_DIR ?= TEST_LOG_DIR ?= TEST_REPO_DIR := ${BUILD_DIR}/testrepos TEST_REPO := ${TEST_REPO_DIR}/gitlab-test.git -TEST_REPO_MIRROR := ${TEST_REPO_DIR}/gitlab-test-mirror.git -TEST_REPO_GIT := ${TEST_REPO_DIR}/gitlab-git-test.git BENCHMARK_REPO := ${TEST_REPO_DIR}/benchmark.git # All executables provided by Gitaly. @@ -362,7 +360,7 @@ prepare-tests: libgit2 prepare-test-repos ${RUBY_BUNDLE_FILE} ${GOTESTSUM} ${GIT prepare-debug: ${DELVE} .PHONY: prepare-test-repos -prepare-test-repos: ${TEST_REPO_MIRROR} ${TEST_REPO} ${TEST_REPO_GIT} +prepare-test-repos: ${TEST_REPO} .PHONY: test ## Run Go and Ruby tests. @@ -710,9 +708,6 @@ ${PROTOC_GEN_GO}: TOOL_PACKAGE = google.golang.org/protobuf/cmd/protoc-gen-g ${PROTOC_GEN_GO_GRPC}:TOOL_PACKAGE = google.golang.org/grpc/cmd/protoc-gen-go-grpc ${DELVE}: TOOL_PACKAGE = github.com/go-delve/delve/cmd/dlv -${TEST_REPO_MIRROR}: - ${GIT} clone --mirror ${GIT_QUIET} https://gitlab.com/gitlab-org/gitlab-test.git $@ - ${TEST_REPO}: ${GIT} clone --bare ${GIT_QUIET} https://gitlab.com/gitlab-org/gitlab-test.git $@ @ # Git notes aren't fetched by default with git clone @@ -722,12 +717,5 @@ ${TEST_REPO}: ${Q}cp ${SOURCE_DIR}/_support/gitlab-test.git-packed-refs $@/packed-refs ${Q}${GIT} -C $@ fsck --no-progress --no-dangling -${TEST_REPO_GIT}: - ${GIT} clone --bare ${GIT_QUIET} https://gitlab.com/gitlab-org/gitlab-git-test.git $@ - ${Q}rm -rf $@/refs - ${Q}mkdir -p $@/refs/heads $@/refs/tags - ${Q}cp ${SOURCE_DIR}/_support/gitlab-git-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-git-test.git-packed-refs b/_support/gitlab-git-test.git-packed-refs deleted file mode 100644 index 4fed4130f..000000000 --- a/_support/gitlab-git-test.git-packed-refs +++ /dev/null @@ -1,20 +0,0 @@ -# pack-refs with: peeled fully-peeled sorted -0b4bc9a49b562e85de7cc9e834518ea6828729b9 refs/heads/feature -12d65c8dd2b2676fa3ac47d955accc085a37a9c1 refs/heads/fix -6473c90867124755509e100d0d35ebdc85a0b6ae refs/heads/fix-blob-path -58fa1a3af4de73ea83fe25a1ef1db8e0c56f67e5 refs/heads/fix-existing-submodule-dir -40f4a7a617393735a95a0bb67b08385bc1e7c66d refs/heads/fix-mode -9abd6a8c113a2dd76df3fdb3d58a8cec6db75f8d refs/heads/gitattributes -46e1395e609395de004cacd4b142865ab0e52a29 refs/heads/gitattributes-updated -4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 refs/heads/master -5937ac0a7beb003549fc5fd26fc247adbce4a52e refs/heads/merge-test -c54ad072fabee9f7bf9b2c6c67089db97ebfbecd refs/heads/rd-add-file-larger-than-1-mb -4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6 refs/heads/Ääh-test-utf-8 -f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 refs/tags/v1.0.0 -^6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 -8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b refs/tags/v1.1.0 -^5937ac0a7beb003549fc5fd26fc247adbce4a52e -10d64eed7760f2811ee2d64b44f1f7d3b364f17b refs/tags/v1.2.0 -^eb49186cfa5c4338011f5f590fac11bd66c5c631 -2ac1f24e253e08135507d0830508febaaccf02ee refs/tags/v1.2.1 -^fa1b1e6c004a68b7d8763b86455da9e6b23e36d6 diff --git a/doc/test_repos.md b/doc/test_repos.md index 940fdf82a..651196fe5 100644 --- a/doc/test_repos.md +++ b/doc/test_repos.md @@ -6,7 +6,6 @@ second one for free when importing code from `gitlab-ce`. These repositories get cloned by `make prepare-tests`. They end up in: - `_build/testrepos/gitlab-test.git` -- `_build/testrepos/gitlab-git-test.git` To prevent fragile tests, we use fixed `packed-refs` files for these repositories. They get installed by make (see `_support/makegen.go`) diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go index b1561a103..acf310535 100644 --- a/internal/git/gittest/repo.go +++ b/internal/git/gittest/repo.go @@ -36,9 +36,6 @@ const ( // SeedGitLabTest is the path of the gitlab-test.git repository in _build/testrepos SeedGitLabTest = "gitlab-test.git" - - // SeedGitLabTestMirror is the path of the gitlab-test-mirror.git repository in _build/testrepos - SeedGitLabTestMirror = "gitlab-test-mirror.git" ) // InitRepoDir creates a temporary directory for a repo, without initializing it diff --git a/ruby/spec/test_repo_helper.rb b/ruby/spec/test_repo_helper.rb index c10445b3a..2a05f2c33 100644 --- a/ruby/spec/test_repo_helper.rb +++ b/ruby/spec/test_repo_helper.rb @@ -29,8 +29,6 @@ DEFAULT_STORAGE_DIR = File.join(TMP_DIR, 'repositories', __dir__) DEFAULT_STORAGE_NAME = 'default'.freeze TEST_REPO_PATH = File.join(DEFAULT_STORAGE_DIR, 'gitlab-test.git') TEST_REPO_ORIGIN = '../_build/testrepos/gitlab-test.git'.freeze -GIT_TEST_REPO_PATH = File.join(DEFAULT_STORAGE_DIR, 'gitlab-git-test.git') -GIT_TEST_REPO_ORIGIN = '../_build/testrepos/gitlab-git-test.git'.freeze module TestRepo def self.prepare_test_repository @@ -39,8 +37,7 @@ module TestRepo FileUtils.mkdir_p(DEFAULT_STORAGE_DIR) { - TEST_REPO_ORIGIN => TEST_REPO_PATH, - GIT_TEST_REPO_ORIGIN => GIT_TEST_REPO_PATH + TEST_REPO_ORIGIN => TEST_REPO_PATH }.each do |origin, path| next if File.directory?(path) -- cgit v1.2.3