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

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

@@ -37,6 +37,7 @@ import (
)
func TestPreparePostListForClient(t *testing.T) {
mainHelper.Parallel(t)
// Most of this logic is covered by TestPreparePostForClient, so this just tests handling of multiple posts
th := Setup(t)
@@ -68,6 +69,7 @@ func TestPreparePostListForClient(t *testing.T) {
}
func TestPreparePostForClient(t *testing.T) {
mainHelper.Parallel(t)
var serverURL string
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
@@ -862,6 +864,7 @@ func TestPreparePostForClient(t *testing.T) {
}
func TestPreparePostForClientWithImageProxy(t *testing.T) {
mainHelper.Parallel(t)
setup := func(t *testing.T) *TestHelper {
th := Setup(t).InitBasic()
@@ -981,6 +984,7 @@ func testProxyOpenGraphImage(t *testing.T, th *TestHelper, shouldProxy bool) {
}
func TestGetEmbedForPost(t *testing.T) {
mainHelper.Parallel(t)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/index.html" {
w.Header().Set("Content-Type", "text/html")
@@ -1157,6 +1161,7 @@ func TestGetEmbedForPost(t *testing.T) {
}
func TestGetImagesForPost(t *testing.T) {
mainHelper.Parallel(t)
t.Run("with an image link", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -1445,6 +1450,7 @@ func TestGetImagesForPost(t *testing.T) {
}
func TestGetEmojiNamesForString(t *testing.T) {
mainHelper.Parallel(t)
testCases := []struct {
Description string
Input string
@@ -1496,6 +1502,7 @@ func TestGetEmojiNamesForString(t *testing.T) {
}
func TestGetEmojiNamesForPost(t *testing.T) {
mainHelper.Parallel(t)
testCases := []struct {
Description string
Post *model.Post
@@ -1591,6 +1598,7 @@ func TestGetEmojiNamesForPost(t *testing.T) {
}
func TestGetCustomEmojisForPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1670,6 +1678,7 @@ func TestGetCustomEmojisForPost(t *testing.T) {
}
func TestGetFirstLinkAndImages(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1838,6 +1847,7 @@ func TestGetFirstLinkAndImages(t *testing.T) {
}
func TestGetImagesInMessageAttachments(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2623,6 +2633,7 @@ func TestGetLinkMetadata(t *testing.T) {
}
func TestResolveMetadataURL(t *testing.T) {
mainHelper.Parallel(t)
for _, test := range []struct {
Name string
RequestURL string
@@ -2664,6 +2675,7 @@ func TestResolveMetadataURL(t *testing.T) {
}
func TestParseLinkMetadata(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -2760,6 +2772,7 @@ func TestParseLinkMetadata(t *testing.T) {
}
func TestParseImages(t *testing.T) {
mainHelper.Parallel(t)
for name, testCase := range map[string]struct {
FileName string
Expected *model.PostImage
@@ -2879,6 +2892,7 @@ func TestParseImages(t *testing.T) {
}
func TestLooksLikeAPermalink(t *testing.T) {
mainHelper.Parallel(t)
const siteURLWithSubpath = "http://localhost:8065/foo"
const siteURLWithTrailingSlash = "http://test.com/"
const siteURL = "http://test.com"
@@ -2910,6 +2924,7 @@ func TestLooksLikeAPermalink(t *testing.T) {
}
func TestContainsPermalink(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -2949,6 +2964,7 @@ func TestContainsPermalink(t *testing.T) {
}
func TestSanitizePostMetadataForUserAndChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3073,6 +3089,7 @@ func TestSanitizePostMetadataForUserAndChannel(t *testing.T) {
}
func TestSanitizePostMetaDataForAudit(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3125,6 +3142,7 @@ func TestSanitizePostMetaDataForAudit(t *testing.T) {
}
func TestSanitizePostMetadataForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()