Commit 38d9b4d7 authored by Shinya Maeda's avatar Shinya Maeda

Use script_failure. Add runner_system_failure. Improve spec.

parent 5d50cbfa
...@@ -40,9 +40,10 @@ class CommitStatus < ActiveRecord::Base ...@@ -40,9 +40,10 @@ class CommitStatus < ActiveRecord::Base
enum failure_reason: { enum failure_reason: {
unknown_failure: nil, unknown_failure: nil,
job_failure: 1, script_failure: 1,
api_failure: 2, api_failure: 2,
stuck_or_timeout_failure: 3 stuck_or_timeout_failure: 3,
runner_system_failure: 4
} }
state_machine :status do state_machine :status do
......
...@@ -53,7 +53,7 @@ module Projects ...@@ -53,7 +53,7 @@ module Projects
log_error("Projects::UpdatePagesService: #{message}") log_error("Projects::UpdatePagesService: #{message}")
@status.allow_failure = !latest? @status.allow_failure = !latest?
@status.description = message @status.description = message
@status.drop(:job_failure) @status.drop(:script_failure)
super super
end end
......
...@@ -129,8 +129,7 @@ module API ...@@ -129,8 +129,7 @@ module API
when 'success' when 'success'
job.success job.success
when 'failed' when 'failed'
failure_reason = params[:failure_reason] ? params[:failure_reason].to_sym : :unknown_failure job.drop(params[:failure_reason] || :unknown_failure)
job.drop(failure_reason)
end end
end end
......
...@@ -458,10 +458,10 @@ describe CommitStatus do ...@@ -458,10 +458,10 @@ describe CommitStatus do
it { is_expected.to be_unknown_failure } it { is_expected.to be_unknown_failure }
end end
context 'when failure_reason is job_failure' do context 'when failure_reason is script_failure' do
let(:reason) { :job_failure } let(:reason) { :script_failure }
it { is_expected.to be_job_failure } it { is_expected.to be_script_failure }
end end
end end
end end
...@@ -626,24 +626,34 @@ describe API::Runner do ...@@ -626,24 +626,34 @@ describe API::Runner do
it 'mark job as succeeded' do it 'mark job as succeeded' do
update_job(state: 'success') update_job(state: 'success')
expect(job.reload.status).to eq 'success' job.reload
expect(job).to be_unknown_failure expect(job).to be_success
end end
it 'mark job as failed' do it 'mark job as failed' do
update_job(state: 'failed') update_job(state: 'failed')
expect(job.reload.status).to eq 'failed' job.reload
expect(job).to be_job_failure expect(job).to be_failed
expect(job).to be_unknown_failure
end end
context 'when failure_reason is given' do context 'when failure_reason is script_failure' do
it 'mark job as failed' do before do
update_job(state: 'failed', failure_reason: 'stuck_or_timeout_failure') update_job(state: 'failed', failure_reason: 'script_failure')
job.reload
end
it { expect(job).to be_script_failure }
end
expect(job.reload.status).to eq 'failed' context 'when failure_reason is runner_system_failure' do
expect(job).to be_stuck_or_timeout_failure before do
update_job(state: 'failed', failure_reason: 'runner_system_failure')
job.reload
end end
it { expect(job).to be_runner_system_failure }
end end
end end
......
...@@ -116,7 +116,7 @@ describe Projects::UpdatePagesService do ...@@ -116,7 +116,7 @@ describe Projects::UpdatePagesService do
expect(deploy_status.description) expect(deploy_status.description)
.to match(/artifacts for pages are too large/) .to match(/artifacts for pages are too large/)
expect(deploy_status).to be_job_failure expect(deploy_status).to be_script_failure
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment