MM-27149: optimize initBasic (#15063)
* MM-27149: optimize initBasic Mostly, all tests just needed the user initialization part and not the channel and group creation. So we move the user initialization inside the Setup call. This avoids unnecessary DB calls which take around 250-300ms on average. And we make the login requests concurrently to shave off a few more ms. According to my tests, the 2 login calls take 140 ms on average, which shaves off 70ms. So approximately, we shave off 350ms per test. And there are 114 occurences of these. So around 39 seconds. * make initlogin only for Setup/SetupEnterprise Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
30bd506e76
Коммит
4a2715974d
@@ -188,7 +188,9 @@ func SetupEnterprise(tb testing.TB) *TestHelper {
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, true, true, nil)
|
||||
th := setupTestHelper(dbStore, searchEngine, true, true, nil)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func Setup(tb testing.TB) *TestHelper {
|
||||
@@ -204,7 +206,9 @@ func Setup(tb testing.TB) *TestHelper {
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, false, true, nil)
|
||||
th := setupTestHelper(dbStore, searchEngine, false, true, nil)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
@@ -220,7 +224,9 @@ func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelpe
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, false, true, updateConfig)
|
||||
th := setupTestHelper(dbStore, searchEngine, false, true, updateConfig)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
@@ -283,7 +289,7 @@ var userCache struct {
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
func (me *TestHelper) InitLogin() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
// create users once and cache them because password hashing is slow
|
||||
@@ -318,9 +324,21 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.BasicUser.Password = "Pa$$word11"
|
||||
me.BasicUser2.Password = "Pa$$word11"
|
||||
|
||||
me.LoginSystemAdmin()
|
||||
me.LoginTeamAdmin()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
me.LoginSystemAdmin()
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
me.LoginTeamAdmin()
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Wait()
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicChannel = me.CreatePublicChannel()
|
||||
me.BasicPrivateChannel = me.CreatePrivateChannel()
|
||||
|
||||
Ссылка в новой задаче
Block a user