[MM-25089] Migrate server busy endpoints to local mode (#14883)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bf664997a7
Коммит
5ddf8d4099
@@ -5,4 +5,7 @@ package api4
|
||||
|
||||
func (api *API) InitSystemLocal() {
|
||||
api.BaseRoutes.ApiRoot.Handle("/logs", api.ApiLocal(getLogs)).Methods("GET")
|
||||
api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(setServerBusy)).Methods("POST")
|
||||
api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(getServerBusyExpires)).Methods("GET")
|
||||
api.BaseRoutes.ApiRoot.Handle("/server_busy", api.ApiLocal(clearServerBusy)).Methods("DELETE")
|
||||
}
|
||||
|
||||
@@ -530,27 +530,27 @@ func TestSetServerBusy(t *testing.T) {
|
||||
require.False(t, th.App.Srv().Busy.IsBusy(), "server should not be marked busy")
|
||||
})
|
||||
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
ok, resp := th.SystemAdminClient.SetServerBusy(secs)
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
ok, resp := c.SetServerBusy(secs)
|
||||
CheckNoError(t, resp)
|
||||
require.True(t, ok, "should set server busy successfully")
|
||||
require.True(t, th.App.Srv().Busy.IsBusy(), "server should be marked busy")
|
||||
})
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestSetServerBusyInvalidParam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system admin, invalid param", func(t *testing.T) {
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
params := []int{-1, 0, MAX_SERVER_BUSY_SECONDS + 1}
|
||||
for _, p := range params {
|
||||
ok, resp := th.SystemAdminClient.SetServerBusy(p)
|
||||
ok, resp := c.SetServerBusy(p)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
require.False(t, ok, "should not set server busy due to invalid param ", p)
|
||||
require.False(t, th.App.Srv().Busy.IsBusy(), "server should not be marked busy due to invalid param ", p)
|
||||
}
|
||||
})
|
||||
}, "as system admin, invalid param")
|
||||
}
|
||||
|
||||
func TestClearServerBusy(t *testing.T) {
|
||||
@@ -566,12 +566,12 @@ func TestClearServerBusy(t *testing.T) {
|
||||
})
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
ok, resp := th.SystemAdminClient.ClearServerBusy()
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
ok, resp := c.ClearServerBusy()
|
||||
CheckNoError(t, resp)
|
||||
require.True(t, ok, "should clear server busy flag successfully")
|
||||
require.False(t, th.App.Srv().Busy.IsBusy(), "server should not be marked busy")
|
||||
})
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestGetServerBusy(t *testing.T) {
|
||||
@@ -585,12 +585,12 @@ func TestGetServerBusy(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
sbs, resp := th.SystemAdminClient.GetServerBusy()
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
sbs, resp := c.GetServerBusy()
|
||||
expires := time.Unix(sbs.Expires, 0)
|
||||
CheckNoError(t, resp)
|
||||
require.Greater(t, expires.Unix(), time.Now().Unix())
|
||||
})
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestGetServerBusyExpires(t *testing.T) {
|
||||
@@ -604,11 +604,11 @@ func TestGetServerBusyExpires(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
expires, resp := th.SystemAdminClient.GetServerBusyExpires()
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
expires, resp := c.GetServerBusyExpires()
|
||||
CheckNoError(t, resp)
|
||||
require.Greater(t, expires.Unix(), time.Now().Unix())
|
||||
})
|
||||
}, "as system admin")
|
||||
}
|
||||
|
||||
func TestServerBusy503(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user