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
require 'shellwords'
module Gitlab
module SidekiqCluster
# The signals that should terminate both the master and workers.
......@@ -73,9 +75,9 @@ module Gitlab
counts = count_by_queue(queues)
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 << "-gqueues: #{proc_details(counts)}"
cmd << "-gqueues:#{proc_details(counts)}"
cmd << "-r#{directory}"
counts.each do |queue, count|
......@@ -83,7 +85,7 @@ module Gitlab
end
if dryrun
puts "Sidekiq command: #{cmd}" # rubocop:disable Rails/Output
puts Shellwords.join(cmd) # rubocop:disable Rails/Output
return
end
......@@ -112,7 +114,7 @@ module Gitlab
else
"#{queue} (#{count})"
end
end.join(', ')
end.join(',')
end
def self.concurrency(queues, min_concurrency, max_concurrency)
......
......@@ -64,7 +64,9 @@ module Gitlab
'No queues found, you must select at least one queue'
end
unless @dryrun
@logger.info("Starting cluster with #{queue_groups.length} processes")
end
@processes = SidekiqCluster.start(
queue_groups,
......
# frozen_string_literal: true
require 'spec_helper'
require 'shellwords'
describe 'bin/sidekiq-cluster' do
using RSpec::Parameterized::TableSyntax
......@@ -18,9 +19,9 @@ describe 'bin/sidekiq-cluster' do
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
expect(status).to be(0)
expect(output).to include('"bundle", "exec", "sidekiq"')
expect(output).to include(included)
expect(output).not_to include(excluded)
expect(output).to include('bundle exec sidekiq')
expect(Shellwords.split(output)).to include(included)
expect(Shellwords.split(output)).not_to include(excluded)
end
end
end
......@@ -36,9 +37,9 @@ describe 'bin/sidekiq-cluster' do
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
expect(status).to be(0)
expect(output).to include('"bundle", "exec", "sidekiq"')
expect(output).to include('-qdefault,1')
expect(output).to include('-qcronjob:ci_archive_traces_cron,1')
expect(output).to include('bundle exec sidekiq')
expect(Shellwords.split(output)).to include('-qdefault,1')
expect(Shellwords.split(output)).to include('-qcronjob:ci_archive_traces_cron,1')
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