chore: Add delay before running dataimport job (#8039)
- We have observed some failures for data import jobs in the cloud due to race conditions with job executions and active storage file uploading. This PR adds delays and retries to accommodate that.
This commit is contained in:
@@ -13,6 +13,20 @@ RSpec.describe DataImportJob do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'retrying the job' do
|
||||
context 'when ActiveStorage::FileNotFoundError is raised' do
|
||||
before do
|
||||
allow(data_import.import_file).to receive(:download).and_raise(ActiveStorage::FileNotFoundError)
|
||||
end
|
||||
|
||||
it 'retries the job' do
|
||||
expect do
|
||||
described_class.perform_now(data_import)
|
||||
end.to have_enqueued_job(described_class).at_least(1).times
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'importing data' do
|
||||
context 'when the data is valid' do
|
||||
it 'imports data into the account' do
|
||||
|
||||
@@ -10,4 +10,14 @@ RSpec.describe DataImport do
|
||||
expect(build(:data_import, data_type: 'Xyc').valid?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'callbacks' do
|
||||
let(:data_import) { build(:data_import) }
|
||||
|
||||
it 'schedules a job after creation' do
|
||||
expect do
|
||||
data_import.save
|
||||
end.to have_enqueued_job(DataImportJob).with(data_import).on_queue('low')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user