diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2018-01-27 06:16:45 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2018-02-02 01:37:53 +0300 |
commit | a32cac06ab5bbaa124246d0c5c85e544713f94b3 (patch) | |
tree | 9360c79494b8f1779342053d82ffa79a65ef6721 /spec/workers | |
parent | b9787cc632b803e776efcaf8ddf517d98334f3ee (diff) |
Retry Contact messages 20 time (about two weeks)
closes #7705
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/send_base_spec.rb | 14 | ||||
-rw-r--r-- | spec/workers/send_private_spec.rb | 17 |
2 files changed, 24 insertions, 7 deletions
diff --git a/spec/workers/send_base_spec.rb b/spec/workers/send_base_spec.rb index c7961451b..7a3b77a98 100644 --- a/spec/workers/send_base_spec.rb +++ b/spec/workers/send_base_spec.rb @@ -8,13 +8,13 @@ describe Workers::SendBase do end it "increases the interval for each retry" do - expect(Workers::SendBase.new.send(:seconds_to_delay, 2)).to be >= 625 - expect(Workers::SendBase.new.send(:seconds_to_delay, 3)).to be >= 1_296 - expect(Workers::SendBase.new.send(:seconds_to_delay, 4)).to be >= 2_401 - expect(Workers::SendBase.new.send(:seconds_to_delay, 5)).to be >= 4_096 - expect(Workers::SendBase.new.send(:seconds_to_delay, 6)).to be >= 6_561 - expect(Workers::SendBase.new.send(:seconds_to_delay, 7)).to be >= 10_000 - expect(Workers::SendBase.new.send(:seconds_to_delay, 8)).to be >= 14_641 + (2..19).each do |count| + expect(Workers::SendBase.new.send(:seconds_to_delay, count)).to be >= ((count + 3)**4) + end + + # lets make some tests with explicit numbers to make sure the formula above works correctly + # and increases the delay with the expected result expect(Workers::SendBase.new.send(:seconds_to_delay, 9)).to be >= 20_736 + expect(Workers::SendBase.new.send(:seconds_to_delay, 19)).to be >= 234_256 end end diff --git a/spec/workers/send_private_spec.rb b/spec/workers/send_private_spec.rb index 622c1e93e..1817c5983 100644 --- a/spec/workers/send_private_spec.rb +++ b/spec/workers/send_private_spec.rb @@ -41,4 +41,21 @@ describe Workers::SendPrivate do Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 9) }.to raise_error Workers::SendBase::MaxRetriesReached end + + it "retries contact entities 20 times" do + contact = Fabricate(:contact_entity, author: sender_id, recipient: alice.diaspora_handle) + obj_str = contact.to_s + targets = {"https://example.org/receive/user/guid" => "<xml>post</xml>"} + expect(DiasporaFederation::Federation::Sender).to receive(:private).with( + sender_id, obj_str, targets + ).and_return(targets).twice + + expect(Workers::SendPrivate).to receive(:perform_in).with(a_kind_of(Numeric), sender_id, obj_str, targets, 19) + Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 18) + + expect(Workers::SendPrivate).not_to receive(:perform_in) + expect { + Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 19) + }.to raise_error Workers::SendBase::MaxRetriesReached + end end |