From 91bfc72a99477b6d611b13e225786e3ca7add10c Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 22 Dec 2017 06:09:33 -0600 Subject: Reduce logging data races, fix MySQL test race condition (#7994) * fix races * revert unintentional change * fix test as intended --- api4/apitestlib.go | 2 -- api4/brand.go | 4 ---- api4/channel.go | 3 --- api4/cluster.go | 4 ---- api4/command.go | 4 ---- api4/compliance.go | 4 ---- api4/data_retention.go | 6 ------ api4/elasticsearch.go | 4 ---- api4/emoji.go | 5 ----- api4/file.go | 3 --- api4/job.go | 3 --- api4/ldap.go | 4 ---- api4/oauth.go | 2 -- api4/openGraph.go | 3 --- api4/openGraph_test.go | 3 ++- api4/post.go | 5 ----- api4/preference.go | 4 ---- api4/reaction.go | 4 ---- api4/saml.go | 4 ---- api4/status.go | 5 ----- api4/system.go | 2 -- api4/team.go | 4 ---- api4/user.go | 2 -- api4/webhook.go | 3 --- api4/webrtc.go | 5 ----- api4/webrtc_test.go | 3 ++- api4/websocket.go | 2 -- 27 files changed, 4 insertions(+), 93 deletions(-) (limited to 'api4') diff --git a/api4/apitestlib.go b/api4/apitestlib.go index f08e5d1ef..eab27173f 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -88,7 +88,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" }) @@ -97,7 +96,6 @@ func setupTestHelper(enterprise bool) *TestHelper { th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress }) Init(th.App, th.App.Srv.Router, true) 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 }) diff --git a/api4/brand.go b/api4/brand.go index ee48953dd..f182e1070 100644 --- a/api4/brand.go +++ b/api4/brand.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitBrand() { - l4g.Debug(utils.T("api.brand.init.debug")) - api.BaseRoutes.Brand.Handle("/image", api.ApiHandlerTrustRequester(getBrandImage)).Methods("GET") api.BaseRoutes.Brand.Handle("/image", api.ApiSessionRequired(uploadBrandImage)).Methods("POST") } diff --git a/api4/channel.go b/api4/channel.go index f96942a4f..f8a069ea0 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -8,12 +8,9 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitChannel() { - l4g.Debug(utils.T("api.channel.init.debug")) - api.BaseRoutes.Channels.Handle("", api.ApiSessionRequired(createChannel)).Methods("POST") api.BaseRoutes.Channels.Handle("/direct", api.ApiSessionRequired(createDirectChannel)).Methods("POST") api.BaseRoutes.Channels.Handle("/group", api.ApiSessionRequired(createGroupChannel)).Methods("POST") diff --git a/api4/cluster.go b/api4/cluster.go index 472b52f36..375e1bd0c 100644 --- a/api4/cluster.go +++ b/api4/cluster.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitCluster() { - l4g.Debug(utils.T("api.cluster.init.debug")) - api.BaseRoutes.Cluster.Handle("/status", api.ApiSessionRequired(getClusterStatus)).Methods("GET") } diff --git a/api4/command.go b/api4/command.go index c92eb277a..3ab2839ba 100644 --- a/api4/command.go +++ b/api4/command.go @@ -9,14 +9,10 @@ import ( "strconv" "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("", api.ApiSessionRequired(createCommand)).Methods("POST") api.BaseRoutes.Commands.Handle("", api.ApiSessionRequired(listCommands)).Methods("GET") api.BaseRoutes.Commands.Handle("/execute", api.ApiSessionRequired(executeCommand)).Methods("POST") diff --git a/api4/compliance.go b/api4/compliance.go index d58398595..71f0fa81d 100644 --- a/api4/compliance.go +++ b/api4/compliance.go @@ -7,15 +7,11 @@ import ( "net/http" "strconv" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" "github.com/mssola/user_agent" ) func (api *API) InitCompliance() { - l4g.Debug(utils.T("api.compliance.init.debug")) - api.BaseRoutes.Compliance.Handle("/reports", api.ApiSessionRequired(createComplianceReport)).Methods("POST") api.BaseRoutes.Compliance.Handle("/reports", api.ApiSessionRequired(getComplianceReports)).Methods("GET") api.BaseRoutes.Compliance.Handle("/reports/{report_id:[A-Za-z0-9]+}", api.ApiSessionRequired(getComplianceReport)).Methods("GET") diff --git a/api4/data_retention.go b/api4/data_retention.go index da0d5812e..8c42473e6 100644 --- a/api4/data_retention.go +++ b/api4/data_retention.go @@ -5,15 +5,9 @@ package api4 import ( "net/http" - - l4g "github.com/alecthomas/log4go" - - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitDataRetention() { - l4g.Debug(utils.T("api.data_retention.init.debug")) - api.BaseRoutes.DataRetention.Handle("/policy", api.ApiSessionRequired(getPolicy)).Methods("GET") } diff --git a/api4/elasticsearch.go b/api4/elasticsearch.go index 6640b0837..7ba88f172 100644 --- a/api4/elasticsearch.go +++ b/api4/elasticsearch.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitElasticsearch() { - l4g.Debug(utils.T("api.elasticsearch.init.debug")) - api.BaseRoutes.Elasticsearch.Handle("/test", api.ApiSessionRequired(testElasticsearch)).Methods("POST") api.BaseRoutes.Elasticsearch.Handle("/purge_indexes", api.ApiSessionRequired(purgeElasticsearchIndexes)).Methods("POST") } diff --git a/api4/emoji.go b/api4/emoji.go index e96e0755f..341c565d8 100644 --- a/api4/emoji.go +++ b/api4/emoji.go @@ -7,16 +7,11 @@ import ( "net/http" "strings" - l4g "github.com/alecthomas/log4go" - "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.Emojis.Handle("", api.ApiSessionRequired(createEmoji)).Methods("POST") api.BaseRoutes.Emojis.Handle("", api.ApiSessionRequired(getEmojiList)).Methods("GET") api.BaseRoutes.Emoji.Handle("", api.ApiSessionRequired(deleteEmoji)).Methods("DELETE") diff --git a/api4/file.go b/api4/file.go index 7e13d0290..48ee281fe 100644 --- a/api4/file.go +++ b/api4/file.go @@ -9,7 +9,6 @@ import ( "strconv" "strings" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" @@ -44,8 +43,6 @@ var MEDIA_CONTENT_TYPES = [...]string{ } func (api *API) InitFile() { - l4g.Debug(utils.T("api.file.init.debug")) - api.BaseRoutes.Files.Handle("", api.ApiSessionRequired(uploadFile)).Methods("POST") api.BaseRoutes.File.Handle("", api.ApiSessionRequiredTrustRequester(getFile)).Methods("GET") api.BaseRoutes.File.Handle("/thumbnail", api.ApiSessionRequiredTrustRequester(getFileThumbnail)).Methods("GET") diff --git a/api4/job.go b/api4/job.go index 2a5134cd3..864d21bbb 100644 --- a/api4/job.go +++ b/api4/job.go @@ -6,13 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" ) func (api *API) InitJob() { - l4g.Info("Initializing job API routes") - api.BaseRoutes.Jobs.Handle("", api.ApiSessionRequired(getJobs)).Methods("GET") api.BaseRoutes.Jobs.Handle("", api.ApiSessionRequired(createJob)).Methods("POST") api.BaseRoutes.Jobs.Handle("/{job_id:[A-Za-z0-9]+}", api.ApiSessionRequired(getJob)).Methods("GET") diff --git a/api4/ldap.go b/api4/ldap.go index 66735c526..b3416ffa1 100644 --- a/api4/ldap.go +++ b/api4/ldap.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitLdap() { - l4g.Debug(utils.T("api.ldap.init.debug")) - api.BaseRoutes.LDAP.Handle("/sync", api.ApiSessionRequired(syncLdap)).Methods("POST") api.BaseRoutes.LDAP.Handle("/test", api.ApiSessionRequired(testLdap)).Methods("POST") } diff --git a/api4/oauth.go b/api4/oauth.go index b54a43832..ac293c63e 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -15,8 +15,6 @@ import ( ) func (api *API) InitOAuth() { - l4g.Debug(utils.T("api.oauth.init.debug")) - api.BaseRoutes.OAuthApps.Handle("", api.ApiSessionRequired(createOAuthApp)).Methods("POST") api.BaseRoutes.OAuthApp.Handle("", api.ApiSessionRequired(updateOAuthApp)).Methods("PUT") api.BaseRoutes.OAuthApps.Handle("", api.ApiSessionRequired(getOAuthApps)).Methods("GET") diff --git a/api4/openGraph.go b/api4/openGraph.go index c552b54d9..646cce883 100644 --- a/api4/openGraph.go +++ b/api4/openGraph.go @@ -6,7 +6,6 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -16,8 +15,6 @@ const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000 var openGraphDataCache = utils.NewLru(OPEN_GRAPH_METADATA_CACHE_SIZE) func (api *API) InitOpenGraph() { - l4g.Debug(utils.T("api.opengraph.init.debug")) - api.BaseRoutes.OpenGraph.Handle("", api.ApiSessionRequired(getOpenGraphMetadata)).Methods("POST") } diff --git a/api4/openGraph_test.go b/api4/openGraph_test.go index 6a14ad943..b7c4fe314 100644 --- a/api4/openGraph_test.go +++ b/api4/openGraph_test.go @@ -9,8 +9,9 @@ import ( "net/http/httptest" "strings" - "github.com/mattermost/mattermost-server/model" "testing" + + "github.com/mattermost/mattermost-server/model" ) func TestGetOpenGraphMetadata(t *testing.T) { diff --git a/api4/post.go b/api4/post.go index 6dc3564ff..7a365845f 100644 --- a/api4/post.go +++ b/api4/post.go @@ -8,15 +8,10 @@ import ( "strconv" "time" - l4g "github.com/alecthomas/log4go" - "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitPost() { - l4g.Debug(utils.T("api.post.init.debug")) - api.BaseRoutes.Posts.Handle("", api.ApiSessionRequired(createPost)).Methods("POST") api.BaseRoutes.Post.Handle("", api.ApiSessionRequired(getPost)).Methods("GET") api.BaseRoutes.Post.Handle("", api.ApiSessionRequired(deletePost)).Methods("DELETE") diff --git a/api4/preference.go b/api4/preference.go index ad1eca4c8..c9f0b3af4 100644 --- a/api4/preference.go +++ b/api4/preference.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "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.ApiSessionRequired(getPreferences)).Methods("GET") api.BaseRoutes.Preferences.Handle("", api.ApiSessionRequired(updatePreferences)).Methods("PUT") api.BaseRoutes.Preferences.Handle("/delete", api.ApiSessionRequired(deletePreferences)).Methods("POST") diff --git a/api4/reaction.go b/api4/reaction.go index a19b2460a..6208b0aee 100644 --- a/api4/reaction.go +++ b/api4/reaction.go @@ -6,14 +6,10 @@ package api4 import ( "net/http" - l4g "github.com/alecthomas/log4go" "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.Reactions.Handle("", api.ApiSessionRequired(saveReaction)).Methods("POST") api.BaseRoutes.Post.Handle("/reactions", api.ApiSessionRequired(getReactions)).Methods("GET") api.BaseRoutes.ReactionByNameForPostForUser.Handle("", api.ApiSessionRequired(deleteReaction)).Methods("DELETE") diff --git a/api4/saml.go b/api4/saml.go index 469576943..936e5d958 100644 --- a/api4/saml.go +++ b/api4/saml.go @@ -7,14 +7,10 @@ import ( "mime/multipart" "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func (api *API) InitSaml() { - l4g.Debug(utils.T("api.saml.init.debug")) - api.BaseRoutes.SAML.Handle("/metadata", api.ApiHandler(getSamlMetadata)).Methods("GET") api.BaseRoutes.SAML.Handle("/certificate/public", api.ApiSessionRequired(addSamlPublicCertificate)).Methods("POST") diff --git a/api4/status.go b/api4/status.go index c8690768d..59909e295 100644 --- a/api4/status.go +++ b/api4/status.go @@ -6,15 +6,10 @@ package api4 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.User.Handle("/status", api.ApiSessionRequired(getUserStatus)).Methods("GET") api.BaseRoutes.Users.Handle("/status/ids", api.ApiSessionRequired(getUserStatusesByIds)).Methods("POST") api.BaseRoutes.User.Handle("/status", api.ApiSessionRequired(updateUserStatus)).Methods("PUT") diff --git a/api4/system.go b/api4/system.go index 93e9ddcd2..c87527ff0 100644 --- a/api4/system.go +++ b/api4/system.go @@ -16,8 +16,6 @@ import ( ) func (api *API) InitSystem() { - l4g.Debug(utils.T("api.system.init.debug")) - api.BaseRoutes.System.Handle("/ping", api.ApiHandler(getSystemPing)).Methods("GET") api.BaseRoutes.ApiRoot.Handle("/config", api.ApiSessionRequired(getConfig)).Methods("GET") diff --git a/api4/team.go b/api4/team.go index e897ea32b..d770aee22 100644 --- a/api4/team.go +++ b/api4/team.go @@ -9,9 +9,7 @@ import ( "net/http" "strconv" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) const ( @@ -19,8 +17,6 @@ const ( ) func (api *API) InitTeam() { - l4g.Debug(utils.T("api.team.init.debug")) - api.BaseRoutes.Teams.Handle("", api.ApiSessionRequired(createTeam)).Methods("POST") api.BaseRoutes.Teams.Handle("", api.ApiSessionRequired(getAllTeams)).Methods("GET") api.BaseRoutes.Teams.Handle("/search", api.ApiSessionRequired(searchTeams)).Methods("POST") diff --git a/api4/user.go b/api4/user.go index 4f4185958..6cb064f8c 100644 --- a/api4/user.go +++ b/api4/user.go @@ -17,8 +17,6 @@ import ( ) func (api *API) InitUser() { - l4g.Debug(utils.T("api.user.init.debug")) - api.BaseRoutes.Users.Handle("", api.ApiHandler(createUser)).Methods("POST") api.BaseRoutes.Users.Handle("", api.ApiSessionRequired(getUsers)).Methods("GET") api.BaseRoutes.Users.Handle("/ids", api.ApiSessionRequired(getUsersByIds)).Methods("POST") diff --git a/api4/webhook.go b/api4/webhook.go index 5146024f7..90e32a891 100644 --- a/api4/webhook.go +++ b/api4/webhook.go @@ -8,15 +8,12 @@ import ( "net/http" "strings" - l4g "github.com/alecthomas/log4go" "github.com/gorilla/mux" "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.IncomingHooks.Handle("", api.ApiSessionRequired(createIncomingHook)).Methods("POST") api.BaseRoutes.IncomingHooks.Handle("", api.ApiSessionRequired(getIncomingHooks)).Methods("GET") api.BaseRoutes.IncomingHook.Handle("", api.ApiSessionRequired(getIncomingHook)).Methods("GET") diff --git a/api4/webrtc.go b/api4/webrtc.go index 9fcc18ff9..978342393 100644 --- a/api4/webrtc.go +++ b/api4/webrtc.go @@ -5,14 +5,9 @@ package api4 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.ApiSessionRequired(webrtcToken)).Methods("GET") } diff --git a/api4/webrtc_test.go b/api4/webrtc_test.go index 660bb6f62..4ad20175e 100644 --- a/api4/webrtc_test.go +++ b/api4/webrtc_test.go @@ -4,8 +4,9 @@ package api4 import ( - "github.com/mattermost/mattermost-server/model" "testing" + + "github.com/mattermost/mattermost-server/model" ) func TestGetWebrtcToken(t *testing.T) { diff --git a/api4/websocket.go b/api4/websocket.go index 6465e49e9..7ea19224b 100644 --- a/api4/websocket.go +++ b/api4/websocket.go @@ -13,8 +13,6 @@ import ( ) func (api *API) InitWebSocket() { - l4g.Debug(utils.T("api.web_socket.init.debug")) - api.BaseRoutes.ApiRoot.Handle("/websocket", api.ApiHandlerTrustRequester(connectWebSocket)).Methods("GET") } -- cgit v1.2.3-1-g7c22