summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-02-06 01:52:46 +0900
committerShinya Maeda <shinya@gitlab.com>2018-02-06 15:50:08 +0900
commita2d79e1f2c8186fa69a91717b3d4e71a332d8bbf (patch)
tree4927baf9766d7edc4e8ab5d7a62af8686a965e34
parentd30e71b381b9cf33ed61b04c25c258c11942c79b (diff)
downloadgitlab-ce-feature/sm/artifacts-trace.tar.gz
Reorder async/sync tasks in BuildFinishedWorker to read traces efficientlyfeature/sm/artifacts-trace
-rw-r--r--app/workers/build_finished_worker.rb7
-rw-r--r--spec/workers/build_finished_worker_spec.rb16
2 files changed, 11 insertions, 12 deletions
diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb
index 2acf0d14ff5..b5ed8d607b3 100644
--- a/app/workers/build_finished_worker.rb
+++ b/app/workers/build_finished_worker.rb
@@ -6,8 +6,11 @@ class BuildFinishedWorker
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
- BuildTraceSectionsWorker.perform_async(build.id)
- BuildCoverageWorker.perform_async(build.id)
+ # We execute that in sync as this access the files in order to access local file, and reduce IO
+ 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)
CreateTraceArtifactWorker.perform_async(build.id)
end
diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb
index 0f46ad5bbea..c7ff8cf3b92 100644
--- a/spec/workers/build_finished_worker_spec.rb
+++ b/spec/workers/build_finished_worker_spec.rb
@@ -6,19 +6,15 @@ describe BuildFinishedWorker do
let!(:build) { create(:ci_build) }
it 'calculates coverage and calls hooks' do
- expect(BuildCoverageWorker)
+ expect(BuildTraceSectionsWorker)
.to receive(:new).ordered.and_call_original
- expect(BuildHooksWorker)
+ expect(BuildCoverageWorker)
.to receive(:new).ordered.and_call_original
- expect(BuildTraceSectionsWorker)
- .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)
+ expect_any_instance_of(BuildTraceSectionsWorker).to receive(:perform)
+ expect_any_instance_of(BuildCoverageWorker).to receive(:perform)
+ expect(BuildHooksWorker).to receive(:perform_async)
+ expect(CreateTraceArtifactWorker).to receive(:perform_async)
described_class.new.perform(build.id)
end