summaryrefslogtreecommitdiff
path: root/spec/workers/archive_trace_worker_spec.rb
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-11-29 14:51:03 +0900
committerShinya Maeda <shinya@gitlab.com>2018-11-29 14:51:03 +0900
commitaf5bf56857bd6e88bc9ea3322a0873ff6767de69 (patch)
tree206afaf4ef6cbe958d69d730f179651d621302c2 /spec/workers/archive_trace_worker_spec.rb
parent3fbd48e127053517e9ee0f6307989758a4d59f9a (diff)
downloadgitlab-ce-af5bf56857bd6e88bc9ea3322a0873ff6767de69.tar.gz
Improve spec
Diffstat (limited to 'spec/workers/archive_trace_worker_spec.rb')
-rw-r--r--spec/workers/archive_trace_worker_spec.rb36
1 files changed, 5 insertions, 31 deletions
diff --git a/spec/workers/archive_trace_worker_spec.rb b/spec/workers/archive_trace_worker_spec.rb
index ce71468202f..7244ad4f199 100644
--- a/spec/workers/archive_trace_worker_spec.rb
+++ b/spec/workers/archive_trace_worker_spec.rb
@@ -5,10 +5,11 @@ describe ArchiveTraceWorker do
subject { described_class.new.perform(job&.id) }
context 'when job is found' do
- let(:job) { create(:ci_build) }
+ let(:job) { create(:ci_build, :trace_live) }
it 'executes service' do
- expect_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!)
+ expect_any_instance_of(Ci::ArchiveTraceService)
+ .to receive(:execute).with(job)
subject
end
@@ -18,38 +19,11 @@ describe ArchiveTraceWorker do
let(:job) { nil }
it 'does not execute service' do
- expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive!)
+ expect_any_instance_of(Ci::ArchiveTraceService)
+ .not_to receive(:execute)
subject
end
end
-
- context 'when an unexpected exception happened during archiving' do
- let!(:job) { 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: job.id } ).once
-
- expect(Rails.logger)
- .to receive(:error)
- .with("Failed to archive trace. id: #{job.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
end