diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-09 15:30:57 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-11-14 19:07:29 +0300 |
commit | 19d6cdfe1b374fce6119a85a6e221d9e354dc0e3 (patch) | |
tree | 09f25ff1c9199bf01c6a5e7e07a8a005ce991280 /spec | |
parent | dd0e4f30b3bf71dfd8561410f9bcc7213d7c6ca0 (diff) |
Merge branch '39958-updatemergerequestsworker-are-failing-on-metric-tagging' into 'master'
Revert "add metrics tagging to the sidekiq middleware"
Closes #39958
See merge request gitlab-org/gitlab-ce!15285
(cherry picked from commit 43d98cd1ff3ea0dd6a794ba4d1d621415d439985)
7fd3ce41 Revert "add metrics tagging to the sidekiq middleware"
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb index 6d69b5305d2..ae1d8b47fe9 100644 --- a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb @@ -4,32 +4,40 @@ describe Gitlab::Metrics::SidekiqMiddleware do let(:middleware) { described_class.new } let(:message) { { 'args' => ['test'], 'enqueued_at' => Time.new(2016, 6, 23, 6, 59).to_f } } - def run(worker, message) - expect(Gitlab::Metrics::BackgroundTransaction).to receive(:new) - .with(worker.class) - .and_call_original - - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) - .with(:sidekiq_queue_duration, instance_of(Float)) + describe '#call' do + it 'tracks the transaction' do + worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) + expect(Gitlab::Metrics::BackgroundTransaction).to receive(:new) + .with(worker.class) + .and_call_original - middleware.call(worker, message, :test) { nil } - end + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) + .with(:sidekiq_queue_duration, instance_of(Float)) - describe '#call' do - let(:test_worker_class) { double(:class, name: 'TestWorker') } - let(:worker) { double(:worker, class: test_worker_class) } + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) - it 'tracks the transaction' do - run(worker, message) + middleware.call(worker, message, :test) { nil } end it 'tracks the transaction (for messages without `enqueued_at`)' do - run(worker, {}) + worker = double(:worker, class: double(:class, name: 'TestWorker')) + + expect(Gitlab::Metrics::BackgroundTransaction).to receive(:new) + .with(worker.class) + .and_call_original + + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) + .with(:sidekiq_queue_duration, instance_of(Float)) + + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) + + middleware.call(worker, {}, :test) { nil } end it 'tracks any raised exceptions' do + worker = double(:worker, class: double(:class, name: 'TestWorker')) + expect_any_instance_of(Gitlab::Metrics::Transaction) .to receive(:run).and_raise(RuntimeError) |