MM-34171: Fix racy test TestSentry (#17215)

* MM-34171: Fix racy test TestSentry

The NewServer call sets the global mlog Info variable.
But before that, if we call UpdateConfig with the functional options,
then the store.Set method will call mlog.Info before
it could be set.

To fix that, we prepare the updated config
and pass that directly to NewServer to avoid
having to call UpdateConfig.

https://mattermost.atlassian.net/browse/MM-34171

```release-note
NONE
```

* disable watcher

* Trying yet again

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2021-03-25 08:50:55 +05:30
коммит произвёл GitHub
родитель f60b7437da
Коммит 1578e25537

Просмотреть файл

@@ -607,20 +607,19 @@ func TestSentry(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
SentryDSN = dsn.String() SentryDSN = dsn.String()
s, err := NewServer(func(server *Server) error { configStore, _ := config.NewMemoryStore()
configStore, _ := config.NewFileStore("config.json", true)
store, _ := config.NewStoreFromBacking(configStore, nil, false) store, _ := config.NewStoreFromBacking(configStore, nil, false)
server.configStore = store cfg := store.Get()
server.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ListenAddress = ":0" *cfg.ServiceSettings.ListenAddress = ":0"
*cfg.LogSettings.EnableSentry = false *cfg.LogSettings.EnableSentry = false
*cfg.ServiceSettings.ConnectionSecurity = "TLS" *cfg.ServiceSettings.ConnectionSecurity = "TLS"
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem") *cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem") *cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
*cfg.LogSettings.EnableDiagnostics = true *cfg.LogSettings.EnableDiagnostics = true
})
return nil store.Set(cfg)
})
s, err := NewServer(ConfigStore(store))
require.NoError(t, err) require.NoError(t, err)
// Route for just panicing // Route for just panicing
@@ -658,20 +657,19 @@ func TestSentry(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
SentryDSN = dsn.String() SentryDSN = dsn.String()
s, err := NewServer(func(server *Server) error { configStore, _ := config.NewMemoryStore()
configStore, _ := config.NewFileStore("config.json", true)
store, _ := config.NewStoreFromBacking(configStore, nil, false) store, _ := config.NewStoreFromBacking(configStore, nil, false)
server.configStore = store cfg := store.Get()
server.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ListenAddress = ":0" *cfg.ServiceSettings.ListenAddress = ":0"
*cfg.ServiceSettings.ConnectionSecurity = "TLS" *cfg.ServiceSettings.ConnectionSecurity = "TLS"
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem") *cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem") *cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
*cfg.LogSettings.EnableSentry = true *cfg.LogSettings.EnableSentry = true
*cfg.LogSettings.EnableDiagnostics = true *cfg.LogSettings.EnableDiagnostics = true
})
return nil store.Set(cfg)
})
s, err := NewServer(ConfigStore(store))
require.NoError(t, err) require.NoError(t, err)
// Route for just panicing // Route for just panicing