mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 17:47:46 +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()
|
||||
|
||||
tm := time.NewTimer(15 * time.Second)
|
||||
defer tm.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-tk.C:
|
||||
@ -109,7 +112,7 @@ func (suite *EnqueuerTestSuite) TestEnqueuer() {
|
||||
}, "at least one job should be scheduled for the periodic job policy") {
|
||||
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"))
|
||||
return
|
||||
}
|
||||
@ -120,7 +123,7 @@ func (suite *EnqueuerTestSuite) prepare() {
|
||||
now := time.Now()
|
||||
minute := now.Minute()
|
||||
|
||||
coreSpec := fmt.Sprintf("0-59 %d * * * *", minute)
|
||||
coreSpec := fmt.Sprintf("0-59 %d-%d * * * *", minute, minute+2)
|
||||
|
||||
// Prepare one
|
||||
p := &Policy{
|
||||
|
Loading…
Reference in New Issue
Block a user