2020-03-11 20:09:34 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2020-03-20 17:09:17 -04:00
|
|
|
require 'shellwords'
|
2020-03-11 20:09:34 -04:00
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe 'bin/sidekiq-cluster' do
|
2020-03-11 20:09:34 -04:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
context 'when selecting some queues and excluding others' do
|
|
|
|
where(:args, :included, :excluded) do
|
|
|
|
%w[--negate cronjob] | '-qdefault,1' | '-qcronjob,1'
|
2020-11-03 01:08:58 -05:00
|
|
|
%w[--queue-selector resource_boundary=cpu] | '-qupdate_merge_requests,1' | '-qdefault,1'
|
|
|
|
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
|
2020-03-11 20:09:34 -04:00
|
|
|
%w[--experimental-queue-selector resource_boundary=cpu] | '-qupdate_merge_requests,1' | '-qdefault,1'
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it 'runs successfully', :aggregate_failures do
|
|
|
|
cmd = %w[bin/sidekiq-cluster --dryrun] + args
|
|
|
|
|
|
|
|
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
|
|
|
|
|
|
|
|
expect(status).to be(0)
|
2020-03-20 17:09:17 -04:00
|
|
|
expect(output).to include('bundle exec sidekiq')
|
|
|
|
expect(Shellwords.split(output)).to include(included)
|
|
|
|
expect(Shellwords.split(output)).not_to include(excluded)
|
2020-03-11 20:09:34 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when selecting all queues' do
|
|
|
|
[
|
|
|
|
%w[*],
|
2020-11-03 01:08:58 -05:00
|
|
|
%w[--queue-selector *],
|
|
|
|
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
|
2020-03-11 20:09:34 -04:00
|
|
|
%w[--experimental-queue-selector *]
|
|
|
|
].each do |args|
|
|
|
|
it "runs successfully with `#{args}`", :aggregate_failures do
|
|
|
|
cmd = %w[bin/sidekiq-cluster --dryrun] + args
|
|
|
|
|
|
|
|
output, status = Gitlab::Popen.popen(cmd, Rails.root.to_s)
|
|
|
|
|
|
|
|
expect(status).to be(0)
|
2020-03-20 17:09:17 -04:00
|
|
|
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')
|
2020-03-11 20:09:34 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|