Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-17 18:08:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-17 18:08:37 +0300
commit37eff29d5ce44899e34c7c2ac319b314f2f26d15 (patch)
treeb74e1632fdb58ea10972f270bfec70a4e6ee07b0 /spec/services
parent9411a664118a3247d0a56baf7e7ef4549c1201c3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/boards/list_service_spec.rb1
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb22
-rw-r--r--spec/services/ci/pipeline_processing/atomic_processing_service/status_collection_spec.rb91
-rw-r--r--spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb12
-rw-r--r--spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb4
-rw-r--r--spec/services/ci/pipeline_processing/shared_processing_service.rb24
-rw-r--r--spec/services/ci/retry_build_service_spec.rb8
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb2
8 files changed, 143 insertions, 21 deletions
diff --git a/spec/services/boards/list_service_spec.rb b/spec/services/boards/list_service_spec.rb
index c9d372ea166..4eb023907fa 100644
--- a/spec/services/boards/list_service_spec.rb
+++ b/spec/services/boards/list_service_spec.rb
@@ -10,6 +10,7 @@ describe Boards::ListService do
subject(:service) { described_class.new(parent, double) }
it_behaves_like 'boards list service'
+ it_behaves_like 'multiple boards list service'
end
context 'when board parent is a group' do
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index dc67efe0fbe..d6cc233088d 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -362,11 +362,11 @@ describe Ci::CreatePipelineService do
context 'when build that is not marked as interruptible is running' do
it 'cancels running outdated pipelines', :sidekiq_might_not_need_inline do
- pipeline_on_previous_commit
- .builds
- .find_by_name('build_2_1')
- .tap(&:enqueue!)
- .run!
+ build_2_1 = pipeline_on_previous_commit
+ .builds.find_by_name('build_2_1')
+
+ build_2_1.enqueue!
+ build_2_1.reset.run!
pipeline
@@ -377,12 +377,12 @@ describe Ci::CreatePipelineService do
end
context 'when an uninterruptible build is running' do
- it 'does not cancel running outdated pipelines', :sidekiq_might_not_need_inline do
- pipeline_on_previous_commit
- .builds
- .find_by_name('build_3_1')
- .tap(&:enqueue!)
- .run!
+ it 'does not cancel running outdated pipelines', :sidekiq_inline do
+ build_3_1 = pipeline_on_previous_commit
+ .builds.find_by_name('build_3_1')
+
+ build_3_1.enqueue!
+ build_3_1.reset.run!
pipeline
diff --git a/spec/services/ci/pipeline_processing/atomic_processing_service/status_collection_spec.rb b/spec/services/ci/pipeline_processing/atomic_processing_service/status_collection_spec.rb
new file mode 100644
index 00000000000..c29c56c2b04
--- /dev/null
+++ b/spec/services/ci/pipeline_processing/atomic_processing_service/status_collection_spec.rb
@@ -0,0 +1,91 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Ci::PipelineProcessing::AtomicProcessingService::StatusCollection do
+ using RSpec::Parameterized::TableSyntax
+
+ set(:pipeline) { create(:ci_pipeline) }
+ set(:build_a) { create(:ci_build, :success, name: 'build-a', stage: 'build', stage_idx: 0, pipeline: pipeline) }
+ set(:build_b) { create(:ci_build, :failed, name: 'build-b', stage: 'build', stage_idx: 0, pipeline: pipeline) }
+ set(:test_a) { create(:ci_build, :running, name: 'test-a', stage: 'test', stage_idx: 1, pipeline: pipeline) }
+ set(:test_b) { create(:ci_build, :pending, name: 'test-b', stage: 'test', stage_idx: 1, pipeline: pipeline) }
+ set(:deploy) { create(:ci_build, :created, name: 'deploy', stage: 'deploy', stage_idx: 2, pipeline: pipeline) }
+
+ let(:collection) { described_class.new(pipeline) }
+
+ describe '#set_processable_status' do
+ it 'does update existing status of processable' do
+ collection.set_processable_status(test_a.id, 'success', 100)
+
+ expect(collection.status_for_names(['test-a'])).to eq('success')
+ end
+
+ it 'ignores a missing processable' do
+ collection.set_processable_status(-1, 'failed', 100)
+ end
+ end
+
+ describe '#status_of_all' do
+ it 'returns composite status of the collection' do
+ expect(collection.status_of_all).to eq('running')
+ end
+ end
+
+ describe '#status_for_names' do
+ where(:names, :status) do
+ %w[build-a] | 'success'
+ %w[build-a build-b] | 'failed'
+ %w[build-a test-a] | 'running'
+ end
+
+ with_them do
+ it 'returns composite status of given names' do
+ expect(collection.status_for_names(names)).to eq(status)
+ end
+ end
+ end
+
+ describe '#status_for_prior_stage_position' do
+ where(:stage, :status) do
+ 0 | 'success'
+ 1 | 'failed'
+ 2 | 'running'
+ end
+
+ with_them do
+ it 'returns composite status for processables in prior stages' do
+ expect(collection.status_for_prior_stage_position(stage)).to eq(status)
+ end
+ end
+ end
+
+ describe '#status_for_stage_position' do
+ where(:stage, :status) do
+ 0 | 'failed'
+ 1 | 'running'
+ 2 | 'created'
+ end
+
+ with_them do
+ it 'returns composite status for processables at a given stages' do
+ expect(collection.status_for_stage_position(stage)).to eq(status)
+ end
+ end
+ end
+
+ describe '#created_processable_ids_for_stage_position' do
+ it 'returns IDs of processables at a given stage position' do
+ expect(collection.created_processable_ids_for_stage_position(0)).to be_empty
+ expect(collection.created_processable_ids_for_stage_position(1)).to be_empty
+ expect(collection.created_processable_ids_for_stage_position(2)).to contain_exactly(deploy.id)
+ end
+ end
+
+ describe '#processing_processables' do
+ it 'returns processables marked as processing' do
+ expect(collection.processing_processables.map { |processable| processable[:id]} )
+ .to contain_exactly(build_a.id, build_b.id, test_a.id, test_b.id, deploy.id)
+ end
+ end
+end
diff --git a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
new file mode 100644
index 00000000000..38686b41a22
--- /dev/null
+++ b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_relative 'shared_processing_service.rb'
+
+describe Ci::PipelineProcessing::AtomicProcessingService do
+ before do
+ stub_feature_flags(ci_atomic_processing: true)
+ end
+
+ it_behaves_like 'Pipeline Processing Service'
+end
diff --git a/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb b/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
index 6e92771b034..2da1eb19818 100644
--- a/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
+++ b/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
@@ -4,5 +4,9 @@ require 'spec_helper'
require_relative 'shared_processing_service.rb'
describe Ci::PipelineProcessing::LegacyProcessingService do
+ before do
+ stub_feature_flags(ci_atomic_processing: false)
+ end
+
it_behaves_like 'Pipeline Processing Service'
end
diff --git a/spec/services/ci/pipeline_processing/shared_processing_service.rb b/spec/services/ci/pipeline_processing/shared_processing_service.rb
index 45baae4118c..cae5ae3f09d 100644
--- a/spec/services/ci/pipeline_processing/shared_processing_service.rb
+++ b/spec/services/ci/pipeline_processing/shared_processing_service.rb
@@ -879,19 +879,27 @@ shared_examples 'Pipeline Processing Service' do
end
def succeed_pending
- builds.pending.map(&:success)
+ builds.pending.each do |build|
+ build.reset.success
+ end
end
def succeed_running_or_pending
- pipeline.builds.running_or_pending.each(&:success)
+ pipeline.builds.running_or_pending.each do |build|
+ build.reset.success
+ end
end
def fail_running_or_pending
- pipeline.builds.running_or_pending.each(&:drop)
+ pipeline.builds.running_or_pending.each do |build|
+ build.reset.drop
+ end
end
def cancel_running_or_pending
- pipeline.builds.running_or_pending.each(&:cancel)
+ pipeline.builds.running_or_pending.each do |build|
+ build.reset.cancel
+ end
end
def play_manual_action(name)
@@ -911,11 +919,15 @@ shared_examples 'Pipeline Processing Service' do
end
def create_build(name, **opts)
- create(:ci_build, :created, pipeline: pipeline, name: name, **opts)
+ create(:ci_build, :created, pipeline: pipeline, name: name, **with_stage_opts(opts))
end
def successful_build(name, **opts)
- create(:ci_build, :success, pipeline: pipeline, name: name, **opts)
+ create(:ci_build, :success, pipeline: pipeline, name: name, **with_stage_opts(opts))
+ end
+
+ def with_stage_opts(opts)
+ { stage: "stage-#{opts[:stage_idx].to_i}" }.merge(opts)
end
def delayed_options
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb
index 1a39b37e925..b3189974440 100644
--- a/spec/services/ci/retry_build_service_spec.rb
+++ b/spec/services/ci/retry_build_service_spec.rb
@@ -45,7 +45,8 @@ describe Ci::RetryBuildService do
user_id auto_canceled_by_id retried failure_reason
sourced_pipelines artifacts_file_store artifacts_metadata_store
metadata runner_session trace_chunks upstream_pipeline_id
- artifacts_file artifacts_metadata artifacts_size commands resource resource_group_id].freeze
+ artifacts_file artifacts_metadata artifacts_size commands
+ resource resource_group_id processed].freeze
shared_examples 'build duplication' do
let(:another_pipeline) { create(:ci_empty_pipeline, project: project) }
@@ -202,12 +203,13 @@ describe Ci::RetryBuildService do
it 'does not enqueue the new build' do
expect(new_build).to be_created
+ expect(new_build).not_to be_processed
end
- it 'does mark old build as retried in the database and on the instance' do
+ it 'does mark old build as retried' do
expect(new_build).to be_latest
expect(build).to be_retried
- expect(build.reload).to be_retried
+ expect(build).to be_processed
end
context 'when build with deployment is retried' do
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index 4b949761b8f..e7a241ed335 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -330,7 +330,7 @@ describe Ci::RetryPipelineService, '#execute' do
stage: "stage_#{stage_num}",
stage_idx: stage_num,
pipeline: pipeline, **opts) do |build|
- pipeline.update_status
+ pipeline.update_legacy_status
end
end
end