Commit bc6c2a5c authored by Mike Kozono's avatar Mike Kozono

Geo: Alternate redownload and normal SSF sync attempts

For retries of failed syncs.

Changelog: changed
EE: true
parent 37faf155
......@@ -245,7 +245,9 @@ module Geo
def should_be_redownloaded?
return true if registry.force_to_redownload
registry.retry_count > RETRIES_BEFORE_REDOWNLOAD
retries = registry.retry_count
retries.present? && retries > RETRIES_BEFORE_REDOWNLOAD && retries.odd?
end
def reschedule_sync
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
include ::EE::GeoHelpers
include ExclusiveLeaseHelpers
using RSpec::Parameterized::TableSyntax
let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) }
......@@ -327,4 +328,30 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
end
end
end
describe '#should_be_redownloaded?' do
where(:force_to_redownload, :retry_count, :expected) do
false | nil | false
false | 0 | false
false | 1 | false
false | 10 | false
false | 11 | true
false | 12 | false
false | 13 | true
false | 14 | false
false | 101 | true
false | 102 | false
true | nil | true
true | 0 | true
true | 11 | true
end
with_them do
it "returns the expected boolean" do
registry.update!(retry_count: retry_count, force_to_redownload: force_to_redownload)
expect(subject.send(:should_be_redownloaded?)).to eq(expected)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment