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:
Diffstat (limited to 'spec/commands/sidekiq_cluster/cli_spec.rb')
-rw-r--r--spec/commands/sidekiq_cluster/cli_spec.rb102
1 files changed, 25 insertions, 77 deletions
diff --git a/spec/commands/sidekiq_cluster/cli_spec.rb b/spec/commands/sidekiq_cluster/cli_spec.rb
index bbf5f2bc4d9..223d0c3b0ec 100644
--- a/spec/commands/sidekiq_cluster/cli_spec.rb
+++ b/spec/commands/sidekiq_cluster/cli_spec.rb
@@ -18,7 +18,6 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
let(:sidekiq_exporter_enabled) { false }
let(:sidekiq_exporter_port) { '3807' }
- let(:sidekiq_health_checks_port) { '3807' }
let(:config_file) { Tempfile.new('gitlab.yml') }
let(:config) do
@@ -29,11 +28,6 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
'address' => 'localhost',
'enabled' => sidekiq_exporter_enabled,
'port' => sidekiq_exporter_port
- },
- 'sidekiq_health_checks' => {
- 'address' => 'localhost',
- 'enabled' => sidekiq_exporter_enabled,
- 'port' => sidekiq_health_checks_port
}
}
}
@@ -310,63 +304,37 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
cli.run(%w(foo))
end
- context 'when there are no sidekiq_health_checks settings set' do
- let(:sidekiq_exporter_enabled) { true }
-
- it 'does not start a sidekiq metrics server' do
- expect(MetricsServer).not_to receive(:fork)
-
- cli.run(%w(foo))
- end
- end
-
- context 'when the sidekiq_exporter.port setting is not set' do
- let(:sidekiq_exporter_enabled) { true }
-
- it 'does not start a sidekiq metrics server' do
- expect(MetricsServer).not_to receive(:fork)
-
- cli.run(%w(foo))
- end
- end
-
- context 'when sidekiq_exporter.enabled setting is not set' do
+ context 'when sidekiq_exporter is not set up' do
let(:config) do
{
'test' => {
'monitoring' => {
- 'sidekiq_exporter' => {},
- 'sidekiq_health_checks' => {
- 'address' => 'localhost',
- 'enabled' => sidekiq_exporter_enabled,
- 'port' => sidekiq_health_checks_port
- }
+ 'sidekiq_exporter' => {}
}
}
}
end
it 'does not start a sidekiq metrics server' do
- expect(MetricsServer).not_to receive(:fork)
+ expect(MetricsServer).not_to receive(:start_for_sidekiq)
cli.run(%w(foo))
end
end
- context 'with a blank sidekiq_exporter setting' do
+ context 'with missing sidekiq_exporter setting' do
let(:config) do
{
'test' => {
'monitoring' => {
- 'sidekiq_exporter' => nil,
- 'sidekiq_health_checks' => nil
+ 'sidekiq_exporter' => nil
}
}
}
end
it 'does not start a sidekiq metrics server' do
- expect(MetricsServer).not_to receive(:fork)
+ expect(MetricsServer).not_to receive(:start_for_sidekiq)
cli.run(%w(foo))
end
@@ -376,26 +344,21 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
end
end
- context 'with valid settings' do
- using RSpec::Parameterized::TableSyntax
+ context 'when sidekiq_exporter is disabled' do
+ it 'does not start a sidekiq metrics server' do
+ expect(MetricsServer).not_to receive(:start_for_sidekiq)
- where(:sidekiq_exporter_enabled, :sidekiq_exporter_port, :sidekiq_health_checks_port, :start_metrics_server) do
- true | '3807' | '3907' | true
- true | '3807' | '3807' | false
- false | '3807' | '3907' | false
- false | '3807' | '3907' | false
+ cli.run(%w(foo))
end
+ end
+
+ context 'when sidekiq_exporter is enabled' do
+ let(:sidekiq_exporter_enabled) { true }
- with_them do
- specify do
- if start_metrics_server
- expect(MetricsServer).to receive(:fork).with('sidekiq', metrics_dir: metrics_dir, reset_signals: trapped_signals)
- else
- expect(MetricsServer).not_to receive(:fork)
- end
+ it 'starts the metrics server' do
+ expect(MetricsServer).to receive(:start_for_sidekiq).with(metrics_dir: metrics_dir, reset_signals: trapped_signals)
- cli.run(%w(foo))
- end
+ cli.run(%w(foo))
end
end
@@ -421,7 +384,7 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
let(:sidekiq_exporter_enabled) { true }
it 'does not start the server' do
- expect(MetricsServer).not_to receive(:fork)
+ expect(MetricsServer).not_to receive(:start_for_sidekiq)
cli.run(%w(foo --dryrun))
end
@@ -431,7 +394,6 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
context 'supervising the cluster' do
let(:sidekiq_exporter_enabled) { true }
- let(:sidekiq_health_checks_port) { '3907' }
let(:metrics_server_pid) { 99 }
let(:sidekiq_worker_pids) { [2, 42] }
@@ -440,32 +402,18 @@ RSpec.describe Gitlab::SidekiqCluster::CLI, stub_settings_source: true do # rubo
end
it 'stops the entire process cluster if one of the workers has been terminated' do
- expect(supervisor).to receive(:alive).and_return(true)
- expect(supervisor).to receive(:supervise).and_yield([2])
- expect(MetricsServer).to receive(:fork).once.and_return(metrics_server_pid)
- expect(Gitlab::ProcessManagement).to receive(:signal_processes).with([42, 99], :TERM)
+ 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)
cli.run(%w(foo))
end
- context 'when the supervisor is alive' do
- it 'restarts the metrics server when it is down' do
- expect(supervisor).to receive(:alive).and_return(true)
- expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
- expect(MetricsServer).to receive(:fork).twice.and_return(metrics_server_pid)
+ it 'restarts the metrics server when it is down' do
+ expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
+ expect(MetricsServer).to receive(:start_for_sidekiq).twice.and_return(metrics_server_pid)
- cli.run(%w(foo))
- end
- end
-
- context 'when the supervisor is shutting down' do
- it 'does not restart the metrics server' do
- expect(supervisor).to receive(:alive).and_return(false)
- expect(supervisor).to receive(:supervise).and_yield([metrics_server_pid])
- expect(MetricsServer).to receive(:fork).once.and_return(metrics_server_pid)
-
- cli.run(%w(foo))
- end
+ cli.run(%w(foo))
end
end
end