mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-13 03:10:45 +01:00
fix[UT]:improve the UT cases of enqueuer (#11358)
- change the test cron spec - use cretaed timer for timeout Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
parent
f2beed577f
commit
3d6c65f53b
@ -96,9 +96,12 @@ func (suite *EnqueuerTestSuite) TestEnqueuer() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
tk := time.NewTicker(500 * time.Millisecond)
|
tk := time.NewTicker(497 * time.Millisecond)
|
||||||
defer tk.Stop()
|
defer tk.Stop()
|
||||||
|
|
||||||
|
tm := time.NewTimer(15 * time.Second)
|
||||||
|
defer tm.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-tk.C:
|
case <-tk.C:
|
||||||
@ -109,7 +112,7 @@ func (suite *EnqueuerTestSuite) TestEnqueuer() {
|
|||||||
}, "at least one job should be scheduled for the periodic job policy") {
|
}, "at least one job should be scheduled for the periodic job policy") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-time.After(15 * time.Second):
|
case <-tm.C:
|
||||||
require.NoError(suite.T(), errors.New("timeout (15s): expect at 1 scheduled job but still get nothing"))
|
require.NoError(suite.T(), errors.New("timeout (15s): expect at 1 scheduled job but still get nothing"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -120,7 +123,7 @@ func (suite *EnqueuerTestSuite) prepare() {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
minute := now.Minute()
|
minute := now.Minute()
|
||||||
|
|
||||||
coreSpec := fmt.Sprintf("0-59 %d * * * *", minute)
|
coreSpec := fmt.Sprintf("0-59 %d-%d * * * *", minute, minute+2)
|
||||||
|
|
||||||
// Prepare one
|
// Prepare one
|
||||||
p := &Policy{
|
p := &Policy{
|
||||||
|
Loading…
Reference in New Issue
Block a user