diff options
Diffstat (limited to 'spec/lib/system_check')
4 files changed, 90 insertions, 28 deletions
diff --git a/spec/lib/system_check/app/gitlab_cable_config_exists_check_spec.rb b/spec/lib/system_check/app/gitlab_cable_config_exists_check_spec.rb new file mode 100644 index 00000000000..8e127bb715c --- /dev/null +++ b/spec/lib/system_check/app/gitlab_cable_config_exists_check_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe SystemCheck::App::GitlabCableConfigExistsCheck, feature_category: :redis do + subject(:system_check) { described_class.new } + + describe '#check?' do + subject { system_check.check? } + + context 'when config/cable.yml exists' do + before do + allow(File).to receive(:exist?).and_return(true) + end + + it { is_expected.to eq(true) } + end + + context 'when config/cable.yml does not exist' do + before do + allow(File).to receive(:exist?).and_return(false) + end + + it { is_expected.to eq(false) } + end + end +end diff --git a/spec/lib/system_check/app/gitlab_resque_config_exists_check_spec.rb b/spec/lib/system_check/app/gitlab_resque_config_exists_check_spec.rb new file mode 100644 index 00000000000..d2e5dec7460 --- /dev/null +++ b/spec/lib/system_check/app/gitlab_resque_config_exists_check_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe SystemCheck::App::GitlabResqueConfigExistsCheck, feature_category: :redis do + subject(:system_check) { described_class.new } + + describe '#check?' do + subject { system_check.check? } + + context 'when config/resque.yml exists' do + before do + allow(File).to receive(:exist?).and_return(true) + end + + it { is_expected.to eq(true) } + end + + context 'when config/resque.yml does not exist' do + before do + allow(File).to receive(:exist?).and_return(false) + end + + it { is_expected.to eq(false) } + end + end +end diff --git a/spec/lib/system_check/base_check_spec.rb b/spec/lib/system_check/base_check_spec.rb index 241c3b33777..168bda07791 100644 --- a/spec/lib/system_check/base_check_spec.rb +++ b/spec/lib/system_check/base_check_spec.rb @@ -12,7 +12,7 @@ RSpec.describe SystemCheck::BaseCheck do it 'responds to Gitlab::TaskHelpers methods' do expect(subject).to respond_to :ask_to_continue, :os_name, :prompt, :run_and_match, :run_command, - :run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :all_repos, + :run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :repository_storage_paths_args, :user_home, :checkout_or_clone_version, :clone_repo, :checkout_version end end diff --git a/spec/lib/system_check/sidekiq_check_spec.rb b/spec/lib/system_check/sidekiq_check_spec.rb index c2f61e0e4b7..ff4eece8f7c 100644 --- a/spec/lib/system_check/sidekiq_check_spec.rb +++ b/spec/lib/system_check/sidekiq_check_spec.rb @@ -37,45 +37,53 @@ RSpec.describe SystemCheck::SidekiqCheck do ) end - it 'succeeds when one cluster process and one or more worker processes are running' do - stub_ps_output <<~PS - root 2193947 0.9 0.1 146564 18104 ? Ssl 17:34 0:00 ruby bin/sidekiq-cluster * -P ... - root 2193955 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... - root 2193956 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... - PS - - expect_check_output <<~OUTPUT - Running? ... yes - Number of Sidekiq processes (cluster/worker) ... 1/2 - OUTPUT - end - - # TODO: Running without a cluster is deprecated and will be removed in GitLab 14.0 - # https://gitlab.com/gitlab-org/gitlab/-/issues/323225 - context 'when running without a cluster' do - it 'fails when more than one worker process is running' do + context 'when only a worker process is running' do + before do stub_ps_output <<~PS root 2193955 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... - root 2193956 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... PS + end - expect_check_output include( - 'Running? ... yes', - 'Number of Sidekiq processes (cluster/worker) ... 0/2', - 'Please fix the error above and rerun the checks.' - ) + it 'fails with the right message for systemd' do + allow(File).to receive(:symlink?).with(described_class::SYSTEMD_UNIT_PATH).and_return(true) + + expect_check_output <<~OUTPUT + Running? ... yes + Number of Sidekiq processes (cluster/worker) ... 0/1 + Try fixing it: + sudo systemctl restart gitlab-sidekiq.service + Please fix the error above and rerun the checks. + OUTPUT end - it 'succeeds when one worker process is running' do - stub_ps_output <<~PS - root 2193955 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... - PS + it 'fails with the right message for sysvinit' do + allow(File).to receive(:symlink?).with(described_class::SYSTEMD_UNIT_PATH).and_return(false) + allow(subject).to receive(:gitlab_user).and_return('git') expect_check_output <<~OUTPUT Running? ... yes Number of Sidekiq processes (cluster/worker) ... 0/1 + Try fixing it: + sudo service gitlab stop + sudo pkill -u git -f sidekiq + sleep 10 && sudo pkill -9 -u git -f sidekiq + sudo service gitlab start + Please fix the error above and rerun the checks. OUTPUT end end + + it 'succeeds when one cluster process and one or more worker processes are running' do + stub_ps_output <<~PS + root 2193947 0.9 0.1 146564 18104 ? Ssl 17:34 0:00 ruby bin/sidekiq-cluster * -P ... + root 2193955 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... + root 2193956 92.2 3.1 4675972 515516 ? Sl 17:34 0:13 sidekiq 5.2.9 ... + PS + + expect_check_output <<~OUTPUT + Running? ... yes + Number of Sidekiq processes (cluster/worker) ... 1/2 + OUTPUT + end end end |