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-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb')
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
index a46275d90b6..c22e7a1240f 100644
--- a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb
@@ -226,6 +226,14 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi
expect(redis_ttl(cookie_key)).to be_within(1).of(expected_ttl)
end
+ it 'does not try to set an invalid ttl at the end of expiry' do
+ with_redis { |r| r.expire(cookie_key, 1) }
+
+ sleep 0.5 # sleep 500ms to redis would round the remaining ttl to 0
+
+ expect { subject }.not_to raise_error
+ end
+
context 'and low offsets' do
let(:existing_cookie) do
{
@@ -241,6 +249,24 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi
expect(cookie['offsets']).to eq({ 'c1' => 1, 'c2' => 2, 'c3' => 3 })
end
end
+
+ context 'when a WAL location is nil with existing offsets' do
+ let(:existing_cookie) do
+ {
+ 'offsets' => { 'main' => 8, 'ci' => 5 },
+ 'wal_locations' => { 'main' => 'loc1old', 'ci' => 'loc2old' }
+ }
+ end
+
+ let(:argv) { ['main', 9, 'loc1', 'ci', nil, 'loc2'] }
+
+ it 'only updates the main connection' do
+ subject
+
+ expect(cookie['wal_locations']).to eq({ 'main' => 'loc1', 'ci' => 'loc2old' })
+ expect(cookie['offsets']).to eq({ 'main' => 9, 'ci' => 5 })
+ end
+ end
end
end