Commit 52bdd6c9 authored by Thong Kuah's avatar Thong Kuah

Move specs to run all cases of ci_enable_live_trace FF

We should test the cases where ci_enable_live_trace FF is false, and
true.
parent 22a37107
......@@ -281,6 +281,52 @@ RSpec.shared_examples 'common trace features' do
describe '#archive!' do
subject { trace.archive! }
context 'when live trace chunks exists' do
before do
# Build a trace_chunk manually
# It is possible to do so with trace.set but only if ci_enable_live_trace FF is enabled
#
# We need the job to have a trace_chunk because we only use #stick in
# the case where trace_chunks exist.
stream = Gitlab::Ci::Trace::Stream.new do
Gitlab::Ci::Trace::ChunkedIO.new(trace.job)
end
stream.set(+"12\n34")
end
# We check the before setup actually sets up job trace_chunks
it 'has job trace_chunks' do
expect(trace.job.trace_chunks).to be_present
end
context 'gitlab_ci_archived_trace_consistent_reads feature flag enabled' do
before do
stub_feature_flags(gitlab_ci_archived_trace_consistent_reads: trace.job.project)
end
it 'calls ::Gitlab::Database::LoadBalancing::Sticking.stick' do
expect(::Gitlab::Database::LoadBalancing::Sticking).to receive(:stick)
.with(described_class::LOAD_BALANCING_STICKING_NAMESPACE, trace.job.id)
.and_call_original
subject
end
end
context 'gitlab_ci_archived_trace_consistent_reads feature flag disabled' do
before do
stub_feature_flags(gitlab_ci_archived_trace_consistent_reads: false)
end
it 'does not call ::Gitlab::Database::LoadBalancing::Sticking.stick' do
expect(::Gitlab::Database::LoadBalancing::Sticking).not_to receive(:stick)
subject
end
end
end
context 'when build status is success' do
let!(:build) { create(:ci_build, :success, :trace_live) }
......@@ -818,32 +864,6 @@ RSpec.shared_examples 'trace with enabled live trace feature' do
.to eq(described_class.hexdigest(build.job_artifacts_trace.file.path))
expect(build.job_artifacts_trace.file_sha256).to eq(src_checksum)
end
context 'gitlab_ci_archived_trace_consistent_reads feature flag enabled' do
before do
stub_feature_flags(gitlab_ci_archived_trace_consistent_reads: build.project)
end
it 'calls ::Gitlab::Database::LoadBalancing::Sticking.stick' do
expect(::Gitlab::Database::LoadBalancing::Sticking).to receive(:stick)
.with(described_class::LOAD_BALANCING_STICKING_NAMESPACE, build.id)
.and_call_original
subject
end
end
context 'gitlab_ci_archived_trace_consistent_reads feature flag disabled' do
before do
stub_feature_flags(gitlab_ci_archived_trace_consistent_reads: false)
end
it 'does not call ::Gitlab::Database::LoadBalancing::Sticking.stick' do
expect(::Gitlab::Database::LoadBalancing::Sticking).not_to receive(:stick)
subject
end
end
end
shared_examples 'source trace in ChunkedIO stays intact' do |error:|
......
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