Reduce logging data races, fix MySQL test race condition (#7994)
* fix races * revert unintentional change * fix test as intended
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
5189e8ea10
Коммит
91bfc72a99
@@ -7,17 +7,13 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mssola/user_agent"
|
||||
)
|
||||
|
||||
func (api *API) InitAdmin() {
|
||||
l4g.Debug(utils.T("api.admin.init.debug"))
|
||||
|
||||
api.BaseRoutes.Admin.Handle("/logs", api.ApiAdminSystemRequired(getLogs)).Methods("GET")
|
||||
api.BaseRoutes.Admin.Handle("/audits", api.ApiAdminSystemRequired(getAllAudits)).Methods("GET")
|
||||
api.BaseRoutes.Admin.Handle("/config", api.ApiAdminSystemRequired(getConfig)).Methods("GET")
|
||||
|
||||
@@ -107,7 +107,6 @@ func Init(a *app.App, root *mux.Router) *API {
|
||||
api.InitStatus()
|
||||
api.InitWebrtc()
|
||||
api.InitReaction()
|
||||
api.InitDeprecated()
|
||||
|
||||
// 404 on any api route before web.go has a chance to serve it
|
||||
root.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
|
||||
|
||||
@@ -79,7 +79,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
||||
*cfg.RateLimitSettings.Enable = false
|
||||
cfg.EmailSettings.SendEmailNotifications = true
|
||||
})
|
||||
utils.DisableDebugLogForTest()
|
||||
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
|
||||
if testStore != nil {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
|
||||
@@ -89,7 +88,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
||||
api4.Init(th.App, th.App.Srv.Router, false)
|
||||
Init(th.App, th.App.Srv.Router)
|
||||
wsapi.Init(th.App, th.App.Srv.WebSocketRouter)
|
||||
utils.EnableDebugLogForTest()
|
||||
th.App.Srv.Store.MarkSystemRanUnitTests()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = true })
|
||||
|
||||
@@ -14,8 +14,6 @@ import (
|
||||
)
|
||||
|
||||
func (api *API) InitChannel() {
|
||||
l4g.Debug(utils.T("api.channel.init.debug"))
|
||||
|
||||
api.BaseRoutes.Channels.Handle("/", api.ApiUserRequired(getChannels)).Methods("GET")
|
||||
api.BaseRoutes.Channels.Handle("/more/{offset:[0-9]+}/{limit:[0-9]+}", api.ApiUserRequired(getMoreChannelsPage)).Methods("GET")
|
||||
api.BaseRoutes.Channels.Handle("/more/search", api.ApiUserRequired(searchMoreChannels)).Methods("POST")
|
||||
|
||||
@@ -8,15 +8,10 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitCommand() {
|
||||
l4g.Debug(utils.T("api.command.init.debug"))
|
||||
|
||||
api.BaseRoutes.Commands.Handle("/execute", api.ApiUserRequired(executeCommand)).Methods("POST")
|
||||
api.BaseRoutes.Commands.Handle("/list", api.ApiUserRequired(listCommands)).Methods("GET")
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
// ONLY FOR APIs SCHEDULED TO BE DEPRECATED
|
||||
|
||||
func (api *API) InitDeprecated() {
|
||||
l4g.Debug(utils.T("api.deprecated.init.debug"))
|
||||
}
|
||||
@@ -12,17 +12,13 @@ import (
|
||||
|
||||
"image/color/palette"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitEmoji() {
|
||||
l4g.Debug(utils.T("api.emoji.init.debug"))
|
||||
|
||||
api.BaseRoutes.Emoji.Handle("/list", api.ApiUserRequired(getEmoji)).Methods("GET")
|
||||
api.BaseRoutes.Emoji.Handle("/create", api.ApiUserRequired(createEmoji)).Methods("POST")
|
||||
api.BaseRoutes.Emoji.Handle("/delete", api.ApiUserRequired(deleteEmoji)).Methods("POST")
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
@@ -31,8 +30,6 @@ var UNSAFE_CONTENT_TYPES = [...]string{
|
||||
}
|
||||
|
||||
func (api *API) InitFile() {
|
||||
l4g.Debug(utils.T("api.file.init.debug"))
|
||||
|
||||
api.BaseRoutes.TeamFiles.Handle("/upload", api.ApiUserRequired(uploadFile)).Methods("POST")
|
||||
|
||||
api.BaseRoutes.NeedFile.Handle("/get", api.ApiUserRequiredTrustRequester(getFile)).Methods("GET")
|
||||
|
||||
@@ -8,15 +8,11 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitGeneral() {
|
||||
l4g.Debug(utils.T("api.general.init.debug"))
|
||||
|
||||
api.BaseRoutes.General.Handle("/client_props", api.ApiAppHandler(getClientConfig)).Methods("GET")
|
||||
api.BaseRoutes.General.Handle("/log_client", api.ApiAppHandler(logClient)).Methods("POST")
|
||||
api.BaseRoutes.General.Handle("/ping", api.ApiAppHandler(ping)).Methods("GET")
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
func TestGetClientProperties(t *testing.T) {
|
||||
|
||||
@@ -8,14 +8,11 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitLicense() {
|
||||
l4g.Debug(utils.T("api.license.init.debug"))
|
||||
|
||||
api.BaseRoutes.License.Handle("/add", api.ApiAdminSystemRequired(addLicense)).Methods("POST")
|
||||
api.BaseRoutes.License.Handle("/remove", api.ApiAdminSystemRequired(removeLicense)).Methods("POST")
|
||||
api.BaseRoutes.License.Handle("/client_config", api.ApiAppHandler(getClientLicenceConfig)).Methods("GET")
|
||||
|
||||
@@ -6,15 +6,11 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitOAuth() {
|
||||
l4g.Debug(utils.T("api.oauth.init.debug"))
|
||||
|
||||
api.BaseRoutes.OAuth.Handle("/register", api.ApiUserRequired(registerOAuthApp)).Methods("POST")
|
||||
api.BaseRoutes.OAuth.Handle("/list", api.ApiUserRequired(getOAuthApps)).Methods("GET")
|
||||
api.BaseRoutes.OAuth.Handle("/app/{client_id}", api.ApiUserRequired(getOAuthAppInfo)).Methods("GET")
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
@@ -20,8 +19,6 @@ const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000
|
||||
var openGraphDataCache = utils.NewLru(OPEN_GRAPH_METADATA_CACHE_SIZE)
|
||||
|
||||
func (api *API) InitPost() {
|
||||
l4g.Debug(utils.T("api.post.init.debug"))
|
||||
|
||||
api.BaseRoutes.ApiRoot.Handle("/get_opengraph_metadata", api.ApiUserRequired(getOpenGraphMetadata)).Methods("POST")
|
||||
|
||||
api.BaseRoutes.NeedTeam.Handle("/posts/search", api.ApiUserRequiredActivity(searchPosts, true)).Methods("POST")
|
||||
|
||||
@@ -6,15 +6,11 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitPreference() {
|
||||
l4g.Debug(utils.T("api.preference.init.debug"))
|
||||
|
||||
api.BaseRoutes.Preferences.Handle("/", api.ApiUserRequired(getAllPreferences)).Methods("GET")
|
||||
api.BaseRoutes.Preferences.Handle("/save", api.ApiUserRequired(savePreferences)).Methods("POST")
|
||||
api.BaseRoutes.Preferences.Handle("/delete", api.ApiUserRequired(deletePreferences)).Methods("POST")
|
||||
|
||||
@@ -6,15 +6,11 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitReaction() {
|
||||
l4g.Debug(utils.T("api.reaction.init.debug"))
|
||||
|
||||
api.BaseRoutes.NeedPost.Handle("/reactions/save", api.ApiUserRequired(saveReaction)).Methods("POST")
|
||||
api.BaseRoutes.NeedPost.Handle("/reactions/delete", api.ApiUserRequired(deleteReaction)).Methods("POST")
|
||||
api.BaseRoutes.NeedPost.Handle("/reactions", api.ApiUserRequired(listReactions)).Methods("GET")
|
||||
|
||||
@@ -6,15 +6,10 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitStatus() {
|
||||
l4g.Debug(utils.T("api.status.init.debug"))
|
||||
|
||||
api.BaseRoutes.Users.Handle("/status", api.ApiUserRequired(getStatusesHttp)).Methods("GET")
|
||||
api.BaseRoutes.Users.Handle("/status/ids", api.ApiUserRequired(getStatusesByIdsHttp)).Methods("POST")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
@@ -18,8 +17,6 @@ import (
|
||||
)
|
||||
|
||||
func (api *API) InitTeam() {
|
||||
l4g.Debug(utils.T("api.team.init.debug"))
|
||||
|
||||
api.BaseRoutes.Teams.Handle("/create", api.ApiUserRequired(createTeam)).Methods("POST")
|
||||
api.BaseRoutes.Teams.Handle("/all", api.ApiUserRequired(getAll)).Methods("GET")
|
||||
api.BaseRoutes.Teams.Handle("/all_team_listings", api.ApiUserRequired(GetAllTeamListings)).Methods("GET")
|
||||
|
||||
@@ -20,8 +20,6 @@ import (
|
||||
)
|
||||
|
||||
func (api *API) InitUser() {
|
||||
l4g.Debug(utils.T("api.user.init.debug"))
|
||||
|
||||
api.BaseRoutes.Users.Handle("/create", api.ApiAppHandler(createUser)).Methods("POST")
|
||||
api.BaseRoutes.Users.Handle("/update", api.ApiUserRequired(updateUser)).Methods("POST")
|
||||
api.BaseRoutes.Users.Handle("/update_active", api.ApiUserRequired(updateActive)).Methods("POST")
|
||||
|
||||
@@ -6,14 +6,10 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitWebhook() {
|
||||
l4g.Debug(utils.T("api.webhook.init.debug"))
|
||||
|
||||
api.BaseRoutes.Hooks.Handle("/incoming/create", api.ApiUserRequired(createIncomingHook)).Methods("POST")
|
||||
api.BaseRoutes.Hooks.Handle("/incoming/update", api.ApiUserRequired(updateIncomingHook)).Methods("POST")
|
||||
api.BaseRoutes.Hooks.Handle("/incoming/delete", api.ApiUserRequired(deleteIncomingHook)).Methods("POST")
|
||||
|
||||
@@ -5,14 +5,9 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (api *API) InitWebrtc() {
|
||||
l4g.Debug(utils.T("api.webrtc.init.debug"))
|
||||
|
||||
api.BaseRoutes.Webrtc.Handle("/token", api.ApiUserRequired(webrtcToken)).Methods("POST")
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func (api *API) InitWebSocket() {
|
||||
l4g.Debug(utils.T("api.web_socket.init.debug"))
|
||||
api.BaseRoutes.Users.Handle("/websocket", api.ApiAppHandlerTrustRequester(connect)).Methods("GET")
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user