mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-13 03:10:45 +01:00
fix[js_ut]:update stop job case of js
remove the status checking loop Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
parent
890200ea19
commit
b2434945ff
@ -188,34 +188,32 @@ func (suite *CWorkerTestSuite) TestStopJob() {
|
|||||||
|
|
||||||
genericJob, err := suite.cWorker.Enqueue("fake_long_run_job", params, false, "")
|
genericJob, err := suite.cWorker.Enqueue("fake_long_run_job", params, false, "")
|
||||||
require.NoError(suite.T(), err, "enqueue job: nil error expected but got %s", err)
|
require.NoError(suite.T(), err, "enqueue job: nil error expected but got %s", err)
|
||||||
t, err := suite.lcmCtl.New(genericJob)
|
_, err = suite.lcmCtl.New(genericJob)
|
||||||
require.NoError(suite.T(), err, "new job stats: nil error expected but got %s", err)
|
require.NoError(suite.T(), err, "new job stats: nil error expected but got %s", err)
|
||||||
|
|
||||||
tk := time.NewTicker(417 * time.Millisecond)
|
/*
|
||||||
defer tk.Stop()
|
// Check if the job is running
|
||||||
|
times := 20
|
||||||
|
sleep := 500 * time.Millisecond
|
||||||
|
|
||||||
LOOP:
|
for times > 0 {
|
||||||
for {
|
st, err := t.Status()
|
||||||
select {
|
require.NoError(suite.T(), err, "retrieve enqueued job status")
|
||||||
case <-tk.C:
|
if st.Compare(job.RunningStatus) >= 0 {
|
||||||
latest, err := t.Status()
|
break
|
||||||
require.NoError(suite.T(), err, "get latest status: nil error expected but got %s", err)
|
|
||||||
if latest.Compare(job.RunningStatus) >= 0 {
|
|
||||||
break LOOP
|
|
||||||
}
|
|
||||||
case <-time.After(29 * time.Second):
|
|
||||||
require.NoError(suite.T(), errors.New("check running status time out"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
times--
|
||||||
|
time.Sleep(sleep)
|
||||||
|
}*/
|
||||||
|
|
||||||
err = suite.cWorker.StopJob(genericJob.Info.JobID)
|
err = suite.cWorker.StopJob(genericJob.Info.JobID)
|
||||||
require.NoError(suite.T(), err, "stop job: nil error expected but got %s", err)
|
require.NoError(suite.T(), err, "stop job: nil error expected but got %s", err)
|
||||||
|
|
||||||
// Stop scheduled job
|
// Stop scheduled job
|
||||||
scheduledJob, err := suite.cWorker.Schedule("fake_long_run_job", params, 120, false, "")
|
scheduledJob, err := suite.cWorker.Schedule("fake_long_run_job", params, 120, false, "")
|
||||||
require.NoError(suite.T(), err, "schedule job: nil error expected but got %s", err)
|
require.NoError(suite.T(), err, "schedule job: nil error expected but got %s", err)
|
||||||
t, err = suite.lcmCtl.New(scheduledJob)
|
_, err = suite.lcmCtl.New(scheduledJob)
|
||||||
require.NoError(suite.T(), err, "new job stats: nil error expected but got %s", err)
|
require.NoError(suite.T(), err, "new job stats: nil error expected but got %s", err)
|
||||||
|
|
||||||
err = suite.cWorker.StopJob(scheduledJob.Info.JobID)
|
err = suite.cWorker.StopJob(scheduledJob.Info.JobID)
|
||||||
|
Loading…
Reference in New Issue
Block a user