Commit 74e72dfc authored by Andrejs Cunskis's avatar Andrejs Cunskis

Merge branch 'acunskis-fix-knapsack-check' into 'master'

E2E: Do not bind knapsack unless parallel run

See merge request gitlab-org/gitlab!76736
parents 8fcd20a6 674cf873
......@@ -281,6 +281,8 @@ module QA
end
def knapsack?
return false unless ENV['CI_NODE_TOTAL'].to_i > 1
!!(ENV['KNAPSACK_GENERATE_REPORT'] || ENV['KNAPSACK_REPORT_PATH'] || ENV['KNAPSACK_TEST_FILE_PATTERN'])
end
......
......@@ -169,6 +169,10 @@ RSpec.describe QA::Runtime::Env do
end
describe '.knapsack?' do
before do
stub_env('CI_NODE_TOTAL', '2')
end
it 'returns true if KNAPSACK_GENERATE_REPORT is defined' do
stub_env('KNAPSACK_GENERATE_REPORT', 'true')
......@@ -190,28 +194,11 @@ RSpec.describe QA::Runtime::Env do
it 'returns false if neither KNAPSACK_GENERATE_REPORT nor KNAPSACK_REPORT_PATH nor KNAPSACK_TEST_FILE_PATTERN are defined' do
expect(described_class.knapsack?).to be_falsey
end
end
describe '.knapsack?' do
it 'returns true if KNAPSACK_GENERATE_REPORT is defined' do
it 'returns false if not running in parallel job' do
stub_env('CI_NODE_TOTAL', '1')
stub_env('KNAPSACK_GENERATE_REPORT', 'true')
expect(described_class.knapsack?).to be_truthy
end
it 'returns true if KNAPSACK_REPORT_PATH is defined' do
stub_env('KNAPSACK_REPORT_PATH', '/a/path')
expect(described_class.knapsack?).to be_truthy
end
it 'returns true if KNAPSACK_TEST_FILE_PATTERN is defined' do
stub_env('KNAPSACK_TEST_FILE_PATTERN', '/a/**/pattern')
expect(described_class.knapsack?).to be_truthy
end
it 'returns false if neither KNAPSACK_GENERATE_REPORT nor KNAPSACK_REPORT_PATH nor KNAPSACK_TEST_FILE_PATTERN are defined' do
expect(described_class.knapsack?).to be_falsey
end
end
......
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