[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 удалений

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

@@ -54,6 +54,7 @@ func newServerWithConfig(t *testing.T, f func(cfg *model.Config)) (*Server, erro
}
func TestStartServerSuccess(t *testing.T) {
mainHelper.Parallel(t)
s, err := newServerWithConfig(t, func(cfg *model.Config) {
*cfg.ServiceSettings.ListenAddress = "localhost:0"
})
@@ -70,6 +71,7 @@ func TestStartServerSuccess(t *testing.T) {
}
func TestStartServerPortUnavailable(t *testing.T) {
mainHelper.Parallel(t)
// Listen on the next available port
listener, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
@@ -88,6 +90,7 @@ func TestStartServerPortUnavailable(t *testing.T) {
}
func TestStartServerNoS3Bucket(t *testing.T) {
mainHelper.Parallel(t)
s3Host := os.Getenv("CI_MINIO_HOST")
if s3Host == "" {
s3Host = "localhost"
@@ -140,6 +143,7 @@ func TestStartServerNoS3Bucket(t *testing.T) {
}
func TestStartServerTLSSuccess(t *testing.T) {
mainHelper.Parallel(t)
s, err := newServerWithConfig(t, func(cfg *model.Config) {
testDir, _ := fileutils.FindDir("tests")
@@ -165,6 +169,7 @@ func TestStartServerTLSSuccess(t *testing.T) {
}
func TestStartServerTLSVersion(t *testing.T) {
mainHelper.Parallel(t)
configStore, _ := config.NewMemoryStore()
store, _ := config.NewStoreFromBacking(configStore, nil, false)
cfg := store.Get()
@@ -205,7 +210,6 @@ func TestStartServerTLSVersion(t *testing.T) {
}
err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(s.ListenAddr.Port)+"/")
if err != nil {
t.Errorf("Expected nil, got %s", err)
}
@@ -215,6 +219,7 @@ func TestStartServerTLSVersion(t *testing.T) {
}
func TestStartServerTLSOverwriteCipher(t *testing.T) {
mainHelper.Parallel(t)
s, err := newServerWithConfig(t, func(cfg *model.Config) {
testDir, _ := fileutils.FindDir("tests")
@@ -280,6 +285,7 @@ func checkEndpoint(t *testing.T, client *http.Client, url string) error {
}
func TestPanicLog(t *testing.T) {
mainHelper.Parallel(t)
// Creating a temp dir for log
tmpDir, err := os.MkdirTemp("", "mlog-test")
require.NoError(t, err, "cannot create tmp dir for log file")
@@ -347,8 +353,8 @@ func TestPanicLog(t *testing.T) {
s.Shutdown()
// Checking whether panic was logged
var panicLogged = false
var infoLogged = false
panicLogged := false
infoLogged := false
logFile, err := os.Open(config.GetLogFileLocation(tmpDir))
require.NoError(t, err, "cannot open log file")
@@ -494,6 +500,7 @@ func TestSentry(t *testing.T) {
}
func TestCancelTaskSetsTaskToNil(t *testing.T) {
mainHelper.Parallel(t)
var taskMut sync.Mutex
task := model.CreateRecurringTaskFromNextIntervalTime("a test task", func() {}, 5*time.Minute)
require.NotNil(t, task)
@@ -503,6 +510,7 @@ func TestCancelTaskSetsTaskToNil(t *testing.T) {
}
func TestOriginChecker(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()