diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/initializers/diagnostic_reports_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/initializers/diagnostic_reports_spec.rb')
-rw-r--r-- | spec/initializers/diagnostic_reports_spec.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/spec/initializers/diagnostic_reports_spec.rb b/spec/initializers/diagnostic_reports_spec.rb index 70574194916..01b1ed9b7b5 100644 --- a/spec/initializers/diagnostic_reports_spec.rb +++ b/spec/initializers/diagnostic_reports_spec.rb @@ -21,25 +21,33 @@ RSpec.describe 'diagnostic reports' do stub_env('GITLAB_DIAGNOSTIC_REPORTS_ENABLED', true) end - context 'when run in application context' do + context 'when run in Puma context' do before do - allow(::Gitlab::Runtime).to receive(:application?).and_return(true) + allow(::Gitlab::Runtime).to receive(:puma?).and_return(true) end - it 'modifies worker startup hooks' do - report_daemon = instance_double(Gitlab::Memory::ReportsDaemon) + let(:report_daemon) { instance_double(Gitlab::Memory::ReportsDaemon) } + it 'modifies worker startup hooks, starts Gitlab::Memory::ReportsDaemon' do expect(Gitlab::Cluster::LifecycleEvents).to receive(:on_worker_start).and_call_original - expect(Gitlab::Memory::ReportsDaemon).to receive(:instance).and_return(report_daemon) - expect(report_daemon).to receive(:start) + + expect_next_instance_of(Gitlab::Memory::ReportsDaemon) do |daemon| + expect(daemon).to receive(:start).and_call_original + + # make sleep no-op + allow(daemon).to receive(:sleep).and_return(nil) + + # let alive return 3 times: true, true, false + allow(daemon).to receive(:alive).and_return(true, true, false) + end load_initializer end end - context 'when run in non-application context, such as rails console or tests' do + context 'when run in non-Puma context, such as rails console, tests, Sidekiq' do before do - allow(::Gitlab::Runtime).to receive(:application?).and_return(false) + allow(::Gitlab::Runtime).to receive(:puma?).and_return(false) end include_examples 'does not modify worker startup hooks' @@ -48,7 +56,7 @@ RSpec.describe 'diagnostic reports' do context 'when GITLAB_DIAGNOSTIC_REPORTS_ENABLED is not set' do before do - allow(::Gitlab::Runtime).to receive(:application?).and_return(true) + allow(::Gitlab::Runtime).to receive(:puma?).and_return(true) end include_examples 'does not modify worker startup hooks' @@ -57,7 +65,7 @@ RSpec.describe 'diagnostic reports' do context 'when GITLAB_DIAGNOSTIC_REPORTS_ENABLED is set to false' do before do stub_env('GITLAB_DIAGNOSTIC_REPORTS_ENABLED', false) - allow(::Gitlab::Runtime).to receive(:application?).and_return(true) + allow(::Gitlab::Runtime).to receive(:puma?).and_return(true) end include_examples 'does not modify worker startup hooks' |