[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1cf2f08108
Коммит
611b2a8e79
@@ -134,6 +134,7 @@ func setupPluginAPITest(t *testing.T, pluginCode string, pluginManifest string,
|
||||
}
|
||||
|
||||
func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -164,6 +165,7 @@ func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUserPreference(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return preferences when called", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -211,6 +213,7 @@ func TestPluginAPIGetUserPreference(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -244,6 +247,7 @@ func TestPluginAPIGetUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIDeleteUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -305,6 +309,7 @@ func TestPluginAPIDeleteUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUpdateUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -356,6 +361,7 @@ func TestPluginAPIUpdateUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).DeleteBots()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -455,6 +461,7 @@ func TestPluginAPIGetUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsersByIds(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).DeleteBots()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -519,6 +526,7 @@ func TestPluginAPIGetUsersByIds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsersInTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -647,6 +655,7 @@ func TestPluginAPIGetUsersInTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUserCustomStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -703,6 +712,7 @@ func TestPluginAPIUserCustomStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -731,6 +741,7 @@ func TestPluginAPIGetFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetFileInfos(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -828,6 +839,7 @@ func TestPluginAPIGetFileInfos(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -871,6 +883,7 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -904,6 +917,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -941,6 +955,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1000,6 +1015,7 @@ func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1036,6 +1052,7 @@ func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallPlugin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// TODO(ilgooz): remove this setup func to use existent setupPluginAPITest().
|
||||
// following setupTest() func is a modified version of setupPluginAPITest().
|
||||
// we need a modified version of setupPluginAPITest() because it wasn't possible to use it directly here
|
||||
@@ -1162,6 +1179,7 @@ func TestInstallPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1193,6 +1211,7 @@ func TestPluginAPIGetTeamIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISetTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1223,6 +1242,7 @@ func TestPluginAPISetTeamIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIRemoveTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1278,6 +1298,7 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
|
||||
// 5. Successfully running test should return nil, "OK". Any other returned string is considered and error
|
||||
|
||||
func TestBasicAPIPlugins(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
defaultSchema := getDefaultPluginSettingsSchema()
|
||||
testFolder := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests")
|
||||
dirs, err := os.ReadDir(testFolder)
|
||||
@@ -1286,6 +1307,8 @@ func TestBasicAPIPlugins(t *testing.T) {
|
||||
d := dir.Name()
|
||||
if dir.IsDir() && !strings.HasPrefix(d, "manual.") {
|
||||
t.Run(d, func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
mainPath := filepath.Join(testFolder, d, "main.go")
|
||||
_, err := os.Stat(mainPath)
|
||||
require.NoError(t, err, "Cannot find plugin main file at %v", mainPath)
|
||||
@@ -1300,6 +1323,7 @@ func TestBasicAPIPlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIKVCompareAndSet(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1396,6 +1420,7 @@ func TestPluginAPIKVCompareAndSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIKVCompareAndDelete(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1448,6 +1473,7 @@ func TestPluginAPIKVCompareAndDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreateBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1469,6 +1495,7 @@ func TestPluginCreateBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreatePostWithUploadedFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1505,6 +1532,7 @@ func TestPluginCreatePostWithUploadedFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreatePostAddsFromPluginProp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1524,6 +1552,7 @@ func TestPluginCreatePostAddsFromPluginProp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1561,6 +1590,7 @@ func TestPluginAPIGetConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1598,6 +1628,7 @@ func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAddUserToChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1610,6 +1641,7 @@ func TestPluginAddUserToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1740,6 +1772,7 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAPIMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1821,6 +1854,7 @@ func TestAPIMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPostsForChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
require := require.New(t)
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -1864,6 +1898,7 @@ func TestPluginAPIGetPostsForChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginHTTPConnHijack(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1983,6 +2018,7 @@ func TestPluginMFAEnforcement(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2054,6 +2090,7 @@ func (mscp *MockSlashCommandProvider) DoCommand(a *App, c request.CTX, args *mod
|
||||
}
|
||||
|
||||
func TestPluginExecuteSlashCommand(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2079,6 +2116,7 @@ func TestPluginExecuteSlashCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2126,6 +2164,7 @@ func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPICreateCommandAndListCommands(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2164,6 +2203,7 @@ func TestPluginAPICreateCommandAndListCommands(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUpdateCommand(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2222,6 +2262,7 @@ func TestPluginAPIIsEnterpriseReady(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginUploadsAPI(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2321,6 +2362,7 @@ func TestPluginUploadsAPI(t *testing.T) {
|
||||
var configurationWillBeSavedHookTemplate string
|
||||
|
||||
func TestConfigurationWillBeSavedHook(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2422,6 +2464,7 @@ func TestConfigurationWillBeSavedHook(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendPushNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
if testing.Short() {
|
||||
t.Skip("skipping TestSendPushNotification test in short mode")
|
||||
}
|
||||
@@ -2519,6 +2562,7 @@ func TestSendPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginServeMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t, StartMetrics)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2577,6 +2621,7 @@ func TestPluginServeMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginGetChannelsForTeamForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2680,6 +2725,7 @@ func TestPluginGetChannelsForTeamForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginPatchChannelMembersNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should be able to set fields for multiple members", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user