[MM-62408] Server Code Coverage with Fully Parallel Tests (#30078)

* TestPool

* Store infra

* Store tests updates

* Bump maximum concurrent postgres connections

* More infra

* channels/jobs

* channels/app

* channels/api4

* Protect i18n from concurrent access

* Replace some use of os.Setenv

* Remove debug

* Lint fixes

* Fix more linting

* Fix test

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix merge

* [MM-62408] Add CI job to generate test coverage (#30284)

* Add CI job to generate test coverage

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix more Setenv usage

* Fix more potential flakyness

* Remove parallelism from flaky test

* Remove conflicting env var

* Fix

* Disable parallelism

* Test atomic covermode

* Disable parallelism

* Enable parallelism

* Add upload coverage step

* Fix codecov.yml

* Add codecov.yml

* Remove redundant workspace field

* Add Parallel() util methods and refactor

* Fix formatting

* More formatting fixes

* Fix reporting
Этот коммит содержится в:
Claudio Costa
2025-05-30 05:58:26 -06:00
коммит произвёл GitHub
родитель 1cf2f08108
Коммит 611b2a8e79
191 изменённых файлов: 2719 добавлений и 496 удалений

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

@@ -15,6 +15,7 @@ import (
)
func TestCreateBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("invalid bot", func(t *testing.T) {
t.Run("relative to user", func(t *testing.T) {
th := Setup(t).InitBasic()
@@ -116,6 +117,7 @@ func TestCreateBot(t *testing.T) {
}
func TestEnsureBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("ensure bot should pass if already exist bot user", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -190,6 +192,7 @@ func TestEnsureBot(t *testing.T) {
}
func TestPatchBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("invalid patch for user", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -306,6 +309,7 @@ func TestPatchBot(t *testing.T) {
}
func TestGetBot(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -376,6 +380,7 @@ func TestGetBot(t *testing.T) {
}
func TestGetBots(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).DeleteBots()
defer th.TearDown()
@@ -586,6 +591,7 @@ func TestGetBots(t *testing.T) {
}
func TestUpdateBotActive(t *testing.T) {
mainHelper.Parallel(t)
t.Run("unknown bot", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -631,6 +637,7 @@ func TestUpdateBotActive(t *testing.T) {
}
func TestPermanentDeleteBot(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -649,6 +656,7 @@ func TestPermanentDeleteBot(t *testing.T) {
}
func TestDisableUserBots(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -710,6 +718,7 @@ func TestDisableUserBots(t *testing.T) {
}
func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -727,7 +736,8 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
Nickname: "nn_sysadmin1",
Password: "hello1",
Username: "un_sysadmin1",
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId,
}
_, err := th.App.CreateUser(th.Context, &sysadmin1)
require.Nil(t, err, "failed to create user")
_, err = th.App.UpdateUserRoles(th.Context, sysadmin1.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
@@ -738,7 +748,8 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
Nickname: "nn_sysadmin2",
Password: "hello1",
Username: "un_sysadmin2",
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId,
}
_, err = th.App.CreateUser(th.Context, &sysadmin2)
require.Nil(t, err, "failed to create user")
_, err = th.App.UpdateUserRoles(th.Context, sysadmin2.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
@@ -846,6 +857,7 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
}
func TestConvertUserToBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("invalid user", func(t *testing.T) {
t.Run("invalid user id", func(t *testing.T) {
th := Setup(t).InitBasic()
@@ -952,6 +964,7 @@ func TestConvertUserToBot(t *testing.T) {
}
func TestGetSystemBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("An error should be returned if there are no sysadmins in the instance", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()