Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/bulk_imports/stuck_import_worker_spec.rb')
-rw-r--r--spec/workers/bulk_imports/stuck_import_worker_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/bulk_imports/stuck_import_worker_spec.rb b/spec/workers/bulk_imports/stuck_import_worker_spec.rb
new file mode 100644
index 00000000000..7dfb6532c07
--- /dev/null
+++ b/spec/workers/bulk_imports/stuck_import_worker_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BulkImports::StuckImportWorker do
+ let_it_be(:created_bulk_import) { create(:bulk_import, :created) }
+ let_it_be(:started_bulk_import) { create(:bulk_import, :started) }
+ let_it_be(:stale_created_bulk_import) { create(:bulk_import, :created, created_at: 3.days.ago) }
+ let_it_be(:stale_started_bulk_import) { create(:bulk_import, :started, created_at: 3.days.ago) }
+ let_it_be(:stale_created_bulk_import_entity) { create(:bulk_import_entity, :created, created_at: 3.days.ago) }
+ let_it_be(:stale_started_bulk_import_entity) { create(:bulk_import_entity, :started, created_at: 3.days.ago) }
+ let_it_be(:started_bulk_import_tracker) { create(:bulk_import_tracker, :started, entity: stale_started_bulk_import_entity) }
+
+ subject { described_class.new.perform }
+
+ describe 'perform' do
+ it 'updates the status of bulk imports to timeout' do
+ expect { subject }.to change { stale_created_bulk_import.reload.status_name }.from(:created).to(:timeout)
+ .and change { stale_started_bulk_import.reload.status_name }.from(:started).to(:timeout)
+ end
+
+ it 'updates the status of bulk import entities to timeout' do
+ expect { subject }.to change { stale_created_bulk_import_entity.reload.status_name }.from(:created).to(:timeout)
+ .and change { stale_started_bulk_import_entity.reload.status_name }.from(:started).to(:timeout)
+ end
+
+ it 'updates the status of stale entities trackers to timeout' do
+ expect { subject }.to change { started_bulk_import_tracker.reload.status_name }.from(:started).to(:timeout)
+ end
+
+ it 'does not update the status of non-stale records' do
+ expect { subject }.to not_change { created_bulk_import.reload.status }
+ .and not_change { started_bulk_import.reload.status }
+ end
+ end
+end