mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-15 14:12:47 +00:00
feature(worker): fix exec_post_hook_test, manager channel was blocked in the previous version
This commit is contained in:
parent
5ef50090e9
commit
8399417880
@ -82,7 +82,6 @@ echo $TUNASYNC_WORKING_DIR
|
|||||||
echo $TUNASYNC_MIRROR_NAME
|
echo $TUNASYNC_MIRROR_NAME
|
||||||
echo $TUNASYNC_UPSTREAM_URL
|
echo $TUNASYNC_UPSTREAM_URL
|
||||||
echo $TUNASYNC_LOG_FILE
|
echo $TUNASYNC_LOG_FILE
|
||||||
sleep 5
|
|
||||||
exit 1
|
exit 1
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -93,10 +92,12 @@ exit 1
|
|||||||
job.ctrlChan <- jobStart
|
job.ctrlChan <- jobStart
|
||||||
msg := <-managerChan
|
msg := <-managerChan
|
||||||
So(msg.status, ShouldEqual, PreSyncing)
|
So(msg.status, ShouldEqual, PreSyncing)
|
||||||
msg = <-managerChan
|
for i := 0; i < maxRetry; i++ {
|
||||||
So(msg.status, ShouldEqual, Syncing)
|
msg = <-managerChan
|
||||||
msg = <-managerChan
|
So(msg.status, ShouldEqual, Syncing)
|
||||||
So(msg.status, ShouldEqual, Failed)
|
msg = <-managerChan
|
||||||
|
So(msg.status, ShouldEqual, Failed)
|
||||||
|
}
|
||||||
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
job.ctrlChan <- jobDisable
|
job.ctrlChan <- jobDisable
|
||||||
|
@ -49,7 +49,7 @@ func TestMirrorJob(t *testing.T) {
|
|||||||
echo $TUNASYNC_UPSTREAM_URL
|
echo $TUNASYNC_UPSTREAM_URL
|
||||||
echo $TUNASYNC_LOG_FILE
|
echo $TUNASYNC_LOG_FILE
|
||||||
`
|
`
|
||||||
exceptedOutput := fmt.Sprintf(
|
expectedOutput := fmt.Sprintf(
|
||||||
"%s\n%s\n%s\n%s\n",
|
"%s\n%s\n%s\n%s\n",
|
||||||
provider.WorkingDir(),
|
provider.WorkingDir(),
|
||||||
provider.Name(),
|
provider.Name(),
|
||||||
@ -86,7 +86,7 @@ func TestMirrorJob(t *testing.T) {
|
|||||||
So(msg.status, ShouldEqual, Success)
|
So(msg.status, ShouldEqual, Success)
|
||||||
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(string(loggedContent), ShouldEqual, exceptedOutput)
|
So(string(loggedContent), ShouldEqual, expectedOutput)
|
||||||
job.ctrlChan <- jobStart
|
job.ctrlChan <- jobStart
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
@ -140,10 +140,10 @@ echo $TUNASYNC_WORKING_DIR
|
|||||||
msg = <-managerChan
|
msg = <-managerChan
|
||||||
So(msg.status, ShouldEqual, Failed)
|
So(msg.status, ShouldEqual, Failed)
|
||||||
|
|
||||||
exceptedOutput := fmt.Sprintf("%s\n", provider.WorkingDir())
|
expectedOutput := fmt.Sprintf("%s\n", provider.WorkingDir())
|
||||||
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(string(loggedContent), ShouldEqual, exceptedOutput)
|
So(string(loggedContent), ShouldEqual, expectedOutput)
|
||||||
job.ctrlChan <- jobDisable
|
job.ctrlChan <- jobDisable
|
||||||
<-job.disabled
|
<-job.disabled
|
||||||
})
|
})
|
||||||
@ -159,14 +159,14 @@ echo $TUNASYNC_WORKING_DIR
|
|||||||
msg = <-managerChan
|
msg = <-managerChan
|
||||||
So(msg.status, ShouldEqual, Success)
|
So(msg.status, ShouldEqual, Success)
|
||||||
|
|
||||||
exceptedOutput := fmt.Sprintf(
|
expectedOutput := fmt.Sprintf(
|
||||||
"%s\n%s\n",
|
"%s\n%s\n",
|
||||||
provider.WorkingDir(), provider.WorkingDir(),
|
provider.WorkingDir(), provider.WorkingDir(),
|
||||||
)
|
)
|
||||||
|
|
||||||
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(string(loggedContent), ShouldEqual, exceptedOutput)
|
So(string(loggedContent), ShouldEqual, expectedOutput)
|
||||||
job.ctrlChan <- jobDisable
|
job.ctrlChan <- jobDisable
|
||||||
<-job.disabled
|
<-job.disabled
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user