Commit 4937e12e authored by Douwe Maan's avatar Douwe Maan

Ensure mirror can transition out of the started state when last_update_started_at is nil

parent 6c9cf0c0
......@@ -39,6 +39,8 @@ class ProjectMirrorData < ActiveRecord::Base
private
def base_delay(timestamp)
return 0 unless self.last_update_started_at
duration = timestamp - self.last_update_started_at
(BACKOFF_PERIOD + rand(JITTER)) * duration.seconds
......
---
title: Ensure mirror can transition out of the started state when last_update_started_at
is nil
merge_request:
author:
type: fixed
......@@ -76,6 +76,12 @@ describe ProjectMirrorData, type: :model do
allow(Gitlab::Mirror).to receive(:rand).and_return(mirror_jitter)
end
context 'when last_update_started_at is nil' do
it 'applies transition successfully' do
expect_next_execution_timestamp(mirror_data, timestamp + 15.minutes + mirror_jitter)
end
end
context 'when base delay is lower than mirror min_delay' do
before do
mirror_data.last_update_started_at = timestamp - 1.second
......
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