mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-14 13:32:43 +00:00
bug fix: jobs not being scheduled after timeout
This commit is contained in:
parent
d8963c9946
commit
b5d2a0ad89
@ -180,7 +180,6 @@ func (m *mirrorJob) Run(managerChan chan<- jobMessage, semaphore chan empty) err
|
|||||||
logger.Debug("syncing done")
|
logger.Debug("syncing done")
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
logger.Notice("provider timeout")
|
logger.Notice("provider timeout")
|
||||||
stopASAP = true
|
|
||||||
termErr = provider.Terminate()
|
termErr = provider.Terminate()
|
||||||
syncErr = fmt.Errorf("%s timeout after %v", m.Name(), timeout)
|
syncErr = fmt.Errorf("%s timeout after %v", m.Name(), timeout)
|
||||||
case <-kill:
|
case <-kill:
|
||||||
|
@ -335,7 +335,6 @@ echo $TUNASYNC_WORKING_DIR
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
Convey("When a job timed out", func(ctx C) {
|
Convey("When a job timed out", func(ctx C) {
|
||||||
scriptContent := `#!/bin/bash
|
scriptContent := `#!/bin/bash
|
||||||
echo $TUNASYNC_WORKING_DIR
|
echo $TUNASYNC_WORKING_DIR
|
||||||
@ -371,6 +370,30 @@ echo $TUNASYNC_WORKING_DIR
|
|||||||
job.ctrlChan <- jobDisable
|
job.ctrlChan <- jobDisable
|
||||||
<-job.disabled
|
<-job.disabled
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("It should be retried", func(ctx C) {
|
||||||
|
go job.Run(managerChan, semaphore)
|
||||||
|
job.ctrlChan <- jobStart
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
msg := <-managerChan
|
||||||
|
So(msg.status, ShouldEqual, PreSyncing)
|
||||||
|
|
||||||
|
for i := 0; i < defaultMaxRetry; i++ {
|
||||||
|
msg = <-managerChan
|
||||||
|
So(msg.status, ShouldEqual, Syncing)
|
||||||
|
|
||||||
|
job.ctrlChan <- jobStart // should be ignored
|
||||||
|
|
||||||
|
msg = <-managerChan
|
||||||
|
So(msg.status, ShouldEqual, Failed)
|
||||||
|
So(msg.msg, ShouldContainSubstring, "timeout after")
|
||||||
|
// re-schedule after last try
|
||||||
|
So(msg.schedule, ShouldEqual, i == defaultMaxRetry-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
job.ctrlChan <- jobDisable
|
||||||
|
<-job.disabled
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user