Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-02 07:08:34 +0300
committerShinya Maeda <shinya@gitlab.com>2018-06-06 11:49:48 +0300
commit5a1ee0c391a06a323d960eab6ffb33dfcf2edca7 (patch)
tree0112d50f35408d4c04c4c6e8b4e473989a08eb97 /spec/workers
parent2084e7ab9aad92d4a8196af01b9b8e02ffacb0a4 (diff)
Fix the query to select stale live traces
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/ci/rescue_stale_live_trace_worker_spec.rb47
-rw-r--r--spec/workers/stuck_ci_jobs_worker_spec.rb4
2 files changed, 13 insertions, 38 deletions
diff --git a/spec/workers/ci/rescue_stale_live_trace_worker_spec.rb b/spec/workers/ci/rescue_stale_live_trace_worker_spec.rb
index 6eee08fdbb5..0e3fbe2d3a9 100644
--- a/spec/workers/ci/rescue_stale_live_trace_worker_spec.rb
+++ b/spec/workers/ci/rescue_stale_live_trace_worker_spec.rb
@@ -25,57 +25,32 @@ describe Ci::RescueStaleLiveTraceWorker do
end
end
- context 'when a job was succeeded 2 hours ago' do
+ context 'when a job was succeeded' do
let!(:build) { create(:ci_build, :success, :trace_live) }
- before do
- build.update(finished_at: 2.hours.ago)
- end
-
it_behaves_like 'archives trace'
- # context 'when build has both archived trace and live trace' do
- # let!(:build2) { create(:ci_build, :success, :trace_live, finished_at: 2.days.ago) }
+ context 'when archive raised an exception' do
+ let!(:build) { create(:ci_build, :success, :trace_artifact, :trace_live) }
+ let!(:build2) { create(:ci_build, :success, :trace_live) }
- # it 'archives only available targets' do
- # subject
-
- # build.reload
- # expect(build.job_artifacts_trace).to be_exist
- # end
- # end
- end
+ it 'archives valid targets' do
+ expect(Rails.logger).to receive(:error).with("Failed to archive stale live trace. id: #{build.id} message: Already archived")
- context 'when a job was failed 2 hours ago' do
- let!(:build) { create(:ci_build, :failed, :trace_live) }
+ subject
- before do
- build.update(finished_at: 2.hours.ago)
+ build2.reload
+ expect(build2.job_artifacts_trace).to be_exist
+ end
end
-
- it_behaves_like 'archives trace'
end
- context 'when a job was cancelled 2 hours ago' do
+ context 'when a job was cancelled' do
let!(:build) { create(:ci_build, :canceled, :trace_live) }
- before do
- build.update(finished_at: 2.hours.ago)
- end
-
it_behaves_like 'archives trace'
end
- context 'when a job has been finished 10 minutes ago' do
- let!(:build) { create(:ci_build, :success, :trace_live) }
-
- before do
- build.update(finished_at: 10.minutes.ago)
- end
-
- it_behaves_like 'does not archive trace'
- end
-
context 'when a job is running' do
let!(:build) { create(:ci_build, :running, :trace_live) }
diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb
index c3294fce5ea..2605c14334f 100644
--- a/spec/workers/stuck_ci_jobs_worker_spec.rb
+++ b/spec/workers/stuck_ci_jobs_worker_spec.rb
@@ -134,8 +134,8 @@ describe StuckCiJobsWorker do
it 'cancels exclusive lease after worker perform' do
worker.perform
- expect(Gitlab::ExclusiveLease.new(described_class::EXCLUSIVE_LEASE_KEY, timeout: 1.hour).exists?)
- .to be_falsy
+ expect(Gitlab::ExclusiveLease.new(described_class::EXCLUSIVE_LEASE_KEY, timeout: 1.hour))
+ .not_to be_exists
end
end
end