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