diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-04 12:09:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-04 12:09:31 +0300 |
commit | 54cd986c9f16b5f7587b072ee8eb84bbf6642e8c (patch) | |
tree | c1ce6fbbcb3c9b90132e8459044ac06d255c54a9 /spec | |
parent | 529d16eb9ca2b5fd437fbd9518a3f88f0429cb3a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
15 files changed, 76 insertions, 89 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 86321350962..2ed71975d0c 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -328,9 +328,10 @@ FactoryBot.define do trait :test_repo do after :create do |project| - TestEnv.copy_repo(project, - bare_repo: TestEnv.factory_repo_path_bare, - refs: TestEnv::BRANCH_SHA) + # There are various tests that rely on there being no repository cache. + # Using raw avoids caching. + repo = Gitlab::GlRepository::PROJECT.repository_for(project).raw + repo.create_from_bundle(TestEnv.factory_repo_bundle_path) end end @@ -428,9 +429,10 @@ FactoryBot.define do path { 'forked-gitlabhq' } after :create do |project| - TestEnv.copy_repo(project, - bare_repo: TestEnv.forked_repo_path_bare, - refs: TestEnv::FORKED_BRANCH_SHA) + # There are various tests that rely on there being no repository cache. + # Using raw avoids caching. + repo = Gitlab::GlRepository::PROJECT.repository_for(project).raw + repo.create_from_bundle(TestEnv.forked_repo_bundle_path) end end diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb index 21e1d911f96..75e2ef3db02 100644 --- a/spec/factories/snippets.rb +++ b/spec/factories/snippets.rb @@ -9,6 +9,10 @@ FactoryBot.define do file_name { generate(:filename) } secret { false } + transient do + repository_storage { 'default' } + end + trait :public do visibility_level { Snippet::PUBLIC } end @@ -23,12 +27,13 @@ FactoryBot.define do # Test repository - https://gitlab.com/gitlab-org/gitlab-test trait :repository do - after :create do |snippet| - TestEnv.copy_repo(snippet, - bare_repo: TestEnv.factory_repo_path_bare, - refs: TestEnv::BRANCH_SHA) + after :create do |snippet, evaluator| + snippet.track_snippet_repository(evaluator.repository_storage) - snippet.track_snippet_repository(snippet.repository.storage) + # There are various tests that rely on there being no repository cache. + # Using raw avoids caching. + repo = Gitlab::GlRepository::SNIPPET.repository_for(snippet).raw + repo.create_from_bundle(TestEnv.factory_repo_bundle_path) end end diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index d906bb396be..727f9aa486e 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -233,6 +233,8 @@ RSpec.describe 'Branches' do end context 'with one or more pipeline', :js do + let(:project) { create(:project, :public, :empty_repo) } + before do sha = create_file(branch_name: "branch") create(:ci_pipeline, diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb index 11b7ab08fb2..9314f616c44 100644 --- a/spec/finders/branches_finder_spec.rb +++ b/spec/finders/branches_finder_spec.rb @@ -181,17 +181,17 @@ RSpec.describe BranchesFinder do it 'filters branches' do result = subject - expect(result.map(&:name)).to eq(%w(feature_conflict fix)) + expect(result.map(&:name)).to eq(%w(feature_conflict few-commits)) end end context 'by next page_token and per_page' do - let(:params) { { page_token: 'fix', per_page: 2 } } + let(:params) { { page_token: 'few-commits', per_page: 2 } } it 'filters branches' do result = subject - expect(result.map(&:name)).to eq(%w(flatten-dir gitattributes)) + expect(result.map(&:name)).to eq(%w(fix flatten-dir)) end end @@ -254,7 +254,7 @@ RSpec.describe BranchesFinder do it 'falls back to default execute and ignore paginations' do result = subject - expect(result.map(&:name)).to eq(%w(feature feature_conflict fix flatten-dir)) + expect(result.map(&:name)).to eq(%w(feature feature_conflict few-commits fix flatten-dir)) end end end diff --git a/spec/fixtures/api/schemas/public_api/v4/commit/basic.json b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json index 227b5a20af3..da7a9fcb7f3 100644 --- a/spec/fixtures/api/schemas/public_api/v4/commit/basic.json +++ b/spec/fixtures/api/schemas/public_api/v4/commit/basic.json @@ -19,7 +19,7 @@ "id": { "type": ["string", "null"] }, "short_id": { "type": ["string", "null"] }, "title": { "type": "string" }, - "created_at": { "type": "string", "format": "date-time" }, + "created_at": { "type": "string" }, "parent_ids": { "type": ["array", "null"], "items": { @@ -30,10 +30,10 @@ "message": { "type": "string" }, "author_name": { "type": "string" }, "author_email": { "type": "string" }, - "authored_date": { "type": "string", "format": "date-time" }, + "authored_date": { "type": "string" }, "committer_name": { "type": "string" }, "committer_email": { "type": "string" }, - "committed_date": { "type": "string", "format": "date-time" }, + "committed_date": { "type": "string" }, "web_url": { "type": "string" } } } diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js index ca666e38291..9982286c625 100644 --- a/spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js +++ b/spec/frontend/packages_and_registries/container_registry/explorer/components/details_page/details_header_spec.js @@ -18,7 +18,6 @@ import { CLEANUP_SCHEDULED_TOOLTIP, CLEANUP_ONGOING_TOOLTIP, CLEANUP_UNFINISHED_TOOLTIP, - ROOT_IMAGE_TEXT, ROOT_IMAGE_TOOLTIP, } from '~/packages_and_registries/container_registry/explorer/constants'; import getContainerRepositoryMetadata from '~/packages_and_registries/container_registry/explorer/graphql/queries/get_container_repository_metadata.query.graphql'; @@ -35,6 +34,7 @@ describe('Details Header', () => { canDelete: true, project: { visibility: 'public', + path: 'path', containerExpirationPolicy: { enabled: false, }, @@ -98,8 +98,8 @@ describe('Details Header', () => { return waitForPromises(); }); - it('root image ', () => { - expect(findTitle().text()).toBe(ROOT_IMAGE_TEXT); + it('root image shows project path name', () => { + expect(findTitle().text()).toBe('path'); }); it('has an icon', () => { diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/image_list_row_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/image_list_row_spec.js index 979e1500d7d..301acf238e7 100644 --- a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/image_list_row_spec.js +++ b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/image_list_row_spec.js @@ -12,7 +12,6 @@ import { IMAGE_DELETE_SCHEDULED_STATUS, IMAGE_MIGRATING_STATE, SCHEDULED_STATUS, - ROOT_IMAGE_TEXT, COPY_IMAGE_PATH_TITLE, } from '~/packages_and_registries/container_registry/explorer/constants'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; @@ -96,10 +95,10 @@ describe('Image List Row', () => { }); }); - it(`when the image has no name appends ${ROOT_IMAGE_TEXT} to the path`, () => { + it(`when the image has no name lists the path`, () => { mountComponent({ item: { ...item, name: '' } }); - expect(findDetailsLink().text()).toBe(`${item.path}/ ${ROOT_IMAGE_TEXT}`); + expect(findDetailsLink().text()).toBe(item.path); }); it('contains a clipboard button', () => { diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/pages/details_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/pages/details_spec.js index 59ca47bee50..1d161888a4d 100644 --- a/spec/frontend/packages_and_registries/container_registry/explorer/pages/details_spec.js +++ b/spec/frontend/packages_and_registries/container_registry/explorer/pages/details_spec.js @@ -20,7 +20,6 @@ import { ALERT_DANGER_IMAGE, ALERT_DANGER_IMPORTING, MISSING_OR_DELETED_IMAGE_BREADCRUMB, - ROOT_IMAGE_TEXT, MISSING_OR_DELETED_IMAGE_TITLE, MISSING_OR_DELETED_IMAGE_MESSAGE, } from '~/packages_and_registries/container_registry/explorer/constants'; @@ -482,7 +481,7 @@ describe('Details Page', () => { expect(breadCrumbState.updateName).toHaveBeenCalledWith(MISSING_OR_DELETED_IMAGE_BREADCRUMB); }); - it(`when the image has no name set the breadcrumb to ${ROOT_IMAGE_TEXT}`, async () => { + it(`when the image has no name set the breadcrumb to project name`, async () => { mountComponent({ resolver: jest .fn() @@ -491,7 +490,7 @@ describe('Details Page', () => { await waitForApolloRequestRender(); - expect(breadCrumbState.updateName).toHaveBeenCalledWith(ROOT_IMAGE_TEXT); + expect(breadCrumbState.updateName).toHaveBeenCalledWith('gitlab-test'); }); }); diff --git a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb index cfa03db52fe..b5122af5cd4 100644 --- a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb @@ -47,10 +47,7 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillSnippetRepositories, :migrat before do allow(snippet_with_repo).to receive(:disk_path).and_return(disk_path(snippet_with_repo)) - TestEnv.copy_repo(snippet_with_repo, - bare_repo: TestEnv.factory_repo_path_bare, - refs: TestEnv::BRANCH_SHA) - + raw_repository(snippet_with_repo).create_from_bundle(TestEnv.factory_repo_bundle_path) raw_repository(snippet_with_empty_repo).create_repository end diff --git a/spec/lib/gitlab/tracking_spec.rb b/spec/lib/gitlab/tracking_spec.rb index cc973be8be9..a99e3b0a7f2 100644 --- a/spec/lib/gitlab/tracking_spec.rb +++ b/spec/lib/gitlab/tracking_spec.rb @@ -10,11 +10,11 @@ RSpec.describe Gitlab::Tracking do stub_application_setting(snowplow_cookie_domain: '.gitfoo.com') stub_application_setting(snowplow_app_id: '_abc123_') - described_class.instance_variable_set("@snowplow", nil) + described_class.instance_variable_set("@tracker", nil) end after do - described_class.instance_variable_set("@snowplow", nil) + described_class.instance_variable_set("@tracker", nil) end describe '.options' do diff --git a/spec/services/suggestions/apply_service_spec.rb b/spec/services/suggestions/apply_service_spec.rb index dc330a5546f..6052882813e 100644 --- a/spec/services/suggestions/apply_service_spec.rb +++ b/spec/services/suggestions/apply_service_spec.rb @@ -581,8 +581,7 @@ RSpec.describe Suggestions::ApplyService do let(:project) { create(:project, :public, :repository) } let(:forked_project) do - fork_project_with_submodules(project, - user, repository: project.repository) + fork_project_with_submodules(project, user) end let(:merge_request) do diff --git a/spec/support/helpers/project_forks_helper.rb b/spec/support/helpers/project_forks_helper.rb index 84b5dbc1d23..1504625bb00 100644 --- a/spec/support/helpers/project_forks_helper.rb +++ b/spec/support/helpers/project_forks_helper.rb @@ -70,12 +70,9 @@ module ProjectForksHelper def fork_project_with_submodules(project, user = nil, params = {}) Gitlab::GitalyClient.allow_n_plus_1_calls do forked_project = fork_project_direct(project, user, params) - TestEnv.copy_repo( - forked_project, - bare_repo: TestEnv.forked_repo_path_bare, - refs: TestEnv::FORKED_BRANCH_SHA - ) - forked_project.repository.expire_content_cache + repo = Gitlab::GlRepository::PROJECT.repository_for(forked_project) + repo.create_from_bundle(TestEnv.forked_repo_bundle_path) + repo.expire_content_cache forked_project end diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 59e6f54cf45..d6814319971 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -82,7 +82,13 @@ module TestEnv 'trailers' => 'f0a5ed6', 'add_commit_with_5mb_subject' => '8cf8e80', 'blame-on-renamed' => '32c33da', - 'with-executables' => '6b8dc4a' + 'with-executables' => '6b8dc4a', + 'spooky-stuff' => 'ba3343b', + 'few-commits' => '0031876', + 'two-commits' => '304d257', + 'utf-16' => 'f05a987', + 'gitaly-rename-test' => '94bb47c', + 'smime-signed-commits' => 'ed775cc' }.freeze # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily @@ -259,43 +265,35 @@ module TestEnv # Create repository for FactoryBot.create(:project) def setup_factory_repo - setup_repo(factory_repo_path, factory_repo_path_bare, factory_repo_name, BRANCH_SHA) + setup_repo(factory_repo_path, factory_repo_bundle_path, factory_repo_name, BRANCH_SHA) end # Create repository for FactoryBot.create(:forked_project_with_submodules) # This repo has a submodule commit that is not present in the main test # repository. def setup_forked_repo - setup_repo(forked_repo_path, forked_repo_path_bare, forked_repo_name, FORKED_BRANCH_SHA) + setup_repo(forked_repo_path, forked_repo_bundle_path, forked_repo_name, FORKED_BRANCH_SHA) end - def setup_repo(repo_path, repo_path_bare, repo_name, refs) + def setup_repo(repo_path, repo_bundle_path, repo_name, refs) clone_url = "https://gitlab.com/gitlab-org/#{repo_name}.git" unless File.directory?(repo_path) start = Time.now system(*%W(#{Gitlab.config.git.bin_path} clone --quiet -- #{clone_url} #{repo_path})) + system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} remote remove origin)) puts "==> #{repo_path} set up in #{Time.now - start} seconds...\n" end set_repo_refs(repo_path, refs) - unless File.directory?(repo_path_bare) + unless File.file?(repo_bundle_path) start = Time.now - # We must copy bare repositories because we will push to them. - system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --quiet --bare -- #{repo_path} #{repo_path_bare})) - puts "==> #{repo_path_bare} set up in #{Time.now - start} seconds...\n" + system(git_env, *%W(#{Gitlab.config.git.bin_path} -C #{repo_path} bundle create #{repo_bundle_path} --all)) + puts "==> #{repo_bundle_path} generated in #{Time.now - start} seconds...\n" end end - def copy_repo(subject, bare_repo:, refs:) - target_repo_path = File.expand_path(repos_path + "/#{subject.disk_path}.git") - - FileUtils.mkdir_p(target_repo_path) - FileUtils.cp_r("#{File.expand_path(bare_repo)}/.", target_repo_path) - FileUtils.chmod_R 0755, target_repo_path - end - def rm_storage_dir(storage, dir) Gitlab::GitalyClient::StorageSettings.allow_disk_access do target_repo_refs_path = File.join(GitalySetup.repos_path(storage), dir) @@ -349,12 +347,12 @@ module TestEnv Capybara.current_session.visit '/' end - def factory_repo_path_bare - "#{factory_repo_path}_bare" + def factory_repo_bundle_path + "#{factory_repo_path}.bundle" end - def forked_repo_path_bare - "#{forked_repo_path}_bare" + def forked_repo_bundle_path + "#{forked_repo_path}.bundle" end def with_empty_bare_repository(name = nil) @@ -378,9 +376,9 @@ module TestEnv gitaly gitlab-shell gitlab-test - gitlab-test_bare + gitlab-test.bundle gitlab-test-fork - gitlab-test-fork_bare + gitlab-test-fork.bundle gitlab-workhorse gitlab_workhorse_secret ] diff --git a/spec/support/snowplow.rb b/spec/support/snowplow.rb index e58be667b37..d600bf008b0 100644 --- a/spec/support/snowplow.rb +++ b/spec/support/snowplow.rb @@ -11,6 +11,6 @@ RSpec.configure do |config| end config.after(:each, :snowplow) do - Gitlab::Tracking.send(:snowplow).send(:tracker).flush + Gitlab::Tracking.send(:tracker).send(:tracker).flush end end diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 4a3b81a072f..9e914f8202e 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -348,14 +348,16 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do project_a = create(:project, :repository) project_snippet_a = create(:project_snippet, :repository, project: project_a, author: project_a.first_owner) project_b = create(:project, :repository, repository_storage: second_storage_name) - project_snippet_b = create(:project_snippet, :repository, project: project_b, author: project_b.first_owner) - project_snippet_b.snippet_repository.update!(shard: project_b.project_repository.shard) + project_snippet_b = create( + :project_snippet, + :repository, + project: project_b, + author: project_b.first_owner, + repository_storage: second_storage_name + ) create(:wiki_page, container: project_a) create(:design, :with_file, issue: create(:issue, project: project_a)) - move_repository_to_secondary(project_b) - move_repository_to_secondary(project_snippet_b) - expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout_from_any_process tar_contents, exit_status = Gitlab::Popen.popen( @@ -400,14 +402,16 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do project_a = create(:project, :repository) project_snippet_a = create(:project_snippet, :repository, project: project_a, author: project_a.first_owner) project_b = create(:project, :repository, repository_storage: second_storage_name) - project_snippet_b = create(:project_snippet, :repository, project: project_b, author: project_b.first_owner) - project_snippet_b.snippet_repository.update!(shard: project_b.project_repository.shard) + project_snippet_b = create( + :project_snippet, + :repository, + project: project_b, + author: project_b.first_owner, + repository_storage: second_storage_name + ) create(:wiki_page, container: project_a) create(:design, :with_file, issue: create(:issue, project: project_a)) - move_repository_to_secondary(project_b) - move_repository_to_secondary(project_snippet_b) - expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout_from_any_process tar_contents, exit_status = Gitlab::Popen.popen( @@ -435,21 +439,6 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do end end end - - def move_repository_to_secondary(record) - Gitlab::GitalyClient::StorageSettings.allow_disk_access do - default_shard_legacy_path = Gitlab.config.repositories.storages.default.legacy_disk_path - secondary_legacy_path = Gitlab.config.repositories.storages[second_storage_name].legacy_disk_path - dst_dir = File.join(secondary_legacy_path, File.dirname(record.disk_path)) - - FileUtils.mkdir_p(dst_dir) unless Dir.exist?(dst_dir) - - FileUtils.mv( - File.join(default_shard_legacy_path, record.disk_path + '.git'), - File.join(secondary_legacy_path, record.disk_path + '.git') - ) - end - end end context 'concurrency settings' do |