diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/tasks | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/sidekiq_rake_spec.rb | 42 | ||||
-rw-r--r-- | spec/tasks/gitlab/update_templates_rake_spec.rb | 7 |
2 files changed, 38 insertions, 11 deletions
diff --git a/spec/tasks/gitlab/sidekiq_rake_spec.rb b/spec/tasks/gitlab/sidekiq_rake_spec.rb index 75f904389e2..0e5111c90a1 100644 --- a/spec/tasks/gitlab/sidekiq_rake_spec.rb +++ b/spec/tasks/gitlab/sidekiq_rake_spec.rb @@ -9,7 +9,10 @@ RSpec.describe 'sidekiq.rake', :aggregate_failures, :silence_stdout do stub_warn_user_is_not_gitlab end + let(:migrator) { ::Gitlab::SidekiqMigrateJobs.new(mappings, logger: Logger.new($stdout)) } + shared_examples 'migration rake task' do + let(:mappings) { {} } it 'runs the migrator with a mapping of workers to queues' do test_routes = [ ['urgency=high', 'default'], @@ -17,20 +20,17 @@ RSpec.describe 'sidekiq.rake', :aggregate_failures, :silence_stdout do ] test_router = ::Gitlab::SidekiqConfig::WorkerRouter.new(test_routes) - migrator = ::Gitlab::SidekiqMigrateJobs.new(sidekiq_set, logger: Logger.new($stdout)) allow(::Gitlab::SidekiqConfig::WorkerRouter) .to receive(:global).and_return(test_router) expect(::Gitlab::SidekiqMigrateJobs) - .to receive(:new).with(sidekiq_set, logger: an_instance_of(Logger)).and_return(migrator) + .to receive(:new).with(a_hash_including('PostReceive' => 'default', + 'MergeWorker' => 'default', + 'DeleteDiffFilesWorker' => 'delete_diff_files'), + logger: an_instance_of(Logger)).and_return(migrator) - expect(migrator) - .to receive(:execute) - .with(a_hash_including('PostReceive' => 'default', - 'MergeWorker' => 'default', - 'DeleteDiffFilesWorker' => 'delete_diff_files')) - .and_call_original + expect(migrator).to receive(:migrate_set).with(sidekiq_set).and_call_original run_rake_task("gitlab:sidekiq:migrate_jobs:#{sidekiq_set}") @@ -50,4 +50,30 @@ RSpec.describe 'sidekiq.rake', :aggregate_failures, :silence_stdout do it_behaves_like 'migration rake task' end + + describe 'gitlab:sidekiq:migrate_jobs:queued rake task' do + let(:mappings) { { 'PostReceive' => 'default' } } + + it 'runs the migrator with a mapping of workers to queues' do + test_routes = [ + ['*', 'default'] + ] + + test_router = ::Gitlab::SidekiqConfig::WorkerRouter.new(test_routes) + + allow(::Gitlab::SidekiqConfig::WorkerRouter) + .to receive(:global).and_return(test_router) + + expect(::Gitlab::SidekiqMigrateJobs) + .to receive(:new).with(a_hash_including('PostReceive' => 'default', + 'MergeWorker' => 'default'), + logger: an_instance_of(Logger)).and_return(migrator) + + expect(migrator).to receive(:migrate_queues).and_call_original + + run_rake_task("gitlab:sidekiq:migrate_jobs:queued") + + expect($stdout.string).to include('List of queues based on routing rules: ["default"]') + end + end end diff --git a/spec/tasks/gitlab/update_templates_rake_spec.rb b/spec/tasks/gitlab/update_templates_rake_spec.rb index 7eccdf22a1f..85da490f718 100644 --- a/spec/tasks/gitlab/update_templates_rake_spec.rb +++ b/spec/tasks/gitlab/update_templates_rake_spec.rb @@ -4,6 +4,7 @@ require 'rake_helper' RSpec.describe 'gitlab:update_project_templates rake task', :silence_stdout do let!(:tmpdir) { Dir.mktmpdir } + let(:template) { Gitlab::ProjectTemplate.find(:rails) } before do Rake.application.rake_require 'tasks/gitlab/update_templates' @@ -14,7 +15,7 @@ RSpec.describe 'gitlab:update_project_templates rake task', :silence_stdout do .and_return(Pathname.new(tmpdir)) # Gitlab::HTTP resolves the domain to an IP prior to WebMock taking effect, hence the wildcard - stub_request(:get, %r{^https://.*/api/v4/projects/gitlab-org%2Fproject-templates%2Frails/repository/commits\?page=1&per_page=1}) + stub_request(:get, %r{^https://.*/api/v4/projects/#{template.uri_encoded_project_path}/repository/commits\?page=1&per_page=1}) .to_return( status: 200, body: [{ id: '67812735b83cb42710f22dc98d73d42c8bf4d907' }].to_json, @@ -27,8 +28,8 @@ RSpec.describe 'gitlab:update_project_templates rake task', :silence_stdout do end it 'updates valid project templates' do - expect { run_rake_task('gitlab:update_project_templates', ['rails']) } + expect { run_rake_task('gitlab:update_project_templates', [template.name]) } .to change { Dir.entries(tmpdir) } - .by(['rails.tar.gz']) + .by(["#{template.name}.tar.gz"]) end end |