Revert testing workarounds (#22630)
* Revert "fix store issue take two" This reverts commit 59f943c2c7ff7d88f7b36cc29e242042746e959e. * Revert "fix store override issue" This reverts commit 29c346757aa627c07d357c54991f9188c927dd1a. * Revert "Fix TestPushNotificationRace" This reverts commit 6d62dddf8679e82b02e8ad9fe7513217eef5b4ee. * Revert "fix default DSN for CI" This reverts commit e0e69cdbb0645bb50434f6b5bbd12bead1e7ce1d. * Revert "disable playbooks from more unit tests" This reverts commit a1e97a9e96bdd16537f5b6dbdc8335762617a9e0. * Revert "disable playbooks for more tests" This reverts commit 4d2dc74f05339f0b3cd28b997a2e35ae20f898be. * Revert "disable playbooks for TestSAMLSettings" This reverts commit 35c1a4312d0c6a0a64991520fa5b0892c083e6a1. * Revert "disable playbooks for more unit tests" This reverts commit c049631a1474cddf168b2be8feb24140e0dcfd48. * Revert "disable playbooks for mocked enterprise tests" This reverts commit 829317fddbd0e84866534a5a75e52dcffd2dbde7. * Partially revert "disable playbooks for channel/apps mocked tests" This reverts commit 52b4a0a6cf135d26f53298294ed23734aafae0d2. * Revert "fix TestUnitUpdateConfig" This reverts commit 8f134f2a8ae9765aa2b6f66d6827e10ef1f5109f. * Revert "add plugin mock to TestUnitUpdateConfig" This reverts commit 3ec5419092135f494fd04701b5cbbd15920e667b. * Revert "disable Boards for more test helpers" This reverts commit 5d4d0d02d9cf6f872f0304098c68a01a3aab0fbe. * Revert "disable boards at correct place in test helpers" This reverts commit 0c9e175f79293c8be4289c7424930388f207dc75. * Partially revert "disable boards for slash cmd tests" This reverts commit fad8d9de93f5ce351d2e50fd6448662e75f597ae. * Revert "disable Boards for channels web tests" This reverts commit 15540fdfc09cf927071af718d4ad0b2c58308328. * Revert "Adds a teardown function to playbook server tests to disable and reenable boards" This reverts commit 9a46e3d0f43f66d548994986b8c4029d58ad022f. * Revert "Test disable boards through feature flag" This reverts commit 787044add8ba8e2680a2c3c6ba11e709cebc8705. * TestUnitUpdateConfig: restore callback check * Revert "Revert "fix default DSN for CI"" This reverts commit 01b879d55ad1249265f23c6fd9ceb5d7730ddb3d.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d62244aebb
Коммит
80c1431983
@@ -71,10 +71,8 @@ type TestHelper struct {
|
||||
|
||||
IncludeCacheLayer bool
|
||||
|
||||
LogBuffer *mlog.Buffer
|
||||
TestLogger *mlog.Logger
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
LogBuffer *mlog.Buffer
|
||||
TestLogger *mlog.Logger
|
||||
}
|
||||
|
||||
var mainHelper *testlib.MainHelper
|
||||
@@ -104,17 +102,6 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
|
||||
// disable Boards through the feature flag
|
||||
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
memoryConfig.FeatureFlags.BoardsProduct = false
|
||||
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
if updateConfig != nil {
|
||||
updateConfig(memoryConfig)
|
||||
}
|
||||
@@ -153,15 +140,13 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: app.New(app.ServerConnector(s.Channels())),
|
||||
Server: s,
|
||||
ConfigStore: configStore,
|
||||
IncludeCacheLayer: includeCache,
|
||||
Context: request.EmptyContext(testLogger),
|
||||
TestLogger: testLogger,
|
||||
LogBuffer: buffer,
|
||||
boardsProductEnvValue: boardsProductEnvValue,
|
||||
playbooksDisableEnvValue: playbooksDisableEnvValue,
|
||||
App: app.New(app.ServerConnector(s.Channels())),
|
||||
Server: s,
|
||||
ConfigStore: configStore,
|
||||
IncludeCacheLayer: includeCache,
|
||||
Context: request.EmptyContext(testLogger),
|
||||
TestLogger: testLogger,
|
||||
LogBuffer: buffer,
|
||||
}
|
||||
th.Context.SetLogger(testLogger)
|
||||
|
||||
@@ -386,17 +371,6 @@ func (th *TestHelper) ShutdownApp() {
|
||||
}
|
||||
|
||||
func (th *TestHelper) TearDown() {
|
||||
// reset board and playbooks product setting to original
|
||||
if th.boardsProductEnvValue != "" {
|
||||
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
|
||||
}
|
||||
|
||||
if th.playbooksDisableEnvValue != "" {
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
|
||||
} else {
|
||||
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
|
||||
}
|
||||
|
||||
if th.IncludeCacheLayer {
|
||||
// Clean all the caches
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
@@ -11,8 +11,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/store/storetest/mocks"
|
||||
)
|
||||
|
||||
/* Temporarily comment out until MM-11108
|
||||
@@ -37,9 +39,26 @@ func init() {
|
||||
}
|
||||
|
||||
func TestUnitUpdateConfig(t *testing.T) {
|
||||
th := Setup(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
mockStore := th.App.Srv().Store().(*mocks.Store)
|
||||
mockUserStore := mocks.UserStore{}
|
||||
mockUserStore.On("Count", mock.Anything).Return(int64(10), nil)
|
||||
mockPostStore := mocks.PostStore{}
|
||||
mockPostStore.On("GetMaxPostSize").Return(65535, nil)
|
||||
mockSystemStore := mocks.SystemStore{}
|
||||
mockSystemStore.On("GetByName", "UpgradedFromTE").Return(&model.System{Name: "UpgradedFromTE", Value: "false"}, nil)
|
||||
mockSystemStore.On("GetByName", "InstallationDate").Return(&model.System{Name: "InstallationDate", Value: "10"}, nil)
|
||||
mockSystemStore.On("GetByName", "FirstServerRunTimestamp").Return(&model.System{Name: "FirstServerRunTimestamp", Value: "10"}, nil)
|
||||
mockLicenseStore := mocks.LicenseStore{}
|
||||
mockLicenseStore.On("Get", "").Return(&model.LicenseRecord{}, nil)
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("License").Return(&mockLicenseStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
prev := *th.App.Config().ServiceSettings.SiteURL
|
||||
|
||||
var called int32
|
||||
|
||||
@@ -42,9 +42,7 @@ type TestHelper struct {
|
||||
TestLogger *mlog.Logger
|
||||
IncludeCacheLayer bool
|
||||
|
||||
tempWorkspace string
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
tempWorkspace string
|
||||
}
|
||||
|
||||
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, options []Option, tb testing.TB) *TestHelper {
|
||||
@@ -62,17 +60,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
*memoryConfig.LogSettings.EnableSentry = false // disable error reporting during tests
|
||||
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
|
||||
// disable Boards through the feature flag
|
||||
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
memoryConfig.FeatureFlags.BoardsProduct = false
|
||||
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
configStore.Set(memoryConfig)
|
||||
|
||||
buffer := &mlog.Buffer{}
|
||||
@@ -103,14 +90,12 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: New(ServerConnector(s.Channels())),
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
LogBuffer: buffer,
|
||||
TestLogger: testLogger,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
boardsProductEnvValue: boardsProductEnvValue,
|
||||
playbooksDisableEnvValue: playbooksDisableEnvValue,
|
||||
App: New(ServerConnector(s.Channels())),
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
LogBuffer: buffer,
|
||||
TestLogger: testLogger,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
}
|
||||
th.Context.SetLogger(testLogger)
|
||||
|
||||
@@ -184,10 +169,16 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
|
||||
statusMock.On("UpdateLastActivityAt", "user1", mock.Anything).Return(nil)
|
||||
statusMock.On("SaveOrUpdate", mock.AnythingOfType("*model.Status")).Return(nil)
|
||||
|
||||
pluginMock := mocks.PluginStore{}
|
||||
pluginMock.On("Get", mock.AnythingOfType("string"), mock.AnythingOfType("string")).Return(&model.PluginKeyValue{}, nil)
|
||||
|
||||
emptyMockStore := mocks.Store{}
|
||||
emptyMockStore.On("Close").Return(nil)
|
||||
emptyMockStore.On("Status").Return(&statusMock)
|
||||
emptyMockStore.On("Plugin").Return(&pluginMock).Maybe()
|
||||
th.App.Srv().SetStore(&emptyMockStore)
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -553,17 +544,6 @@ func (th *TestHelper) ShutdownApp() {
|
||||
}
|
||||
|
||||
func (th *TestHelper) TearDown() {
|
||||
// reset board and playbooks product setting to original
|
||||
if th.boardsProductEnvValue != "" {
|
||||
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
|
||||
}
|
||||
|
||||
if th.playbooksDisableEnvValue != "" {
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
|
||||
} else {
|
||||
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
|
||||
}
|
||||
|
||||
if th.IncludeCacheLayer {
|
||||
// Clean all the caches
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
@@ -1445,13 +1445,9 @@ func TestPushNotificationRace(t *testing.T) {
|
||||
Router: mux.NewRouter(),
|
||||
}
|
||||
var err error
|
||||
s.platform, err = platform.New(
|
||||
platform.ServiceConfig{
|
||||
ConfigStore: memoryStore,
|
||||
},
|
||||
platform.SetFileStore(&fmocks.FileBackend{}),
|
||||
platform.StoreOverride(th.GetSqlStore()),
|
||||
)
|
||||
s.platform, err = platform.New(platform.ServiceConfig{
|
||||
ConfigStore: memoryStore,
|
||||
}, platform.SetFileStore(&fmocks.FileBackend{}))
|
||||
s.SetStore(mockStore)
|
||||
require.NoError(t, err)
|
||||
serviceMap := map[product.ServiceKey]any{
|
||||
|
||||
@@ -73,17 +73,15 @@ func (s *Server) initializeProducts(
|
||||
func (s *Server) shouldStart(product string) bool {
|
||||
if product == "boards" {
|
||||
if !s.Config().FeatureFlags.BoardsProduct {
|
||||
s.Log().Info("Skipping Boards init; disabled via feature flag")
|
||||
s.Log().Warn("Skipping boards start: not enabled via feature flag")
|
||||
return false
|
||||
}
|
||||
s.Log().Info("Allowing Boards init; enabled via feature flag")
|
||||
}
|
||||
if product == "playbooks" {
|
||||
if os.Getenv("MM_DISABLE_PLAYBOOKS") == "true" {
|
||||
s.Log().Info("Skipping Playbooks init; disabled via env var")
|
||||
s.Log().Warn("Skipping playbooks start: disabled via env var")
|
||||
return false
|
||||
}
|
||||
s.Log().Info("Allowing Playbooks init; enabled via env var")
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
@@ -36,9 +36,7 @@ type TestHelper struct {
|
||||
TestLogger *mlog.Logger
|
||||
IncludeCacheLayer bool
|
||||
|
||||
tempWorkspace string
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
tempWorkspace string
|
||||
}
|
||||
|
||||
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, tb testing.TB, configSet func(*model.Config)) *TestHelper {
|
||||
@@ -53,17 +51,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
if configSet != nil {
|
||||
configSet(memoryConfig)
|
||||
}
|
||||
|
||||
// disable Boards through the feature flag
|
||||
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
memoryConfig.FeatureFlags.BoardsProduct = false
|
||||
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
|
||||
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
|
||||
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
@@ -95,14 +82,12 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: app.New(app.ServerConnector(s.Channels())),
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
LogBuffer: buffer,
|
||||
TestLogger: testLogger,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
boardsProductEnvValue: boardsProductEnvValue,
|
||||
playbooksDisableEnvValue: playbooksDisableEnvValue,
|
||||
App: app.New(app.ServerConnector(s.Channels())),
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
LogBuffer: buffer,
|
||||
TestLogger: testLogger,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 })
|
||||
@@ -389,17 +374,6 @@ func (th *TestHelper) shutdownApp() {
|
||||
}
|
||||
|
||||
func (th *TestHelper) tearDown() {
|
||||
// reset board and playbooks product setting to original
|
||||
if th.boardsProductEnvValue != "" {
|
||||
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
|
||||
}
|
||||
|
||||
if th.playbooksDisableEnvValue != "" {
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
|
||||
} else {
|
||||
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
|
||||
}
|
||||
|
||||
if th.IncludeCacheLayer {
|
||||
// Clean all the caches
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
@@ -48,9 +48,6 @@ type TestHelper struct {
|
||||
IncludeCacheLayer bool
|
||||
|
||||
TestLogger *mlog.Logger
|
||||
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
}
|
||||
|
||||
func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
@@ -80,17 +77,6 @@ func setupTestHelper(tb testing.TB, includeCacheLayer bool) *TestHelper {
|
||||
*newConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*newConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
*newConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
|
||||
// disable Boards through the feature flag
|
||||
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
|
||||
newConfig.FeatureFlags.BoardsProduct = false
|
||||
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
memoryStore.Set(newConfig)
|
||||
var options []app.Option
|
||||
options = append(options, app.ConfigStore(memoryStore))
|
||||
@@ -148,14 +134,12 @@ func setupTestHelper(tb testing.TB, includeCacheLayer bool) *TestHelper {
|
||||
})
|
||||
|
||||
th := &TestHelper{
|
||||
App: a,
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
Web: web,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
TestLogger: testLogger,
|
||||
boardsProductEnvValue: boardsProductEnvValue,
|
||||
playbooksDisableEnvValue: playbooksDisableEnvValue,
|
||||
App: a,
|
||||
Context: request.EmptyContext(testLogger),
|
||||
Server: s,
|
||||
Web: web,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
TestLogger: testLogger,
|
||||
}
|
||||
th.Context.SetLogger(testLogger)
|
||||
|
||||
@@ -194,17 +178,6 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
||||
}
|
||||
|
||||
func (th *TestHelper) TearDown() {
|
||||
// reset board and playbooks product setting to original
|
||||
if th.boardsProductEnvValue != "" {
|
||||
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
|
||||
}
|
||||
|
||||
if th.playbooksDisableEnvValue != "" {
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
|
||||
} else {
|
||||
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
|
||||
}
|
||||
|
||||
if th.IncludeCacheLayer {
|
||||
// Clean all the caches
|
||||
th.App.Srv().InvalidateAllCaches()
|
||||
|
||||
Ссылка в новой задаче
Block a user