Commit a0869a7e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make build trace correctness validation sticky

This commit aligns build trace correctness validation with live traces
feature flag rollout. We will only validate build traces that consist of
build chunks. This is especially important when incrementally rolling
out the new feature.
parent 4553557a
......@@ -70,7 +70,9 @@ module Ci
end
def validate_build_trace!
if chunks_persisted?
return unless has_chunks?
unless live_chunks_pending?
metrics.increment_trace_operation(operation: :finalized)
end
......@@ -110,8 +112,8 @@ module Ci
build.trace_chunks.live.any?
end
def chunks_persisted?
build.trace_chunks.any? && !live_chunks_pending?
def has_chunks?
build.trace_chunks.any?
end
def pending_state_outdated?
......
......@@ -83,6 +83,23 @@ RSpec.describe Ci::UpdateBuildStateService do
{ checksum: 'crc32:12345678', state: 'failed', failure_reason: 'script_failure' }
end
context 'when build does not have associated trace chunks' do
it 'updates a build status' do
result = subject.execute
expect(build).to be_failed
expect(result.status).to eq 200
end
it 'does not increment invalid trace metric' do
execute_with_stubbed_metrics!
expect(metrics)
.not_to have_received(:increment_trace_operation)
.with(operation: :invalid)
end
end
context 'when build trace has been migrated' do
before do
create(:ci_build_trace_chunk, :persisted, build: build, initial_data: 'abcd')
......
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