diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-05 17:04:54 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-03-05 17:04:54 +0000 |
commit | b923d1b57e349979017f42948c2377478be03e11 (patch) | |
tree | 2fbb665f9924cf1a2bbabca7c155401210b2835a | |
parent | b3bd85643029f90269338ae6f37f2005563f77ff (diff) | |
parent | be99adb1498420be74d05d3e328632b24b5725a6 (diff) | |
download | gitlab-ce-b923d1b57e349979017f42948c2377478be03e11.tar.gz |
Merge branch 'check_pg_stat_activity' into 'master'
Show pg_stat_activity before each test run
See merge request gitlab-org/gitlab-ce!25723
-rw-r--r-- | spec/support/pg_stat_activity.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/pg_stat_activity.rb b/spec/support/pg_stat_activity.rb new file mode 100644 index 00000000000..f93fba08a19 --- /dev/null +++ b/spec/support/pg_stat_activity.rb @@ -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 |