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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-05 00:09:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-05 00:09:50 +0300
commit1dbd5e4a8082d0ca86a8b2dad73b34523be137db (patch)
treef67f6dd95bc0faf603de3894bb5e433ce64972db /spec/workers
parent43fb9e32f29817020267b13616c6670512fc5eab (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb39
-rw-r--r--spec/workers/concerns/worker_attributes_spec.rb4
2 files changed, 41 insertions, 2 deletions
diff --git a/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb
index 70821f3a833..60a34fdab53 100644
--- a/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb
+++ b/spec/workers/ci/pipeline_success_unlock_artifacts_worker_spec.rb
@@ -69,4 +69,43 @@ RSpec.describe Ci::PipelineSuccessUnlockArtifactsWorker, feature_category: :buil
end
end
end
+
+ describe '.database_health_check_attrs' do
+ it 'defines expected db health check attrs' do
+ expect(described_class.database_health_check_attrs).to eq(
+ gitlab_schema: :gitlab_ci,
+ delay_by: described_class::DEFAULT_DEFER_DELAY,
+ tables: [:ci_job_artifacts]
+ )
+ end
+ end
+
+ context 'with stop signal from database health check' do
+ let(:pipeline_id) { non_existing_record_id }
+ let(:health_signal_attrs) { described_class.database_health_check_attrs }
+
+ around do |example|
+ with_sidekiq_server_middleware do |chain|
+ chain.add Gitlab::SidekiqMiddleware::SkipJobs
+ Sidekiq::Testing.inline! { example.run }
+ end
+ end
+
+ before do
+ stub_feature_flags("drop_sidekiq_jobs_#{described_class.name}": false)
+
+ stop_signal = instance_double("Gitlab::Database::HealthStatus::Signals::Stop", stop?: true)
+ allow(Gitlab::Database::HealthStatus).to receive(:evaluate).and_return([stop_signal])
+ end
+
+ it 'defers the job by set time' do
+ expect_next_instance_of(described_class) do |worker|
+ expect(worker).not_to receive(:perform).with(pipeline_id)
+ end
+
+ expect(described_class).to receive(:perform_in).with(health_signal_attrs[:delay_by], pipeline_id)
+
+ described_class.perform_async(pipeline_id)
+ end
+ end
end
diff --git a/spec/workers/concerns/worker_attributes_spec.rb b/spec/workers/concerns/worker_attributes_spec.rb
index 959cb62c6fb..90c07a9c959 100644
--- a/spec/workers/concerns/worker_attributes_spec.rb
+++ b/spec/workers/concerns/worker_attributes_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe WorkerAttributes, feature_category: :shared do
:worker_has_external_dependencies? | :worker_has_external_dependencies! | false | [] | true
:idempotent? | :idempotent! | false | [] | true
:big_payload? | :big_payload! | false | [] | true
- :database_health_check_attrs | :defer_on_database_health_signal | nil | [:gitlab_main, 1.minute, [:users]] | { gitlab_schema: :gitlab_main, delay_by: 1.minute, tables: [:users] }
+ :database_health_check_attrs | :defer_on_database_health_signal | nil | [:gitlab_main, [:users], 1.minute] | { gitlab_schema: :gitlab_main, tables: [:users], delay_by: 1.minute }
end
# rubocop: enable Layout/LineLength
@@ -148,7 +148,7 @@ RSpec.describe WorkerAttributes, feature_category: :shared do
context 'when defer_on_database_health_signal is set' do
before do
- worker.defer_on_database_health_signal(:gitlab_main, 1.minute, [:users])
+ worker.defer_on_database_health_signal(:gitlab_main, [:users], 1.minute)
end
it { is_expected.to be(true) }