Merge branch 'check_pg_stat_activity' into 'master'
Show pg_stat_activity before each test run See merge request gitlab-org/gitlab-ce!25723
This commit is contained in:
commit
b923d1b57e
1 changed files with 19 additions and 0 deletions
19
spec/support/pg_stat_activity.rb
Normal file
19
spec/support/pg_stat_activity.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before do
|
||||
if Gitlab::Database.postgresql? && ENV['PG_STAT_WARNING_THRESHOLD']
|
||||
warning_threshold = ENV['PG_STAT_WARNING_THRESHOLD'].to_i
|
||||
results = ActiveRecord::Base.connection.execute('SELECT * FROM pg_stat_activity')
|
||||
ntuples = results.ntuples
|
||||
|
||||
warn("pg_stat_activity count: #{ntuples}")
|
||||
|
||||
if ntuples > warning_threshold
|
||||
results.each do |result|
|
||||
warn result.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue