summaryrefslogtreecommitdiff
path: root/spec/models/ci/build_spec.rb
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-10-31 15:27:39 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-10-31 15:27:51 +0100
commit8f8a89f98edc4cb901f4107cbf38288576849d9e (patch)
tree01fd75d067c8f43bfee7a0a80b63cf2814971bf3 /spec/models/ci/build_spec.rb
parent94923328fdf2904e5a31ad8b9c40adcf15428bb2 (diff)
downloadgitlab-ce-8f8a89f98edc4cb901f4107cbf38288576849d9e.tar.gz
Implement POC config based parallelization
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r--spec/models/ci/build_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index a046541031e..41c3c37a7f2 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1880,6 +1880,7 @@ describe Ci::Build do
{ 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_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_BEFORE_SHA', value: build.before_sha, public: true },
{ key: 'CI_BUILD_REF_NAME', value: build.ref, public: true },
@@ -2341,6 +2342,28 @@ describe Ci::Build do
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
context 'when variables hierarchy is stubbed' do
let(:build_pre_var) { { key: 'build', value: 'value', public: true } }
@@ -2447,6 +2470,31 @@ describe Ci::Build do
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
describe '#scoped_variables' do