From 11ce91dd5ac08e6e93fa2aa11bcd2913f87eca68 Mon Sep 17 00:00:00 2001 From: Ricardo Pescuma Domenecci Date: Fri, 30 Sep 2022 12:20:43 -0300 Subject: [PATCH] fix(server): Respect manual scheduling policy (#2464) * fix(server): respect manual scheduling policy * Added test --- snapshot/policy/scheduling_policy.go | 4 ++++ snapshot/policy/scheduling_policy_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/snapshot/policy/scheduling_policy.go b/snapshot/policy/scheduling_policy.go index 830cc7277..ddbb63fbb 100644 --- a/snapshot/policy/scheduling_policy.go +++ b/snapshot/policy/scheduling_policy.go @@ -81,6 +81,10 @@ func (p *SchedulingPolicy) SetInterval(d time.Duration) { // NextSnapshotTime computes next snapshot time given previous // snapshot time and current wall clock time. func (p *SchedulingPolicy) NextSnapshotTime(previousSnapshotTime, now time.Time) (time.Time, bool) { + if p.Manual { + return time.Time{}, false + } + const oneDay = 24 * time.Hour var ( diff --git a/snapshot/policy/scheduling_policy_test.go b/snapshot/policy/scheduling_policy_test.go index c3ec33390..dbbf78090 100644 --- a/snapshot/policy/scheduling_policy_test.go +++ b/snapshot/policy/scheduling_policy_test.go @@ -162,6 +162,17 @@ func TestNextSnapshotTime(t *testing.T) { wantTime: time.Date(2020, time.January, 1, 19, 0, 0, 0, time.Local), wantOK: true, }, + { + pol: policy.SchedulingPolicy{ + IntervalSeconds: 43200, + TimesOfDay: []policy.TimeOfDay{{19, 0}, {20, 0}}, + Manual: true, + }, + previousSnapshotTime: time.Date(2020, time.January, 1, 19, 0, 0, 0, time.Local), + now: time.Date(2020, time.January, 1, 10, 0, 0, 0, time.Local), + wantTime: time.Time{}, + wantOK: false, + }, } for i, tc := range cases {