Commit b1209c39 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sidekiq-cluster-dryrun-emit-command' into 'master'

Make sidekiq-cluster --dryrun emit the literal commands

See merge request gitlab-org/gitlab!27692
parents a989bee5 f2021ec6
# frozen_string_literal: true # frozen_string_literal: true
require 'shellwords'
module Gitlab module Gitlab
module SidekiqCluster module SidekiqCluster
# The signals that should terminate both the master and workers. # The signals that should terminate both the master and workers.
...@@ -73,9 +75,9 @@ module Gitlab ...@@ -73,9 +75,9 @@ module Gitlab
counts = count_by_queue(queues) counts = count_by_queue(queues)
cmd = %w[bundle exec sidekiq] cmd = %w[bundle exec sidekiq]
cmd << "-c #{self.concurrency(queues, min_concurrency, max_concurrency)}" cmd << "-c#{self.concurrency(queues, min_concurrency, max_concurrency)}"
cmd << "-e#{env}" cmd << "-e#{env}"
cmd << "-gqueues: #{proc_details(counts)}" cmd << "-gqueues:#{proc_details(counts)}"
cmd << "-r#{directory}" cmd << "-r#{directory}"
counts.each do |queue, count| counts.each do |queue, count|
...@@ -83,7 +85,7 @@ module Gitlab ...@@ -83,7 +85,7 @@ module Gitlab
end end
if dryrun if dryrun
puts "Sidekiq command: #{cmd}" # rubocop:disable Rails/Output puts Shellwords.join(cmd) # rubocop:disable Rails/Output
return return
end end
...@@ -112,7 +114,7 @@ module Gitlab ...@@ -112,7 +114,7 @@ module Gitlab
else else
"#{queue} (#{count})" "#{queue} (#{count})"
end end
end.join(', ') end.join(',')
end end
def self.concurrency(queues, min_concurrency, max_concurrency) def self.concurrency(queues, min_concurrency, max_concurrency)
......
...@@ -64,7 +64,9 @@ module Gitlab ...@@ -64,7 +64,9 @@ module Gitlab
'No queues found, you must select at least one queue' 'No queues found, you must select at least one queue'
end end
unless @dryrun
@logger.info("Starting cluster with #{queue_groups.length} processes") @logger.info("Starting cluster with #{queue_groups.length} processes")
end
@processes = SidekiqCluster.start( @processes = SidekiqCluster.start(
queue_groups, queue_groups,
......
# frozen_string_literal: true # frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
require 'shellwords'
describe 'bin/sidekiq-cluster' do describe 'bin/sidekiq-cluster' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -18,9 +19,9 @@ describe 'bin/sidekiq-cluster' do ...@@ -18,9 +19,9 @@ describe 'bin/sidekiq-cluster' do
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s) output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
expect(status).to be(0) expect(status).to be(0)
expect(output).to include('"bundle", "exec", "sidekiq"') expect(output).to include('bundle exec sidekiq')
expect(output).to include(included) expect(Shellwords.split(output)).to include(included)
expect(output).not_to include(excluded) expect(Shellwords.split(output)).not_to include(excluded)
end end
end end
end end
...@@ -36,9 +37,9 @@ describe 'bin/sidekiq-cluster' do ...@@ -36,9 +37,9 @@ describe 'bin/sidekiq-cluster' do
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s) output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
expect(status).to be(0) expect(status).to be(0)
expect(output).to include('"bundle", "exec", "sidekiq"') expect(output).to include('bundle exec sidekiq')
expect(output).to include('-qdefault,1') expect(Shellwords.split(output)).to include('-qdefault,1')
expect(output).to include('-qcronjob:ci_archive_traces_cron,1') expect(Shellwords.split(output)).to include('-qcronjob:ci_archive_traces_cron,1')
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment