summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-09-10 08:40:45 +0000
committerRémy Coutable <remy@rymai.me>2018-09-10 08:40:45 +0000
commit3d1fa7902afa67ea7cffd4b507d7b66be336978a (patch)
tree4d42e144341ec9cb7b85b7052ee301fc5092fbc1
parentcee47fb31dc48d6ae16f1fb9fe3d15814a080a28 (diff)
parent39743eaf194b18af622e357ef6bc8edb3db50f10 (diff)
downloadgitlab-ce-3d1fa7902afa67ea7cffd4b507d7b66be336978a.tar.gz
Merge branch 'sidekiq-query' into 'master'
Disable query limit counter in sidekiq See merge request gitlab-org/gitlab-ce!21470
-rw-r--r--spec/support/sidekiq.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/support/sidekiq.rb b/spec/support/sidekiq.rb
index d143014692d..6c4e11910d3 100644
--- a/spec/support/sidekiq.rb
+++ b/spec/support/sidekiq.rb
@@ -1,7 +1,27 @@
require 'sidekiq/testing/inline'
+# If Sidekiq::Testing.inline! is used, SQL transactions done inside
+# Sidekiq worker are included in the SQL query limit (in a real
+# deployment sidekiq worker is executed separately). To avoid
+# increasing SQL limit counter, the request is marked as whitelisted
+# during Sidekiq block
+class DisableQueryLimit
+ def call(worker_instance, msg, queue)
+ transaction = Gitlab::QueryLimiting::Transaction.current
+
+ if !transaction.respond_to?(:whitelisted) || transaction.whitelisted
+ yield
+ else
+ transaction.whitelisted = true
+ yield
+ transaction.whitelisted = false
+ end
+ end
+end
+
Sidekiq::Testing.server_middleware do |chain|
chain.add Gitlab::SidekiqStatus::ServerMiddleware
+ chain.add DisableQueryLimit
end
RSpec.configure do |config|