Manager: store software version on worker sign-on

This commit is contained in:
Sybren A. Stüvel 2022-05-31 12:29:25 +02:00
parent 424e80163b
commit 90b567f97c
2 changed files with 25 additions and 0 deletions

View File

@ -106,6 +106,7 @@ func (f *Flamenco) workerUpdateAfterSignOn(e echo.Context, update api.SignOnJSON
w.Status = api.WorkerStatusStarting
w.Address = e.RealIP()
w.Name = update.Nickname
w.Software = update.SoftwareVersion
// Remove trailing spaces from task types, and convert to lower case.
for idx := range update.SupportedTaskTypes {

View File

@ -89,6 +89,30 @@ func TestTaskScheduleOtherStatusRequested(t *testing.T) {
assertResponseJSON(t, echoCtx, http.StatusLocked, expectBody)
}
func TestWorkerSignOn(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mf := newMockedFlamenco(mockCtrl)
worker := testWorker()
worker.Status = api.WorkerStatusOffline
mf.persistence.EXPECT().SaveWorker(gomock.Any(), &worker).Return(nil)
echo := mf.prepareMockedJSONRequest(api.WorkerSignOn{
Nickname: "Lazy Boi",
SoftwareVersion: "3.0-testing",
SupportedTaskTypes: []string{"testing", "sleeping", "snoozing"},
})
requestWorkerStore(echo, &worker)
err := mf.flamenco.SignOn(echo)
assert.NoError(t, err)
assertResponseJSON(t, echo, http.StatusOK, api.WorkerStateChange{
StatusRequested: api.WorkerStatusAwake,
})
}
func TestWorkerSignoffTaskRequeue(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()