diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-07 18:06:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-07 18:06:33 +0300 |
commit | 90a06a20be61bb6d48d77746091492831153e075 (patch) | |
tree | bdba99289605f8b5acf12159d02aeb23f8690202 /spec/lib/gitlab/health_checks | |
parent | 84a0e65ac88c7a3db86a0e4347606ba093490bef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/health_checks')
-rw-r--r-- | spec/lib/gitlab/health_checks/master_check_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/lib/gitlab/health_checks/master_check_spec.rb b/spec/lib/gitlab/health_checks/master_check_spec.rb new file mode 100644 index 00000000000..91441a7ddc3 --- /dev/null +++ b/spec/lib/gitlab/health_checks/master_check_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' +require_relative './simple_check_shared' + +describe Gitlab::HealthChecks::MasterCheck do + let(:result_class) { Gitlab::HealthChecks::Result } + + SUCCESS_CODE = 100 + FAILURE_CODE = 101 + + before do + described_class.register_master + end + + after do + described_class.finish_master + end + + describe '#readiness' do + context 'when master is running' do + it 'worker does return success' do + _, child_status = run_worker + + expect(child_status.exitstatus).to eq(SUCCESS_CODE) + end + end + + context 'when master finishes early' do + before do + described_class.send(:close_write) + end + + it 'worker does return failure' do + _, child_status = run_worker + + expect(child_status.exitstatus).to eq(FAILURE_CODE) + end + end + + def run_worker + pid = fork do + described_class.register_worker + + exit(described_class.readiness.success ? SUCCESS_CODE : FAILURE_CODE) + end + + Process.wait2(pid) + end + end +end |