Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 4f681cb

Browse files
Extended sleep duration by 100 ms to allow to complete post-schedule activities
1 parent 0ac530a commit 4f681cb

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

scheduler/distributed_task_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ func TestDistributedSubscriptions(t *testing.T) {
324324
})
325325
Convey("Task should be ended after an interval", func() {
326326
// wait for the end of the task
327-
// we are ok at this precision with being within 10% over the interval (100ms)
328-
time.Sleep(interval * 110 / 100)
327+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
328+
time.Sleep(interval + time.Millisecond*100)
329329
So(t.State(), ShouldEqual, core.TaskEnded)
330330

331331
Convey("So all dependencies should have been usubscribed", func() {
@@ -364,7 +364,9 @@ func TestDistributedSubscriptions(t *testing.T) {
364364
// wait for the end of determined window
365365
time.Sleep(startWait + windowSize)
366366
// wait an interval to be sure that the task state has been updated
367-
time.Sleep(interval)
367+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
368+
time.Sleep(interval + time.Millisecond*100)
369+
368370
// check if the task has ended
369371
So(t.State(), ShouldEqual, core.TaskEnded)
370372

scheduler/scheduler_medium_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ func TestCreateTask(t *testing.T) {
263263
// wait for the end of determined window
264264
time.Sleep(startWait + windowSize)
265265
// wait an interval to be sure that the task state has been updated
266-
time.Sleep(interval)
266+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
267+
time.Sleep(interval + time.Millisecond*100)
267268
// check if the task is ended
268269
So(tsk.State(), ShouldEqual, core.TaskEnded)
269270
})
@@ -282,8 +283,8 @@ func TestCreateTask(t *testing.T) {
282283

283284
Convey("the task should be ended after reaching the end of window", func() {
284285
// wait an interval to be sure that the task state has been updated
285-
// we are ok at this precision with being within 10% over the interval (10ms)
286-
time.Sleep(interval * 110 / 100)
286+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
287+
time.Sleep(interval + time.Millisecond*100)
287288
// check if the task is ended
288289
So(tsk.State(), ShouldEqual, core.TaskEnded)
289290
})
@@ -302,8 +303,8 @@ func TestCreateTask(t *testing.T) {
302303
// wait for the end of determined window
303304
time.Sleep(startWait)
304305
// wait an interval to be sure that the task state has been updated
305-
// we are ok at this precision with being within 10% over the interval (10ms)
306-
time.Sleep(interval * 110 / 100)
306+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
307+
time.Sleep(interval + time.Millisecond*100)
307308
// check if the task is ended
308309
So(tsk.State(), ShouldEqual, core.TaskEnded)
309310
})
@@ -414,8 +415,8 @@ func TestStopTask(t *testing.T) {
414415
// wait for the end of determined window
415416
time.Sleep(startWait + windowSize)
416417
// wait an interval to be sure that the task state has been updated
417-
time.Sleep(interval)
418-
418+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
419+
time.Sleep(interval + time.Millisecond*100)
419420
// check if the task is ended
420421
So(tsk.State(), ShouldEqual, core.TaskEnded)
421422

@@ -500,7 +501,8 @@ func TestStartTask(t *testing.T) {
500501
// wait for the end of determined window
501502
time.Sleep(startWait + windowSize)
502503
// wait an interval to be sure that the task state has been updated
503-
time.Sleep(interval)
504+
// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
505+
time.Sleep(interval + time.Millisecond*100)
504506

505507
// check if the task is ended
506508
So(tsk.State(), ShouldEqual, core.TaskEnded)
@@ -596,7 +598,8 @@ func TestEnableTask(t *testing.T) {
596598
// wait for the end of determined window
597599
time.Sleep(startWait + windowSize)
598600
// wait an interval to be sure that the task state has been updated
599-
time.Sleep(interval)
601+
/// we are ok to extend sleeping by 100ms to allow to complete post-schedule activities
602+
time.Sleep(interval + time.Millisecond*100)
600603

601604
// check if the task is ended
602605
So(tsk.State(), ShouldEqual, core.TaskEnded)

0 commit comments

Comments
 (0)