Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-07-21 08:34:46 +0300
committerStan Hu <stanhu@gmail.com>2019-07-24 07:38:05 +0300
commit291df05e434f5678c47bce9521ff15748d6c767f (patch)
treea9ebe8e457d875b18998ac1a997c2faa0b1889f8 /spec/lib/peek
parent4482b82687e5b647459946338686eca0b53b7ce4 (diff)
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')
-rw-r--r--spec/lib/peek/views/rugged_spec.rb37
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