Reorder async/sync tasks in BuildFinishedWorker to read traces efficiently
This commit is contained in:
parent
d30e71b381
commit
a2d79e1f2c
|
@ -6,8 +6,11 @@ class BuildFinishedWorker
|
||||||
|
|
||||||
def perform(build_id)
|
def perform(build_id)
|
||||||
Ci::Build.find_by(id: build_id).try do |build|
|
Ci::Build.find_by(id: build_id).try do |build|
|
||||||
BuildTraceSectionsWorker.perform_async(build.id)
|
# We execute that in sync as this access the files in order to access local file, and reduce IO
|
||||||
BuildCoverageWorker.perform_async(build.id)
|
BuildTraceSectionsWorker.new.perform(build.id)
|
||||||
|
BuildCoverageWorker.new.perform(build.id)
|
||||||
|
|
||||||
|
# We execute that async as this are two indepentent operations that can be executed after TraceSections and Coverage
|
||||||
BuildHooksWorker.perform_async(build.id)
|
BuildHooksWorker.perform_async(build.id)
|
||||||
CreateTraceArtifactWorker.perform_async(build.id)
|
CreateTraceArtifactWorker.perform_async(build.id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,19 +6,15 @@ describe BuildFinishedWorker do
|
||||||
let!(:build) { create(:ci_build) }
|
let!(:build) { create(:ci_build) }
|
||||||
|
|
||||||
it 'calculates coverage and calls hooks' do
|
it 'calculates coverage and calls hooks' do
|
||||||
|
expect(BuildTraceSectionsWorker)
|
||||||
|
.to receive(:new).ordered.and_call_original
|
||||||
expect(BuildCoverageWorker)
|
expect(BuildCoverageWorker)
|
||||||
.to receive(:new).ordered.and_call_original
|
.to receive(:new).ordered.and_call_original
|
||||||
expect(BuildHooksWorker)
|
|
||||||
.to receive(:new).ordered.and_call_original
|
|
||||||
|
|
||||||
expect(BuildTraceSectionsWorker)
|
expect_any_instance_of(BuildTraceSectionsWorker).to receive(:perform)
|
||||||
.to receive(:perform_async)
|
expect_any_instance_of(BuildCoverageWorker).to receive(:perform)
|
||||||
expect(CreateTraceArtifactWorker)
|
expect(BuildHooksWorker).to receive(:perform_async)
|
||||||
.to receive(:perform_async)
|
expect(CreateTraceArtifactWorker).to receive(:perform_async)
|
||||||
expect_any_instance_of(BuildCoverageWorker)
|
|
||||||
.to receive(:perform)
|
|
||||||
expect_any_instance_of(BuildHooksWorker)
|
|
||||||
.to receive(:perform)
|
|
||||||
|
|
||||||
described_class.new.perform(build.id)
|
described_class.new.perform(build.id)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue