diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 00:15:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 00:15:15 +0300 |
commit | ab37c8f6370868a8316992745589167517d422b7 (patch) | |
tree | 58bdce1e126d189d874b50a0dbc3bbd3bfed064a /spec/workers | |
parent | 4534d890f1e1d198804e9e2ff0da76e2308ebe23 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/bulk_imports/pipeline_worker_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/bulk_imports/stuck_import_worker_spec.rb | 43 |
2 files changed, 40 insertions, 5 deletions
diff --git a/spec/workers/bulk_imports/pipeline_worker_spec.rb b/spec/workers/bulk_imports/pipeline_worker_spec.rb index 39f4d6c4f6d..09f76169a12 100644 --- a/spec/workers/bulk_imports/pipeline_worker_spec.rb +++ b/spec/workers/bulk_imports/pipeline_worker_spec.rb @@ -344,7 +344,7 @@ RSpec.describe BulkImports::PipelineWorker, feature_category: :importers do end end - it 'reenqueues the worker' do + it 're_enqueues the worker' do expect_any_instance_of(BulkImports::Tracker) do |tracker| expect(tracker).to receive(:retry).and_call_original end diff --git a/spec/workers/bulk_imports/stuck_import_worker_spec.rb b/spec/workers/bulk_imports/stuck_import_worker_spec.rb index eadf3864190..4bcc72326c7 100644 --- a/spec/workers/bulk_imports/stuck_import_worker_spec.rb +++ b/spec/workers/bulk_imports/stuck_import_worker_spec.rb @@ -5,10 +5,21 @@ require 'spec_helper' RSpec.describe BulkImports::StuckImportWorker, feature_category: :importers 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(:stale_created_bulk_import) do + create(:bulk_import, :created, updated_at: 3.days.ago) + end + + let_it_be(:stale_started_bulk_import) do + create(:bulk_import, :started, updated_at: 3.days.ago) + end + + let_it_be(:stale_created_bulk_import_entity) do + create(:bulk_import_entity, :created, updated_at: 3.days.ago) + end + + let_it_be(:stale_started_bulk_import_entity) do + create(:bulk_import_entity, :started, updated_at: 3.days.ago) + end let_it_be(:started_bulk_import_tracker) do create(:bulk_import_tracker, :started, entity: stale_started_bulk_import_entity) @@ -61,5 +72,29 @@ RSpec.describe BulkImports::StuckImportWorker, feature_category: :importers do expect { subject }.to not_change { created_bulk_import.reload.status } .and not_change { started_bulk_import.reload.status } end + + context 'when bulk import has been updated recently', :clean_gitlab_redis_shared_state do + before do + stale_created_bulk_import.update!(updated_at: 2.minutes.ago) + stale_started_bulk_import.update!(updated_at: 2.minutes.ago) + end + + it 'does not update the status of the import' do + expect { subject }.to not_change { stale_created_bulk_import.reload.status_name } + .and not_change { stale_started_bulk_import.reload.status_name } + end + end + + context 'when bulk import entity has been updated recently', :clean_gitlab_redis_shared_state do + before do + stale_created_bulk_import_entity.update!(updated_at: 2.minutes.ago) + stale_started_bulk_import_entity.update!(updated_at: 2.minutes.ago) + end + + it 'does not update the status of the entity' do + expect { subject }.to not_change { stale_created_bulk_import_entity.reload.status_name } + .and not_change { stale_started_bulk_import_entity.reload.status_name } + end + end end end |