diff options
Diffstat (limited to 'spec/tasks/gitlab')
28 files changed, 109 insertions, 98 deletions
diff --git a/spec/tasks/gitlab/artifacts/check_rake_spec.rb b/spec/tasks/gitlab/artifacts/check_rake_spec.rb index 04015f0e21a..d1d02ab9bc5 100644 --- a/spec/tasks/gitlab/artifacts/check_rake_spec.rb +++ b/spec/tasks/gitlab/artifacts/check_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:artifacts rake tasks' do +RSpec.describe 'gitlab:artifacts rake tasks' do describe 'check' do let!(:artifact) { create(:ci_job_artifact, :archive, :correct_checksum) } diff --git a/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb b/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb index 9ee00b4297b..94a8da9478a 100644 --- a/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb +++ b/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:artifacts namespace rake task' do +RSpec.describe 'gitlab:artifacts namespace rake task' do before(:context) do Rake.application.rake_require 'tasks/gitlab/artifacts/migrate' end diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index febc18e497a..661ce8e74d2 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rake' -describe 'gitlab:app namespace rake task', :delete do +RSpec.describe 'gitlab:app namespace rake task', :delete do let(:enable_registry) { true } def tars_glob diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb index e3e2a22add9..7956b5c57e6 100644 --- a/spec/tasks/gitlab/check_rake_spec.rb +++ b/spec/tasks/gitlab/check_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'check.rake' do +RSpec.describe 'check.rake' do before do Rake.application.rake_require 'tasks/gitlab/check' diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb index 8db18895c24..dc460611169 100644 --- a/spec/tasks/gitlab/cleanup_rake_spec.rb +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:cleanup rake tasks' do +RSpec.describe 'gitlab:cleanup rake tasks' do before do Rake.application.rake_require 'tasks/gitlab/cleanup' end diff --git a/spec/tasks/gitlab/container_registry_rake_spec.rb b/spec/tasks/gitlab/container_registry_rake_spec.rb index 181d5c8b7c8..b83ff567126 100644 --- a/spec/tasks/gitlab/container_registry_rake_spec.rb +++ b/spec/tasks/gitlab/container_registry_rake_spec.rb @@ -2,25 +2,19 @@ require 'rake_helper' -describe 'gitlab:container_registry namespace rake tasks' do - let_it_be(:application_settings) { Gitlab::CurrentSettings } +RSpec.describe 'gitlab:container_registry namespace rake tasks' do let_it_be(:api_url) { 'http://registry.gitlab' } before :all do Rake.application.rake_require 'tasks/gitlab/container_registry' end - describe 'configure' do - before do - stub_access_token - stub_container_registry_config(enabled: true, api_url: api_url) - end - + describe '#configure' do subject { run_rake_task('gitlab:container_registry:configure') } shared_examples 'invalid config' do - it 'does not update the application settings' do - expect(application_settings).not_to receive(:update!) + it 'does not call UpdateContainerRegistryInfoService' do + expect_any_instance_of(UpdateContainerRegistryInfoService).not_to receive(:execute) subject end @@ -30,7 +24,7 @@ describe 'gitlab:container_registry namespace rake tasks' do end it 'prints a warning message' do - expect { subject }.to output(/Registry is not enabled or registry api url is not present./).to_stdout + expect { subject }.to output("Registry is not enabled or registry api url is not present.\n").to_stdout end end @@ -50,74 +44,18 @@ describe 'gitlab:container_registry namespace rake tasks' do it_behaves_like 'invalid config' end - context 'when creating a registry client instance' do - let(:token) { 'foo' } - let(:client) { ContainerRegistry::Client.new(api_url, token: token) } - + context 'when container registry is enabled and api_url is not blank' do before do - stub_registry_info({}) - end - - it 'uses a token with no access permissions' do - expect(Auth::ContainerRegistryAuthenticationService) - .to receive(:access_token).with([], []).and_return(token) - expect(ContainerRegistry::Client) - .to receive(:new).with(api_url, token: token).and_return(client) - - run_rake_task('gitlab:container_registry:configure') + stub_container_registry_config(enabled: true, api_url: api_url) end - end - - context 'when unabled to detect the container registry type' do - it 'fails and raises an error message' do - stub_registry_info({}) - - run_rake_task('gitlab:container_registry:configure') - - application_settings.reload - expect(application_settings.container_registry_vendor).to be_blank - expect(application_settings.container_registry_version).to be_blank - expect(application_settings.container_registry_features).to eq([]) - end - end - context 'when able to detect the container registry type' do - context 'when using the GitLab container registry' do - it 'updates application settings accordingly' do - stub_registry_info(vendor: 'gitlab', version: '2.9.1-gitlab', features: %w[a,b,c]) - - run_rake_task('gitlab:container_registry:configure') - - application_settings.reload - expect(application_settings.container_registry_vendor).to eq('gitlab') - expect(application_settings.container_registry_version).to eq('2.9.1-gitlab') - expect(application_settings.container_registry_features).to eq(%w[a,b,c]) + it 'calls UpdateContainerRegistryInfoService' do + expect_next_instance_of(UpdateContainerRegistryInfoService) do |service| + expect(service).to receive(:execute) end - end - context 'when using a third-party container registry' do - it 'updates application settings accordingly' do - stub_registry_info(vendor: 'other', version: nil, features: nil) - - run_rake_task('gitlab:container_registry:configure') - - application_settings.reload - expect(application_settings.container_registry_vendor).to eq('other') - expect(application_settings.container_registry_version).to be_blank - expect(application_settings.container_registry_features).to eq([]) - end + subject end end end - - def stub_access_token - allow(Auth::ContainerRegistryAuthenticationService) - .to receive(:access_token).with([], []).and_return('foo') - end - - def stub_registry_info(output) - allow_next_instance_of(ContainerRegistry::Client) do |client| - allow(client).to receive(:registry_info).and_return(output) - end - end end diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index c3da5af5439..a78506803be 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rake' -describe 'gitlab:db namespace rake task' do +RSpec.describe 'gitlab:db namespace rake task' do before :all do Rake.application.rake_require 'active_record/railties/databases' Rake.application.rake_require 'tasks/seed_fu' diff --git a/spec/tasks/gitlab/external_diffs_rake_spec.rb b/spec/tasks/gitlab/external_diffs_rake_spec.rb new file mode 100644 index 00000000000..66e555734b3 --- /dev/null +++ b/spec/tasks/gitlab/external_diffs_rake_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:external_diffs rake tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/external_diffs' + end + + describe 'force_object_storage task' do + it 'forces externally stored merge request diffs to object storage' do + db = create(:merge_request).merge_request_diff + file = create(:merge_request).merge_request_diff.tap { |o| o.update_columns(stored_externally: true, external_diff_store: 1) } + object = create(:merge_request).merge_request_diff.tap { |o| o.update_columns(stored_externally: true, external_diff_store: 2) } + + run_rake_task('gitlab:external_diffs:force_object_storage') + + expect(db.reload).not_to be_stored_externally + expect(file.reload).to be_stored_externally + expect(object.reload).to be_stored_externally + + expect(file.external_diff_store).to eq(2) + expect(object.external_diff_store).to eq(2) + end + + it 'limits batches according to BATCH_SIZE, START_ID, and END_ID' do + stub_env('START_ID' => 'foo', 'END_ID' => 'bar', 'BATCH_SIZE' => 'baz') + + expect(MergeRequestDiff).to receive(:in_batches).with(start: 'foo', finish: 'bar', of: 'baz') + + run_rake_task('gitlab:external_diffs:force_object_storage') + end + end +end diff --git a/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb b/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb index 7620047624a..a8effef2d7b 100644 --- a/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb +++ b/spec/tasks/gitlab/generate_sample_prometheus_data_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:generate_sample_prometheus_data rake task' do +RSpec.describe 'gitlab:generate_sample_prometheus_data rake task' do let(:cluster) { create(:cluster, :provided_by_user, :project) } let(:environment) { create(:environment, project: cluster.project) } let(:sample_query_file) { File.join(Rails.root, Metrics::SampleMetricsService::DIRECTORY, 'test_query_result.yml') } diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index b8156e55ec7..4bc1b460d9b 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:git rake tasks' do +RSpec.describe 'gitlab:git rake tasks' do let(:base_path) { 'tmp/tests/default_storage' } let!(:project) { create(:project, :repository) } diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index d9fdc183bfe..c59370a7a32 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:gitaly namespace rake task' do +RSpec.describe 'gitlab:gitaly namespace rake task' do before :all do Rake.application.rake_require 'tasks/gitlab/gitaly' end diff --git a/spec/tasks/gitlab/info_rake_spec.rb b/spec/tasks/gitlab/info_rake_spec.rb index 8d6b3985380..941f3429017 100644 --- a/spec/tasks/gitlab/info_rake_spec.rb +++ b/spec/tasks/gitlab/info_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:env:info' do +RSpec.describe 'gitlab:env:info' do before do Rake.application.rake_require 'tasks/gitlab/info' diff --git a/spec/tasks/gitlab/ldap_rake_spec.rb b/spec/tasks/gitlab/ldap_rake_spec.rb index bbc3f625088..275fcb98dd0 100644 --- a/spec/tasks/gitlab/ldap_rake_spec.rb +++ b/spec/tasks/gitlab/ldap_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:ldap:rename_provider rake task' do +RSpec.describe 'gitlab:ldap:rename_provider rake task' do it 'completes without error' do Rake.application.rake_require 'tasks/gitlab/ldap' stub_warn_user_is_not_gitlab diff --git a/spec/tasks/gitlab/lfs/check_rake_spec.rb b/spec/tasks/gitlab/lfs/check_rake_spec.rb index 3d698efdcb6..fd1b6d010e4 100644 --- a/spec/tasks/gitlab/lfs/check_rake_spec.rb +++ b/spec/tasks/gitlab/lfs/check_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:lfs rake tasks' do +RSpec.describe 'gitlab:lfs rake tasks' do describe 'check' do let!(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) } diff --git a/spec/tasks/gitlab/lfs/migrate_rake_spec.rb b/spec/tasks/gitlab/lfs/migrate_rake_spec.rb index fc7be0eebcd..a59da615b94 100644 --- a/spec/tasks/gitlab/lfs/migrate_rake_spec.rb +++ b/spec/tasks/gitlab/lfs/migrate_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:lfs namespace rake task' do +RSpec.describe 'gitlab:lfs namespace rake task' do before :all do Rake.application.rake_require 'tasks/gitlab/lfs/migrate' end diff --git a/spec/tasks/gitlab/packages/migrate_rake_spec.rb b/spec/tasks/gitlab/packages/migrate_rake_spec.rb new file mode 100644 index 00000000000..0a296eb0808 --- /dev/null +++ b/spec/tasks/gitlab/packages/migrate_rake_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:packages namespace rake task' do + before :all do + Rake.application.rake_require 'tasks/gitlab/packages/migrate' + end + + describe 'migrate' do + let(:local) { ObjectStorage::Store::LOCAL } + let(:remote) { ObjectStorage::Store::REMOTE } + let!(:package_file) { create(:package_file, :pom, file_store: local) } + + def packages_migrate + run_rake_task('gitlab:packages:migrate') + end + + context 'object storage disabled' do + before do + stub_packages_object_storage(enabled: false) + end + + it "doesn't migrate files" do + expect { packages_migrate }.to raise_error('Object store is disabled for packages feature') + end + end + + context 'object storage enabled' do + before do + stub_packages_object_storage + end + + it 'migrates local file to object storage' do + expect { packages_migrate }.to change { package_file.reload.file_store }.from(local).to(remote) + end + end + end +end diff --git a/spec/tasks/gitlab/praefect_rake_spec.rb b/spec/tasks/gitlab/praefect_rake_spec.rb index d986a778c8c..c67dba110c7 100644 --- a/spec/tasks/gitlab/praefect_rake_spec.rb +++ b/spec/tasks/gitlab/praefect_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:praefect:replicas' do +RSpec.describe 'gitlab:praefect:replicas' do before do Rake.application.rake_require 'tasks/gitlab/praefect' end diff --git a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb b/spec/tasks/gitlab/seed/group_seed_rake_spec.rb index ecf4e9575ab..0b69615eebc 100644 --- a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb +++ b/spec/tasks/gitlab/seed/group_seed_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:seed:group_seed rake task' do +RSpec.describe 'gitlab:seed:group_seed rake task' do let(:username) { 'group_seed' } let!(:user) { create(:user, username: username) } let(:task_params) { [2, username] } diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb index 08b3fea0c80..a929daddb67 100644 --- a/spec/tasks/gitlab/shell_rake_spec.rb +++ b/spec/tasks/gitlab/shell_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:shell rake tasks' do +RSpec.describe 'gitlab:shell rake tasks' do before do Rake.application.rake_require 'tasks/gitlab/shell' diff --git a/spec/tasks/gitlab/snippets_rake_spec.rb b/spec/tasks/gitlab/snippets_rake_spec.rb index c4bb8d7897c..f21922e14b8 100644 --- a/spec/tasks/gitlab/snippets_rake_spec.rb +++ b/spec/tasks/gitlab/snippets_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:snippets namespace rake task' do +RSpec.describe 'gitlab:snippets namespace rake task' do let_it_be(:user) { create(:user)} let_it_be(:migrated) { create(:personal_snippet, :repository, author: user) } let(:non_migrated) { create_list(:personal_snippet, 3, author: user) } diff --git a/spec/tasks/gitlab/storage_rake_spec.rb b/spec/tasks/gitlab/storage_rake_spec.rb index 226d3aaab4e..abd44adbdcc 100644 --- a/spec/tasks/gitlab/storage_rake_spec.rb +++ b/spec/tasks/gitlab/storage_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'rake gitlab:storage:*' do +RSpec.describe 'rake gitlab:storage:*' do before do Rake.application.rake_require 'tasks/gitlab/storage' diff --git a/spec/tasks/gitlab/task_helpers_spec.rb b/spec/tasks/gitlab/task_helpers_spec.rb index 8e6872f4d6f..2921913319b 100644 --- a/spec/tasks/gitlab/task_helpers_spec.rb +++ b/spec/tasks/gitlab/task_helpers_spec.rb @@ -6,7 +6,7 @@ class TestHelpersTest include Gitlab::TaskHelpers end -describe Gitlab::TaskHelpers do +RSpec.describe Gitlab::TaskHelpers do subject { TestHelpersTest.new } let(:repo) { 'https://gitlab.com/gitlab-org/gitlab-test.git' } diff --git a/spec/tasks/gitlab/update_templates_rake_spec.rb b/spec/tasks/gitlab/update_templates_rake_spec.rb index 14b4ad5e3d8..25151a2f3ae 100644 --- a/spec/tasks/gitlab/update_templates_rake_spec.rb +++ b/spec/tasks/gitlab/update_templates_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:update_project_templates rake task' do +RSpec.describe 'gitlab:update_project_templates rake task' do let!(:tmpdir) { Dir.mktmpdir } before do diff --git a/spec/tasks/gitlab/uploads/check_rake_spec.rb b/spec/tasks/gitlab/uploads/check_rake_spec.rb index 91f0cedb246..4c6f16dbcf9 100644 --- a/spec/tasks/gitlab/uploads/check_rake_spec.rb +++ b/spec/tasks/gitlab/uploads/check_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:uploads rake tasks' do +RSpec.describe 'gitlab:uploads rake tasks' do describe 'check' do let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) } diff --git a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb index 49026cd74f9..7f0f5c6767d 100644 --- a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb +++ b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:uploads:migrate and migrate_to_local rake tasks' do +RSpec.describe 'gitlab:uploads:migrate and migrate_to_local rake tasks' do let(:model_class) { nil } let(:uploader_class) { nil } let(:mounted_as) { nil } diff --git a/spec/tasks/gitlab/web_hook_rake_spec.rb b/spec/tasks/gitlab/web_hook_rake_spec.rb index ee3c7e034f3..3e18ce5ab29 100644 --- a/spec/tasks/gitlab/web_hook_rake_spec.rb +++ b/spec/tasks/gitlab/web_hook_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:web_hook namespace rake tasks' do +RSpec.describe 'gitlab:web_hook namespace rake tasks' do let_it_be(:group, refind: true) { create(:group) } let_it_be(:project1, reload: true) { create(:project, namespace: group) } let_it_be(:project2, reload: true) { create(:project, namespace: group) } diff --git a/spec/tasks/gitlab/workhorse_rake_spec.rb b/spec/tasks/gitlab/workhorse_rake_spec.rb index 139652ac258..2efbf0febac 100644 --- a/spec/tasks/gitlab/workhorse_rake_spec.rb +++ b/spec/tasks/gitlab/workhorse_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:workhorse namespace rake task' do +RSpec.describe 'gitlab:workhorse namespace rake task' do before :all do Rake.application.rake_require 'tasks/gitlab/workhorse' end diff --git a/spec/tasks/gitlab/x509/update_rake_spec.rb b/spec/tasks/gitlab/x509/update_rake_spec.rb index 8c62c6c1728..93e97ab38ad 100644 --- a/spec/tasks/gitlab/x509/update_rake_spec.rb +++ b/spec/tasks/gitlab/x509/update_rake_spec.rb @@ -2,7 +2,7 @@ require 'rake_helper' -describe 'gitlab:x509 namespace rake task' do +RSpec.describe 'gitlab:x509 namespace rake task' do before :all do Rake.application.rake_require 'tasks/gitlab/x509/update' end |