diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 15:06:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 15:06:40 +0300 |
commit | 0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (patch) | |
tree | 9ff7dd7b21a3f9642a8fbb45c922f71a433faf02 /spec/support/sidekiq_middleware.rb | |
parent | a048261403ea7e12992ccffe704f0779235712d7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/sidekiq_middleware.rb')
-rw-r--r-- | spec/support/sidekiq_middleware.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/support/sidekiq_middleware.rb b/spec/support/sidekiq_middleware.rb new file mode 100644 index 00000000000..f6694713101 --- /dev/null +++ b/spec/support/sidekiq_middleware.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'sidekiq/testing' + +# 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 |