Commit b94ab577 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Rescue just the report download part

parent 790ea416
......@@ -281,7 +281,7 @@ module QA
end
def knapsack?
running_in_ci? && ENV['CI_NODE_TOTAL'].to_i > 1 && ENV['NO_KNAPSACK'] != "true"
ENV['CI_NODE_TOTAL'].to_i > 1 && ENV['NO_KNAPSACK'] != "true"
end
def ldap_username
......
......@@ -25,11 +25,6 @@ module QA
Knapsack.logger = QA::Runtime::Logger.logger
download_report
rescue StandardError => e
logger.warn("Failed to download latest knapsack report: #{e}")
logger.warn("Falling back to 'knapsack/master_report.json'")
ENV["KNAPSACK_REPORT_PATH"] = "knapsack/master_report.json"
end
# Download knapsack report from gcs bucket
......@@ -39,6 +34,11 @@ module QA
logger.debug("Downloading latest knapsack report for '#{report_name}' to '#{report_path}'")
file = client.get_object(BUCKET, report_file)
File.write(report_path, file[:body])
rescue StandardError => e
logger.warn("Failed to fetch latest knapsack report: #{e}")
logger.warn("Falling back to 'knapsack/master_report.json'")
ENV["KNAPSACK_REPORT_PATH"] = "knapsack/master_report.json"
end
# Rename and move new regenerated report to a separate folder used to indicate report name
......
......@@ -170,13 +170,10 @@ RSpec.describe QA::Runtime::Env do
describe '.knapsack?' do
before do
stub_env('CI', 'true')
stub_env('CI_NODE_TOTAL', '2')
end
it 'returns true if running in parallel CI run' do
stub_env('KNAPSACK_GENERATE_REPORT', 'true')
expect(described_class.knapsack?).to be_truthy
end
......@@ -185,15 +182,14 @@ RSpec.describe QA::Runtime::Env do
expect(described_class.knapsack?).to be_falsey
end
it 'returns false if not running in parallel job' do
it 'returns false if not running in a parallel job' do
stub_env('CI_NODE_TOTAL', '1')
expect(described_class.knapsack?).to be_falsey
end
it 'returns false if not running in ci' do
stub_env('CI', nil)
stub_env('CI_SERVER', nil)
stub_env('CI_NODE_TOTAL', nil)
expect(described_class.knapsack?).to be_falsey
end
......
......@@ -2,7 +2,7 @@
RSpec.describe QA::Scenario::Test::Integration::Github do
describe '#perform' do
let(:env) { spy('Runtime::Env') }
let(:env) { spy('Runtime::Env', knapsack?: false) }
before do
stub_const('QA::Runtime::Env', env)
......
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