diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-17 21:11:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-17 21:11:12 +0300 |
commit | d70200a2d3665df14a749445b5721ff520f4f8a7 (patch) | |
tree | 8bcc6a2c96d61a98ba6b852f0c774a3cdc5778f6 /spec/services | |
parent | e303f963d0f03d9e2d21654700b56377701374b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/register_job_service_spec.rb | 40 | ||||
-rw-r--r-- | spec/services/projects/destroy_service_spec.rb | 60 |
2 files changed, 17 insertions, 83 deletions
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 0c7997434d2..866015aa523 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -740,17 +740,17 @@ module Ci stub_feature_flags(ci_pending_builds_queue_source: true) end - context 'with ci_queueing_denormalize_shared_runners_information enabled' do + context 'with ci_queuing_use_denormalized_data_strategy enabled' do before do - stub_feature_flags(ci_queueing_denormalize_shared_runners_information: true) + stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true) end include_examples 'handles runner assignment' end - context 'with ci_queueing_denormalize_shared_runners_information disabled' do + context 'with ci_queuing_use_denormalized_data_strategy disabled' do before do - stub_feature_flags(ci_queueing_denormalize_shared_runners_information: false) + stub_feature_flags(ci_queuing_use_denormalized_data_strategy: false) end around do |example| @@ -762,37 +762,9 @@ module Ci include_examples 'handles runner assignment' end - context 'with ci_queueing_denormalize_tags_information enabled' do + context 'with ci_queuing_use_denormalized_data_strategy enabled' do before do - stub_feature_flags(ci_queueing_denormalize_tags_information: true) - end - - include_examples 'handles runner assignment' - end - - context 'with ci_queueing_denormalize_tags_information disabled' do - before do - stub_feature_flags(ci_queueing_denormalize_tags_information: false) - end - - around do |example| - allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/332952') do - example.run - end - end - - include_examples 'handles runner assignment' - end - - context 'with ci_queueing_denormalize_namespace_traversal_ids disabled' do - before do - stub_feature_flags(ci_queueing_denormalize_namespace_traversal_ids: false) - end - - around do |example| - allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/332952') do - example.run - end + stub_feature_flags(ci_queuing_use_denormalized_data_strategy: true) end include_examples 'handles runner assignment' diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 9ffc32025a4..b22f276ee1f 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -55,32 +55,16 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do .and change { Ci::Pipeline.count }.by(-1) end - context 'with ci_optimize_project_records_destruction disabled' do - stub_feature_flags(ci_optimize_project_records_destruction: false) + it 'avoids N+1 queries' do + recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) } - it 'avoids N+1 queries' do - recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) } + project = create(:project, :repository, namespace: user.namespace) + pipeline = create(:ci_pipeline, project: project) + builds = create_list(:ci_build, 3, :artifacts, pipeline: pipeline) + create(:ci_pipeline_artifact, pipeline: pipeline) + create_list(:ci_build_trace_chunk, 3, build: builds[0]) - project = create(:project, :repository, namespace: user.namespace) - pipeline = create(:ci_pipeline, project: project) - builds = create_list(:ci_build, 3, :artifacts, pipeline: pipeline) - create_list(:ci_build_trace_chunk, 3, build: builds[0]) - - expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder) - end - end - - context 'with ci_optimize_project_records_destruction enabled' do - it 'avoids N+1 queries' do - recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) } - - project = create(:project, :repository, namespace: user.namespace) - pipeline = create(:ci_pipeline, project: project) - builds = create_list(:ci_build, 3, :artifacts, pipeline: pipeline) - create_list(:ci_build_trace_chunk, 3, build: builds[0]) - - expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder) - end + expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder) end it_behaves_like 'deleting the project' @@ -116,11 +100,11 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do destroy_project(project, user, {}) end - context 'with running pipelines to be aborted' do + context 'with running pipelines' do let!(:pipelines) { create_list(:ci_pipeline, 3, :running, project: project) } let(:destroy_pipeline_service) { double('DestroyPipelineService', execute: nil) } - it 'executes DestroyPipelineService for project ci pipelines' do + it 'bulks-fails with AbortPipelineService and then executes DestroyPipelineService for each pipelines' do allow(::Ci::DestroyPipelineService).to receive(:new).and_return(destroy_pipeline_service) expect(::Ci::AbortPipelinesService) @@ -128,33 +112,11 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do .with(project.all_pipelines, :project_deleted) pipelines.each do |pipeline| - expect(destroy_pipeline_service) - .to receive(:execute) - .with(pipeline) + expect(destroy_pipeline_service).to receive(:execute).with(pipeline) end destroy_project(project, user, {}) end - - context 'with ci_optimize_project_records_destruction disabled' do - before do - stub_feature_flags(ci_optimize_project_records_destruction: false) - end - - it 'bulk-fails project ci pipelines' do - expect(::Ci::AbortPipelinesService) - .to receive_message_chain(:new, :execute) - .with(project.all_pipelines, :project_deleted) - - destroy_project(project, user, {}) - end - - it 'does not destroy CI records via DestroyPipelineService' do - expect(::Ci::DestroyPipelineService).not_to receive(:new) - - destroy_project(project, user, {}) - end - end end context 'when project has remote mirrors' do |