Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-06 15:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-06 15:08:19 +0300
commiteaf41d710dd1ee39125f9dce75812f0b6247adba (patch)
tree031a83beaea241474d5f2bdd5670961309cff000 /spec/commands
parent5bc6fcec0edaa4032afacce1aa5e5289e9ae07ac (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/commands')
-rw-r--r--spec/commands/sidekiq_cluster/cli_spec.rb43
1 files changed, 38 insertions, 5 deletions
diff --git a/spec/commands/sidekiq_cluster/cli_spec.rb b/spec/commands/sidekiq_cluster/cli_spec.rb
index 4618c6681d3..c2ea9455de6 100644
--- a/spec/commands/sidekiq_cluster/cli_spec.rb
+++ b/spec/commands/sidekiq_cluster/cli_spec.rb
@@ -299,11 +299,11 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
end
context 'starting the server' do
- context 'without --dryrun' do
- before do
- allow(Gitlab::SidekiqCluster).to receive(:start).and_return([])
- end
+ before do
+ allow(Gitlab::SidekiqCluster).to receive(:start).and_return([])
+ end
+ context 'without --dryrun' do
it 'wipes the metrics directory before starting workers' do
expect(metrics_cleanup_service).to receive(:execute).ordered
expect(Gitlab::SidekiqCluster).to receive(:start).ordered.and_return([])
@@ -403,9 +403,42 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
let(:sidekiq_exporter_enabled) { true }
let(:metrics_server_pid) { 99 }
let(:sidekiq_worker_pids) { [2, 42] }
+ let(:waiter_threads) { [instance_double('Process::Waiter'), instance_double('Process::Waiter')] }
+ let(:process_status) { instance_double('Process::Status') }
before do
- allow(Gitlab::SidekiqCluster).to receive(:start).and_return(sidekiq_worker_pids)
+ allow(Gitlab::SidekiqCluster).to receive(:start).and_return(waiter_threads)
+ allow(process_status).to receive(:success?).and_return(true)
+ allow(cli).to receive(:exit)
+
+ waiter_threads.each.with_index do |thread, i|
+ allow(thread).to receive(:join)
+ allow(thread).to receive(:pid).and_return(sidekiq_worker_pids[i])
+ allow(thread).to receive(:value).and_return(process_status)
+ end
+ end
+
+ context 'when one of the workers has been terminated gracefully' do
+ it 'stops the entire process cluster' do
+ expect(MetricsServer).to receive(:start_for_sidekiq).once.and_return(metrics_server_pid)
+ expect(supervisor).to receive(:supervise).and_yield([2, 99])
+ expect(supervisor).to receive(:shutdown)
+ expect(cli).not_to receive(:exit).with(1)
+
+ cli.run(%w(foo))
+ end
+ end
+
+ context 'when one of the workers has failed' do
+ it 'stops the entire process cluster and exits with a non-zero code' do
+ expect(MetricsServer).to receive(:start_for_sidekiq).once.and_return(metrics_server_pid)
+ expect(supervisor).to receive(:supervise).and_yield([2, 99])
+ expect(supervisor).to receive(:shutdown)
+ expect(process_status).to receive(:success?).and_return(false)
+ expect(cli).to receive(:exit).with(1)
+
+ cli.run(%w(foo))
+ end
end
it 'stops the entire process cluster if one of the workers has been terminated' do