[MM-54132] Use annotated logger for log messages from jobs (#24275)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fcfcbd9909
Коммит
30b12f199b
@@ -10,6 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/client"
|
||||
"github.com/mattermost/mattermost/server/v8/cmd/mmctl/printer"
|
||||
|
||||
@@ -275,16 +276,20 @@ func (s *MmctlE2ETestSuite) TestExportDownloadCmdF() {
|
||||
|
||||
func (s *MmctlE2ETestSuite) TestExportJobShowCmdF() {
|
||||
s.SetupTestHelper().InitBasic()
|
||||
ctx := request.EmptyContext(s.th.App.Log())
|
||||
|
||||
job, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
job.Logger = nil
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
s.Run("MM-T3885 - no permissions", func() {
|
||||
printer.Clean()
|
||||
|
||||
job1, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job1, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
@@ -317,6 +322,7 @@ func (s *MmctlE2ETestSuite) TestExportJobShowCmdF() {
|
||||
|
||||
func (s *MmctlE2ETestSuite) TestExportJobListCmdF() {
|
||||
s.SetupTestHelper().InitBasic()
|
||||
ctx := request.EmptyContext(s.th.App.Log())
|
||||
|
||||
s.Run("MM-T3887 - no permissions", func() {
|
||||
printer.Clean()
|
||||
@@ -356,24 +362,26 @@ func (s *MmctlE2ETestSuite) TestExportJobListCmdF() {
|
||||
cmd.Flags().Int("per-page", perPage, "")
|
||||
cmd.Flags().Bool("all", false, "")
|
||||
|
||||
_, appErr := s.th.App.CreateJob(&model.Job{
|
||||
_, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
job2, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job2, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
job2.Logger = nil
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
job3, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job3, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
job3.Logger = nil
|
||||
|
||||
err := exportJobListCmdF(c, cmd, nil)
|
||||
s.Require().Nil(err)
|
||||
@@ -386,13 +394,14 @@ func (s *MmctlE2ETestSuite) TestExportJobListCmdF() {
|
||||
|
||||
func (s *MmctlE2ETestSuite) TestExportJobCancelCmdF() {
|
||||
s.SetupTestHelper().InitBasic()
|
||||
ctx := request.EmptyContext(s.th.App.Log())
|
||||
|
||||
s.Run("Cancel an export job without permissions", func() {
|
||||
printer.Clean()
|
||||
|
||||
cmd := &cobra.Command{}
|
||||
|
||||
job, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
@@ -421,14 +430,14 @@ func (s *MmctlE2ETestSuite) TestExportJobCancelCmdF() {
|
||||
|
||||
cmd := &cobra.Command{}
|
||||
|
||||
job1, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job1, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
job2, appErr := s.th.App.CreateJob(&model.Job{
|
||||
job2, appErr := s.th.App.CreateJob(ctx, &model.Job{
|
||||
Type: model.JobTypeExportProcess,
|
||||
})
|
||||
s.Require().Nil(appErr)
|
||||
@@ -439,11 +448,11 @@ func (s *MmctlE2ETestSuite) TestExportJobCancelCmdF() {
|
||||
s.Require().Empty(printer.GetErrorLines())
|
||||
|
||||
// Get job1 again to refresh its status
|
||||
job1, appErr = s.th.App.GetJob(job1.Id)
|
||||
job1, appErr = s.th.App.GetJob(ctx, job1.Id)
|
||||
s.Require().Nil(appErr)
|
||||
|
||||
// Get job2 again to ensure its status did not change
|
||||
job2, _ = s.th.App.GetJob(job2.Id)
|
||||
job2, _ = s.th.App.GetJob(ctx, job2.Id)
|
||||
s.Require().Nil(appErr)
|
||||
|
||||
s.Require().Equal(job1.Status, model.JobStatusCanceled)
|
||||
|
||||
Ссылка в новой задаче
Block a user