[MM-54132] Use annotated logger for log messages from jobs (#24275)

Этот коммит содержится в:
Ben Schumacher
2023-09-07 08:50:22 +02:00
коммит произвёл GitHub
родитель fcfcbd9909
Коммит 30b12f199b
120 изменённых файлов: 1064 добавлений и 1111 удалений

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

@@ -7,7 +7,10 @@ import (
"testing"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/v8/channels/store"
"github.com/stretchr/testify/require"
)
func Setup(tb testing.TB) store.Store {
@@ -16,17 +19,15 @@ func Setup(tb testing.TB) store.Store {
return store
}
func deleteAllJobsByTypeAndMigrationKey(store store.Store, jobType string, migrationKey string) {
jobs, err := store.Job().GetAllByType(model.JobTypeMigrations)
if err != nil {
panic(err)
}
func deleteAllJobsByTypeAndMigrationKey(t *testing.T, store store.Store, jobType string, migrationKey string) {
ctx := request.EmptyContext(mlog.CreateConsoleTestLogger(t))
jobs, err := store.Job().GetAllByType(ctx, model.JobTypeMigrations)
require.NoError(t, err)
for _, job := range jobs {
if key, ok := job.Data[JobDataKeyMigration]; ok && key == migrationKey {
if _, err = store.Job().Delete(job.Id); err != nil {
panic(err)
}
_, err = store.Job().Delete(job.Id)
require.NoError(t, err)
}
}
}