diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-11-29 08:51:03 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-11-29 08:51:03 +0300 |
commit | af5bf56857bd6e88bc9ea3322a0873ff6767de69 (patch) | |
tree | 206afaf4ef6cbe958d69d730f179651d621302c2 /spec/workers/ci | |
parent | 3fbd48e127053517e9ee0f6307989758a4d59f9a (diff) |
Improve spec
Diffstat (limited to 'spec/workers/ci')
-rw-r--r-- | spec/workers/ci/archive_traces_cron_worker_spec.rb | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/spec/workers/ci/archive_traces_cron_worker_spec.rb b/spec/workers/ci/archive_traces_cron_worker_spec.rb index 8cd1c7e3906..4ba3d436e94 100644 --- a/spec/workers/ci/archive_traces_cron_worker_spec.rb +++ b/spec/workers/ci/archive_traces_cron_worker_spec.rb @@ -30,6 +30,13 @@ describe Ci::ArchiveTracesCronWorker do it_behaves_like 'archives trace' + it 'executes service' do + expect_any_instance_of(Ci::ArchiveTraceService) + .to receive(:execute).with(build) + + subject + end + context 'when a trace had already been archived' do let!(:build) { create(:ci_build, :success, :trace_live, :trace_artifact) } let!(:build2) { create(:ci_build, :success, :trace_live) } @@ -41,34 +48,6 @@ describe Ci::ArchiveTracesCronWorker do expect(build2.job_artifacts_trace).to be_exist end end - - context 'when an unexpected exception happened during archiving' do - let!(:build) { create(:ci_build, :success, :trace_live) } - - before do - allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive_stream!).and_raise('Unexpected error') - end - - it 'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive' do - expect(Gitlab::Sentry) - .to receive(:track_exception) - .with(RuntimeError, - issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502', - extra: { job_id: build.id } ).once - - expect(Rails.logger) - .to receive(:error) - .with("Failed to archive trace. id: #{build.id} message: Unexpected error") - .and_call_original - - expect(Gitlab::Metrics) - .to receive(:counter) - .with(:job_trace_archive_failed_total, "Counter of failed attempts of trace archiving") - .and_call_original - - expect { subject }.not_to raise_error - end - end end context 'when a job was cancelled' do |