diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/support/shared_examples/ci | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/support/shared_examples/ci')
-rw-r--r-- | spec/support/shared_examples/ci/stuck_builds_shared_examples.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/support/shared_examples/ci/stuck_builds_shared_examples.rb b/spec/support/shared_examples/ci/stuck_builds_shared_examples.rb new file mode 100644 index 00000000000..4fcea18393c --- /dev/null +++ b/spec/support/shared_examples/ci/stuck_builds_shared_examples.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'job is dropped with failure reason' do |failure_reason| + it 'changes status' do + service.execute + job.reload + + expect(job).to be_failed + expect(job.failure_reason).to eq(failure_reason) + end + + context 'when job has data integrity problem' do + it 'drops the job and logs the reason' do + job.update_columns(yaml_variables: '[{"key" => "value"}]') + + expect(Gitlab::ErrorTracking) + .to receive(:track_exception) + .with(anything, a_hash_including(build_id: job.id)) + .once + .and_call_original + + service.execute + job.reload + + expect(job).to be_failed + expect(job.failure_reason).to eq('data_integrity_failure') + end + end +end + +RSpec.shared_examples 'job is unchanged' do + it 'does not change status' do + expect { service.execute }.not_to change(job, :status) + end +end |