diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-06-02 13:08:34 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-06-06 17:49:48 +0900 |
commit | 5a1ee0c391a06a323d960eab6ffb33dfcf2edca7 (patch) | |
tree | 0112d50f35408d4c04c4c6e8b4e473989a08eb97 /spec/models/ci | |
parent | 2084e7ab9aad92d4a8196af01b9b8e02ffacb0a4 (diff) | |
download | gitlab-ce-5a1ee0c391a06a323d960eab6ffb33dfcf2edca7.tar.gz |
Fix the query to select stale live traces
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/build_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/ci/build_trace_chunk_spec.rb | 40 |
2 files changed, 20 insertions, 40 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 5e27cca6771..1b26c8d3b49 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -116,6 +116,26 @@ describe Ci::Build do end end + describe '.with_live_trace' do + subject { described_class.with_live_trace } + + context 'when build has live trace' do + let!(:build) { create(:ci_build, :success, :trace_live) } + + it 'selects the build' do + is_expected.to eq([build]) + end + end + + context 'when build does not have live trace' do + let!(:build) { create(:ci_build, :success, :trace_artifact) } + + it 'selects the build' do + is_expected.to be_empty + end + end + end + describe '#actionize' do context 'when build is a created' do before do diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb index 2dd8e935d62..cbcf1e55979 100644 --- a/spec/models/ci/build_trace_chunk_spec.rb +++ b/spec/models/ci/build_trace_chunk_spec.rb @@ -35,46 +35,6 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do end end - describe '.find_builds_from_stale_live_traces' do - subject { described_class.find_builds_from_stale_live_traces } - - context 'when build status is finished' do - context 'when build finished 2 days ago' do - context 'when build has an archived trace' do - let!(:build) { create(:ci_build, :success, :trace_artifact, finished_at: 2.days.ago) } - - it 'does not yield build id' do - expect { |b| described_class.find_builds_from_stale_live_traces(&b) }.not_to yield_control - end - end - - context 'when build has a live trace' do - let!(:build) { create(:ci_build, :success, :trace_live, finished_at: 2.days.ago) } - - it 'yields build id' do - expect { |b| described_class.find_builds_from_stale_live_traces(&b) }.to yield_with_args([build.id]) - end - end - end - - context 'when build finished 10 minutes ago' do - let!(:build) { create(:ci_build, :success, :trace_live, finished_at: 10.minutes.ago) } - - it 'does not yield build id' do - expect { |b| described_class.find_builds_from_stale_live_traces(&b) }.not_to yield_control - end - end - end - - context 'when build status is running' do - let!(:build) { create(:ci_build, :running, :trace_live) } - - it 'does not yield build id' do - expect { |b| described_class.find_builds_from_stale_live_traces(&b) }.not_to yield_control - end - end - end - describe '#data' do subject { build_trace_chunk.data } |