Commit b94ab577 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Rescue just the report download part

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