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
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetPing(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("basic ping", func(t *testing.T) {
|
||||
@@ -66,7 +66,7 @@ func TestGetPing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestGetAudits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEmailTest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestEmailTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSiteURLTest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -189,7 +189,7 @@ func TestSiteURLTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDatabaseRecycle(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -212,7 +212,7 @@ func TestDatabaseRecycle(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInvalidateCaches(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -238,7 +238,7 @@ func TestInvalidateCaches(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLogs(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
@@ -272,7 +272,7 @@ func TestGetLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostLog(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -381,7 +381,7 @@ func TestGetAnalyticsOld(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestS3TestConnection(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -450,7 +450,7 @@ func TestS3TestConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSupportedTimezones(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -473,7 +473,7 @@ func TestRedirectLocation(t *testing.T) {
|
||||
|
||||
mockBitlyLink := testServer.URL
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
|
||||
@@ -518,7 +518,7 @@ func TestRedirectLocation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
const secs = 30
|
||||
@@ -539,7 +539,7 @@ func TestSetServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetServerBusyInvalidParam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
@@ -554,7 +554,7 @@ func TestSetServerBusyInvalidParam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClearServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -575,7 +575,7 @@ func TestClearServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -594,7 +594,7 @@ func TestGetServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetServerBusyExpires(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -612,7 +612,7 @@ func TestGetServerBusyExpires(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServerBusy503(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -651,7 +651,7 @@ func TestServerBusy503(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPushNotificationAck(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
api := Init(th.Server, th.Server.AppOptions, th.Server.Router)
|
||||
session, _ := th.App.GetSession(th.Client.AuthToken)
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user