fix(server): Respect manual scheduling policy (#2464)

* fix(server): respect manual scheduling policy

* Added test
This commit is contained in:
Ricardo Pescuma Domenecci
2022-09-30 12:20:43 -03:00
committed by GitHub
parent bd49fa806a
commit 11ce91dd5a
2 changed files with 15 additions and 0 deletions

View File

@@ -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 (

View File

@@ -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 {