Fix #99549: Remember Previous Status #104217
@ -290,6 +290,43 @@ func TestWorkerSignoffStatusChangeRequest(t *testing.T) {
|
|||||||
assertResponseNoContent(t, echo)
|
assertResponseNoContent(t, echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWorkerRememberPreviousStatus(t *testing.T) {
|
||||||
|
mockCtrl := gomock.NewController(t)
|
||||||
|
defer mockCtrl.Finish()
|
||||||
|
|
||||||
|
mf := newMockedFlamenco(mockCtrl)
|
||||||
|
worker := testWorker()
|
||||||
|
worker.Status = api.WorkerStatusTesting
|
||||||
|
previousStatus := worker.Status
|
||||||
|
|
||||||
|
worker.StatusChangeRequest(api.WorkerStatusOffline, true)
|
||||||
|
|
||||||
|
mf.broadcaster.EXPECT().BroadcastWorkerUpdate(api.SocketIOWorkerUpdate{
|
||||||
|
Id: worker.UUID,
|
||||||
|
Name: worker.Name,
|
||||||
|
PreviousStatus: &previousStatus,
|
||||||
|
Status: api.WorkerStatusOffline,
|
||||||
|
Updated: worker.UpdatedAt,
|
||||||
|
Version: worker.Software,
|
||||||
|
})
|
||||||
|
mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &worker).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)
|
||||||
|
}
|
||||||
|
|
||||||
func TestWorkerState(t *testing.T) {
|
func TestWorkerState(t *testing.T) {
|
||||||
mockCtrl := gomock.NewController(t)
|
mockCtrl := gomock.NewController(t)
|
||||||
defer mockCtrl.Finish()
|
defer mockCtrl.Finish()
|
||||||
|
Loading…
Reference in New Issue
Block a user