summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-11-25 11:29:48 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2015-11-25 11:29:48 +0000
commitef2bc0f0bf206198a1f4097cc3a5d2fb47ceb007 (patch)
treeab0baca6ab80a7727547f651ba8475619ac46b7b /spec
parent4cfc3df534c50957725f7e1f80c82f88fd764f70 (diff)
parent97f8c6279fc39c4bad87bb880eba04802f6d351d (diff)
downloadgitlab-ce-ef2bc0f0bf206198a1f4097cc3a5d2fb47ceb007.tar.gz
Merge branch 'sherlock-total-query-time' into 'master'
Added total query time to Sherlock This makes it easier to see if a problem is caused by slow queries or slow Ruby code (unrelated to any SQL queries that might be used). See merge request !1887
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/sherlock/transaction_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sherlock/transaction_spec.rb b/spec/lib/gitlab/sherlock/transaction_spec.rb
index bb49fb65cf8..fb80c62c794 100644
--- a/spec/lib/gitlab/sherlock/transaction_spec.rb
+++ b/spec/lib/gitlab/sherlock/transaction_spec.rb
@@ -84,6 +84,19 @@ describe Gitlab::Sherlock::Transaction do
end
end
+ describe '#query_duration' do
+ it 'returns the total query duration in seconds' do
+ time = Time.now
+ query1 = Gitlab::Sherlock::Query.new('SELECT 1', time, time + 5)
+ query2 = Gitlab::Sherlock::Query.new('SELECT 2', time, time + 2)
+
+ transaction.queries << query1
+ transaction.queries << query2
+
+ expect(transaction.query_duration).to be_within(0.1).of(7.0)
+ end
+ end
+
describe '#to_param' do
it 'returns the transaction ID' do
expect(transaction.to_param).to eq(transaction.id)