Fix #99549: Remember Previous Status #104217
@ -293,38 +293,40 @@ func TestWorkerSignoffStatusChangeRequest(t *testing.T) {
|
||||
func TestWorkerRememberPreviousStatus(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
mf := newMockedFlamenco(mockCtrl)
|
||||
|
||||
worker := testWorker()
|
||||
worker.Status = api.WorkerStatusTesting
|
||||
previousStatus := worker.Status
|
||||
|
||||
initialStatusRequested := worker.StatusRequested
|
||||
initialLazyStatusRequest := worker.LazyStatusRequest
|
||||
worker.StatusChangeRequest(api.WorkerStatusOffline, true)
|
||||
|
||||
mf.broadcaster.EXPECT().BroadcastWorkerUpdate(api.SocketIOWorkerUpdate{
|
||||
Id: worker.UUID,
|
||||
Name: worker.Name,
|
||||
PreviousStatus: &previousStatus,
|
||||
PreviousStatus: ptr(api.WorkerStatusTesting),
|
||||
Status: api.WorkerStatusOffline,
|
||||
Updated: worker.UpdatedAt,
|
||||
Version: worker.Software,
|
||||
})
|
||||
mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &worker).Return(nil)
|
||||
|
||||
savedWorker := worker
|
||||
savedWorker.Status = api.WorkerStatusOffline
|
||||
savedWorker.StatusChangeClear()
|
||||
mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &savedWorker).Return(nil)
|
||||
mf.stateMachine.EXPECT().RequeueActiveTasksOfWorker(gomock.Any(), &worker, "worker signed off").Return(nil)
|
||||
mf.persistence.EXPECT().WorkerSeen(gomock.Any(), &worker)
|
||||
|
||||
|
||||
worker.Status = api.WorkerStatusAwake
|
||||
|
||||
// Preform the request
|
||||
echo := mf.prepareMockedRequest(nil)
|
||||
requestWorkerStore(echo, &worker)
|
||||
err := mf.flamenco.SignOff(echo)
|
||||
|
||||
// Validate to check if status is equivalent
|
||||
assert.Equal(t, previousStatus, worker.Status)
|
||||
assert.NoError(t, err)
|
||||
assertResponseNoContent(t, echo)
|
||||
|
||||
assert.Equal(t, initialStatusRequested, worker.StatusRequested)
|
||||
assert.Equal(t, initialLazyStatusRequest, worker.LazyStatusRequest)
|
||||
}
|
||||
|
||||
func TestWorkerState(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user