Commit 94923328 authored by Matija Čupić's avatar Matija Čupić

Revert Seed based parallelization implementation

Revert "Add Build seed specs"

This reverts commit 03bc722e.

Revert "Add build specs"

This reverts commit c2d49565.

Revert "Refactor parallelization implementation"

This reverts commit 72430483.

Revert "Implement POC for job parallelization"

This reverts commit 44b740f9.
parent 3cbea3b9
...@@ -801,16 +801,10 @@ module Ci ...@@ -801,16 +801,10 @@ module Ci
variables.append(key: "CI_COMMIT_TAG", value: ref) if tag? variables.append(key: "CI_COMMIT_TAG", value: ref) if tag?
variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request
variables.append(key: "CI_JOB_MANUAL", value: 'true') if action? variables.append(key: "CI_JOB_MANUAL", value: 'true') if action?
variables.append(key: "CI_NODE_INDEX", value: node_index.to_s) if self.options&.include?(:parallel)
variables.append(key: "CI_NODE_TOTAL", value: (self.options&.dig(:parallel) || 1).to_s)
variables.concat(legacy_variables) variables.concat(legacy_variables)
end end
end end
def node_index
name.match(%r{(\d+)/\d+$}).captures[0]
end
def gitlab_version_info def gitlab_version_info
@gitlab_version_info ||= Gitlab::VersionInfo.parse(Gitlab::VERSION) @gitlab_version_info ||= Gitlab::VersionInfo.parse(Gitlab::VERSION)
end end
......
...@@ -24,16 +24,6 @@ module Gitlab ...@@ -24,16 +24,6 @@ module Gitlab
end end
end end
def parallel?
!!@attributes.dig(:options, :parallel)
end
def parallelize_build
total = @attributes[:options][:parallel]
Array.new(total) { ::Ci::Build.new(attributes) }
.each_with_index { |build, idx| build.name = "#{build.name} #{idx + 1}/#{total}" }
end
def attributes def attributes
@attributes.merge( @attributes.merge(
pipeline: @pipeline, pipeline: @pipeline,
...@@ -48,7 +38,7 @@ module Gitlab ...@@ -48,7 +38,7 @@ module Gitlab
def to_resource def to_resource
strong_memoize(:resource) do strong_memoize(:resource) do
parallel? ? parallelize_build : ::Ci::Build.new(attributes) ::Ci::Build.new(attributes)
end end
end end
end end
......
...@@ -50,7 +50,6 @@ module Gitlab ...@@ -50,7 +50,6 @@ module Gitlab
after_script: job[:after_script], after_script: job[:after_script],
environment: job[:environment], environment: job[:environment],
retry: job[:retry], retry: job[:retry],
parallel: job[:parallel],
start_in: job[:start_in] start_in: job[:start_in]
}.compact } }.compact }
end end
......
...@@ -13,46 +13,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do ...@@ -13,46 +13,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
described_class.new(pipeline, attributes) described_class.new(pipeline, attributes)
end end
describe '#parallel?' do
context 'when build is not parallelized' do
it 'should be false' do
expect(subject.parallel?).to eq(false)
end
end
context 'when build is parallelized' do
before do
attributes[:options] = { parallel: 5 }
end
it 'should be true' do
expect(subject.parallel?).to eq(true)
end
end
end
describe '#parallelize_build' do
let(:total) { 5 }
before do
attributes[:options] = { parallel: total }
end
it 'returns duplicated builds' do
builds = subject.parallelize_build
expect(builds.size).to eq(total)
end
it 'returns builds with indexed names' do
builds = subject.parallelize_build
base_name = builds.first.name.split(' ')[0]
names = builds.map(&:name)
expect(names).to all(match(%r{^#{base_name} \d+/\d+$}))
end
end
describe '#attributes' do describe '#attributes' do
it 'returns hash attributes of a build' do it 'returns hash attributes of a build' do
expect(subject.attributes).to be_a Hash expect(subject.attributes).to be_a Hash
...@@ -62,23 +22,10 @@ describe Gitlab::Ci::Pipeline::Seed::Build do ...@@ -62,23 +22,10 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end end
describe '#to_resource' do describe '#to_resource' do
context 'when build is not parallelized' do
it 'returns a valid build resource' do it 'returns a valid build resource' do
expect(subject.to_resource).to be_a(::Ci::Build) expect(subject.to_resource).to be_a(::Ci::Build)
expect(subject.to_resource).to be_valid expect(subject.to_resource).to be_valid
end end
end
context 'when build is parallelized' do
before do
attributes[:options] = { parallel: 5 }
end
it 'returns a group of valid build resources' do
expect(subject.to_resource).to all(be_a(::Ci::Build))
expect(subject.to_resource).to all(be_valid)
end
end
it 'memoizes a resource object' do it 'memoizes a resource object' do
build = subject.to_resource build = subject.to_resource
......
...@@ -1880,7 +1880,6 @@ describe Ci::Build do ...@@ -1880,7 +1880,6 @@ describe Ci::Build do
{ key: 'CI_COMMIT_BEFORE_SHA', value: build.before_sha, public: true }, { key: 'CI_COMMIT_BEFORE_SHA', value: build.before_sha, public: true },
{ key: 'CI_COMMIT_REF_NAME', value: build.ref, public: true }, { key: 'CI_COMMIT_REF_NAME', value: build.ref, public: true },
{ key: 'CI_COMMIT_REF_SLUG', value: build.ref_slug, public: true }, { key: 'CI_COMMIT_REF_SLUG', value: build.ref_slug, public: true },
{ key: 'CI_NODE_TOTAL', value: '1', public: true },
{ key: 'CI_BUILD_REF', value: build.sha, public: true }, { key: 'CI_BUILD_REF', value: build.sha, public: true },
{ key: 'CI_BUILD_BEFORE_SHA', value: build.before_sha, public: true }, { key: 'CI_BUILD_BEFORE_SHA', value: build.before_sha, public: true },
{ key: 'CI_BUILD_REF_NAME', value: build.ref, public: true }, { key: 'CI_BUILD_REF_NAME', value: build.ref, public: true },
...@@ -2342,28 +2341,6 @@ describe Ci::Build do ...@@ -2342,28 +2341,6 @@ describe Ci::Build do
end end
end end
context 'when build is parallelized' do
let(:total) { 5 }
let(:index) { 3 }
before do
build.options[:parallel] = total
build.name = "#{build.name} #{index}/#{total}"
end
it 'includes CI_NODE_INDEX' do
is_expected.to include(
{ key: 'CI_NODE_INDEX', value: index.to_s, public: true }
)
end
it 'includes correct CI_NODE_TOTAL' do
is_expected.to include(
{ key: 'CI_NODE_TOTAL', value: total.to_s, public: true }
)
end
end
describe 'variables ordering' do describe 'variables ordering' do
context 'when variables hierarchy is stubbed' do context 'when variables hierarchy is stubbed' do
let(:build_pre_var) { { key: 'build', value: 'value', public: true } } let(:build_pre_var) { { key: 'build', value: 'value', public: true } }
...@@ -2470,31 +2447,6 @@ describe Ci::Build do ...@@ -2470,31 +2447,6 @@ describe Ci::Build do
end end
end end
end end
describe '#node_index' do
subject { build.send(:node_index) }
let(:index) { 4 }
context 'when build has only one index' do
before do
build.name = "#{build.name} #{index}/5"
end
it 'returns the index' do
expect(subject).to eq(index.to_s)
end
end
context 'when build has more than one one index' do
before do
build.name = "test_build 1/3 #{index}/5"
end
it 'returns the last index' do
expect(subject).to eq(index.to_s)
end
end
end
end end
describe '#scoped_variables' do describe '#scoped_variables' do
......
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