summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-31 22:03:41 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-05 14:30:28 +0900
commit1d7c0390722c96aa66af5b26f5a826b97293dcd6 (patch)
treeff1795a881ac9a4fa455552ef5dd076f2978d8e2
parentb1af1f268b97c8518bf2806bca48f49174a8aead (diff)
downloadgitlab-ce-1d7c0390722c96aa66af5b26f5a826b97293dcd6.tar.gz
Fix enum lists
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/commit_status.rb14
-rw-r--r--app/services/projects/update_pages_service.rb2
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb2
-rw-r--r--lib/api/commit_statuses.rb2
-rw-r--r--lib/api/runner.rb2
-rw-r--r--spec/models/ci/build_spec.rb20
-rw-r--r--spec/models/commit_status_spec.rb20
-rw-r--r--spec/requests/api/commit_statuses_spec.rb2
-rw-r--r--spec/requests/api/runner_spec.rb4
-rw-r--r--spec/services/projects/update_pages_service_spec.rb2
-rw-r--r--spec/workers/stuck_ci_jobs_worker_spec.rb2
12 files changed, 34 insertions, 40 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 9c50d521880..ba3156154ac 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -103,7 +103,7 @@ module Ci
end
end
- before_transition any => [:failed] do |build, transition|
+ before_transition any => [:failed] do |build|
next if build.retries_max.zero?
if build.retries_count < build.retries_max
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 424f8e49d4d..1c4088d5af9 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -39,16 +39,10 @@ class CommitStatus < ActiveRecord::Base
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
enum failure_reason: {
- no_error: nil,
- failed_by_script: 1, # TODO: Not used. Should we expand pipeline as well?
- failed_by_missing_dependency: 2, # This will be done in the next MR.
- failed_by_system: 3, # TODO: Not used. What's this state?
- failed_by_job_state: 4,
- failed_by_out_of_quota: 5, # TODO: Only EE. How can we detect?
- failed_by_stuck_and_timeout: 6,
- failed_by_no_runner: 7, # TODO: Not used. How can we detect?
- failed_by_api: 8,
- failed_by_page: 9
+ unknown_failure: nil,
+ job_failure: 1,
+ api_failure: 2,
+ stuck_or_timeout_failure: 3,
}
state_machine :status do
diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb
index 0de123515c3..a18b9aae1ea 100644
--- a/app/services/projects/update_pages_service.rb
+++ b/app/services/projects/update_pages_service.rb
@@ -53,7 +53,7 @@ module Projects
log_error("Projects::UpdatePagesService: #{message}")
@status.allow_failure = !latest?
@status.description = message
- @status.drop(:failed_by_page)
+ @status.drop(:job_failure)
super
end
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index 0af8090866a..269776a1f62 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -53,7 +53,7 @@ class StuckCiJobsWorker
def drop_build(type, build, status, timeout)
Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout})"
Gitlab::OptimisticLocking.retry_lock(build, 3) do |b|
- b.drop(:failed_by_stuck_and_timeout)
+ b.drop(:stuck_or_timeout_failure)
end
end
end
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 9ab64452d2b..829eef18795 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -103,7 +103,7 @@ module API
when 'success'
status.success!
when 'failed'
- status.drop!(:failed_by_api)
+ status.drop!(:api_failure)
when 'canceled'
status.cancel!
else
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 604bfd53296..701c1bff1e0 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -127,7 +127,7 @@ module API
when 'success'
job.success
when 'failed'
- job.drop(:failed_job_state)
+ job.drop(:job_failure)
end
end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 2f39a9b4b0f..3fe3ec17d36 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1710,24 +1710,4 @@ describe Ci::Build do
end
end
end
-
- describe 'set failure_reason when drop' do
- let(:build) { create(:ci_build, :created) }
-
- before do
- build.drop!(reason)
- end
-
- context 'when failure_reason is nil' do
- let(:reason) { }
-
- it { expect(build).to be_no_error }
- end
-
- context 'when failure_reason is script_error' do
- let(:reason) { :script_error }
-
- it { expect(build).to be_failed_by_missing_dependency }
- end
- end
end
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index f7583645e69..4fd330ab7dc 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -443,4 +443,24 @@ describe CommitStatus do
end
end
end
+
+ describe 'set failure_reason when drop' do
+ let(:build) { create(:ci_build, :created) }
+
+ before do
+ build.drop!(reason)
+ end
+
+ context 'when failure_reason is nil' do
+ let(:reason) { }
+
+ it { expect(build).to be_unknown_failure }
+ end
+
+ context 'when failure_reason is job_failure' do
+ let(:reason) { :job_failure }
+
+ it { expect(build).to be_job_failure }
+ end
+ end
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index ce54a5702e3..e4c73583545 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -143,7 +143,7 @@ describe API::CommitStatuses do
expect(json_response['target_url']).to be_nil
expect(json_response['description']).to be_nil
if status == 'failed'
- expect(CommitStatus.find(json_response['id'])).to be_failed_by_api
+ expect(CommitStatus.find(json_response['id'])).to be_api_failure
end
end
end
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 48220058c88..386e76c6300 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -627,14 +627,14 @@ describe API::Runner do
update_job(state: 'success')
expect(job.reload.status).to eq 'success'
- expect(job).to be_no_error
+ expect(job).to be_unknown_failure
end
it 'mark job as failed' do
update_job(state: 'failed')
expect(job.reload.status).to eq 'failed'
- expect(job).to be_failed_by_job_state
+ expect(job).to be_job_failure
end
end
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index 0cc7dde3e4d..5fc69c7e4e5 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -116,7 +116,7 @@ describe Projects::UpdatePagesService do
expect(deploy_status.description)
.to match(/artifacts for pages are too large/)
- expect(deploy_status).to be_failed_by_page
+ expect(deploy_status).to be_job_failure
end
end
diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb
index f0691813e77..41549a77495 100644
--- a/spec/workers/stuck_ci_jobs_worker_spec.rb
+++ b/spec/workers/stuck_ci_jobs_worker_spec.rb
@@ -20,7 +20,7 @@ describe StuckCiJobsWorker do
it 'changes status' do
worker.perform
is_expected.to eq('failed')
- expect(job).to be_failed_by_stuck_and_timeout
+ expect(job).to be_stuck_or_timeout_failure
end
end