diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-20 22:34:46 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-23 21:38:05 -0700 |
commit | 291df05e434f5678c47bce9521ff15748d6c767f (patch) | |
tree | a9ebe8e457d875b18998ac1a997c2faa0b1889f8 /spec/lib/peek/views/rugged_spec.rb | |
parent | 4482b82687e5b647459946338686eca0b53b7ce4 (diff) | |
download | gitlab-ce-291df05e434f5678c47bce9521ff15748d6c767f.tar.gz |
Add Rugged calls to performance bar
This will help diagnose the source of excessive I/O from Rugged
calls. To implement this, we need to obtain the full list of arguments
sent to each request method.
Diffstat (limited to 'spec/lib/peek/views/rugged_spec.rb')
-rw-r--r-- | spec/lib/peek/views/rugged_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/peek/views/rugged_spec.rb b/spec/lib/peek/views/rugged_spec.rb new file mode 100644 index 00000000000..0fc75043df8 --- /dev/null +++ b/spec/lib/peek/views/rugged_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Peek::Views::Rugged, :request_store do + subject { described_class.new } + + let(:project) { create(:project) } + + before do + allow(Gitlab::RuggedInstrumentation).to receive(:peek_enabled?).and_return(true) + end + + it 'returns aggregated results' do + ::Gitlab::RuggedInstrumentation.query_time += 1.234 + ::Gitlab::RuggedInstrumentation.increment_query_count + ::Gitlab::RuggedInstrumentation.increment_query_count + + ::Gitlab::RuggedInstrumentation.add_call_details(feature: :rugged_test, + args: [project.repository.raw, 'HEAD'], + duration: 0.123) + ::Gitlab::RuggedInstrumentation.add_call_details(feature: :rugged_test2, + args: [project.repository.raw, 'refs/heads/master'], + duration: 0.456) + + expect(subject.duration).to be_within(0.00001).of(1.234) + expect(subject.calls).to eq(2) + + results = subject.results + expect(results[:calls]).to eq(2) + expect(results[:duration]).to eq('1234.00ms') + expect(results[:details].count).to eq(2) + + expect(results[:details][0][:args]).to eq([project.repository.raw.to_s, "refs/heads/master"]) + expect(results[:details][1][:args]).to eq([project.repository.raw.to_s, "HEAD"]) + end +end |