Этот коммит содержится в:
Ben Schumacher
2021-07-12 20:05:36 +02:00
коммит произвёл Claudio Costa
родитель 953eebdef4
Коммит 97ccf0bdf6
472 изменённых файлов: 9126 добавлений и 9132 удалений

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

@@ -99,7 +99,7 @@ func Setup() *TestHelper {
func (th *TestHelper) InitBasic() *TestHelper {
th.SystemAdminUser = th.CreateUser()
th.App.UpdateUserRoles(th.SystemAdminUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.SYSTEM_ADMIN_ROLE_ID, false)
th.App.UpdateUserRoles(th.SystemAdminUser.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
th.SystemAdminUser, _ = th.App.GetUser(th.SystemAdminUser.Id)
th.BasicTeam = th.CreateTeam()
@@ -123,7 +123,7 @@ func (th *TestHelper) CreateTeam() *model.Team {
DisplayName: "dn_" + id,
Name: "name" + id,
Email: "success+" + id + "@simulator.amazonses.com",
Type: model.TEAM_OPEN,
Type: model.TeamOpen,
}
utils.DisableDebugLogForTest()
@@ -156,7 +156,7 @@ func (th *TestHelper) CreateUser() *model.User {
}
func (th *TestHelper) CreateChannel(team *model.Team) *model.Channel {
return th.createChannel(team, model.CHANNEL_OPEN)
return th.createChannel(team, model.ChannelTypeOpen)
}
func (th *TestHelper) createChannel(team *model.Team, channelType string) *model.Channel {
@@ -250,13 +250,13 @@ func (*TestHelper) ResetRoleMigration() {
mainHelper.GetClusterInterface().SendClearRoleCacheMessage()
if _, err := sqlStore.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.ADVANCED_PERMISSIONS_MIGRATION_KEY}); err != nil {
if _, err := sqlStore.GetMaster().Exec("DELETE from Systems where Name = :Name", map[string]interface{}{"Name": model.AdvancedPermissionsMigrationKey}); err != nil {
panic(err)
}
}
func (th *TestHelper) DeleteAllJobsByTypeAndMigrationKey(jobType string, migrationKey string) {
jobs, err := th.App.Srv().Store.Job().GetAllByType(model.JOB_TYPE_MIGRATIONS)
jobs, err := th.App.Srv().Store.Job().GetAllByType(model.JobTypeMigrations)
if err != nil {
panic(err)
}

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

@@ -17,8 +17,8 @@ const (
MigrationStateInProgress = "in_progress"
MigrationStateCompleted = "completed"
JobDataKeyMigration = "migration_key"
JobDataKeyMigration_LAST_DONE = "last_done"
JobDataKeyMigration = "migration_key"
JobDataKeyMigrationLastDone = "last_done"
)
type MigrationsJobInterfaceImpl struct {
@@ -33,7 +33,7 @@ func init() {
func MakeMigrationsList() []string {
return []string{
model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2,
model.MigrationKeyAdvancedPermissionsPhase2,
}
}
@@ -42,7 +42,7 @@ func GetMigrationState(migration string, store store.Store) (string, *model.Job,
return MigrationStateCompleted, nil, nil
}
jobs, err := store.Job().GetAllByType(model.JOB_TYPE_MIGRATIONS)
jobs, err := store.Job().GetAllByType(model.JobTypeMigrations)
if err != nil {
return "", nil, model.NewAppError("GetMigrationState", "app.job.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -54,7 +54,7 @@ func GetMigrationState(migration string, store store.Store) (string, *model.Job,
}
switch job.Status {
case model.JOB_STATUS_IN_PROGRESS, model.JOB_STATUS_PENDING:
case model.JobStatusInProgress, model.JobStatusPending:
return MigrationStateInProgress, job, nil
default:
return MigrationStateUnscheduled, job, nil

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

@@ -21,7 +21,7 @@ func TestGetMigrationState(t *testing.T) {
migrationKey := model.NewId()
th.DeleteAllJobsByTypeAndMigrationKey(model.JOB_TYPE_MIGRATIONS, migrationKey)
th.DeleteAllJobsByTypeAndMigrationKey(model.JobTypeMigrations, migrationKey)
// Test with no job yet.
state, job, err := GetMigrationState(migrationKey, th.App.Srv().Store)
@@ -52,8 +52,8 @@ func TestGetMigrationState(t *testing.T) {
Data: map[string]string{
JobDataKeyMigration: migrationKey,
},
Status: model.JOB_STATUS_PENDING,
Type: model.JOB_TYPE_MIGRATIONS,
Status: model.JobStatusPending,
Type: model.JobTypeMigrations,
}
j1, nErr = th.App.Srv().Store.Job().Save(j1)
@@ -71,8 +71,8 @@ func TestGetMigrationState(t *testing.T) {
Data: map[string]string{
JobDataKeyMigration: migrationKey,
},
Status: model.JOB_STATUS_IN_PROGRESS,
Type: model.JOB_TYPE_MIGRATIONS,
Status: model.JobStatusInProgress,
Type: model.JobTypeMigrations,
}
j2, nErr = th.App.Srv().Store.Job().Save(j2)
@@ -90,8 +90,8 @@ func TestGetMigrationState(t *testing.T) {
Data: map[string]string{
JobDataKeyMigration: migrationKey,
},
Status: model.JOB_STATUS_ERROR,
Type: model.JOB_TYPE_MIGRATIONS,
Status: model.JobStatusError,
Type: model.JobTypeMigrations,
}
j3, nErr = th.App.Srv().Store.Job().Save(j3)

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

@@ -29,7 +29,7 @@ func (scheduler *Scheduler) Name() string {
}
func (scheduler *Scheduler) JobType() string {
return model.JOB_TYPE_MIGRATIONS
return model.JobTypeMigrations
}
func (scheduler *Scheduler) Enabled(_ *model.Config) bool {
@@ -95,15 +95,15 @@ func (scheduler *Scheduler) ScheduleJob(cfg *model.Config, pendingJobs bool, las
func (scheduler *Scheduler) createJob(migrationKey string, lastJob *model.Job) (*model.Job, *model.AppError) {
var lastDone string
if lastJob != nil {
lastDone = lastJob.Data[JobDataKeyMigration_LAST_DONE]
lastDone = lastJob.Data[JobDataKeyMigrationLastDone]
}
data := map[string]string{
JobDataKeyMigration: migrationKey,
JobDataKeyMigration_LAST_DONE: lastDone,
JobDataKeyMigration: migrationKey,
JobDataKeyMigrationLastDone: lastDone,
}
job, err := scheduler.srv.Jobs.CreateJob(model.JOB_TYPE_MIGRATIONS, data)
job, err := scheduler.srv.Jobs.CreateJob(model.JobTypeMigrations, data)
if err != nil {
return nil, err
}

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

@@ -100,7 +100,7 @@ func (worker *Worker) DoJob(job *model.Job) {
return
case <-time.After(TimeBetweenBatches * time.Millisecond):
done, progress, err := worker.runMigration(job.Data[JobDataKeyMigration], job.Data[JobDataKeyMigration_LAST_DONE])
done, progress, err := worker.runMigration(job.Data[JobDataKeyMigration], job.Data[JobDataKeyMigrationLastDone])
if err != nil {
mlog.Error("Worker: Failed to run migration", mlog.String("worker", worker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
worker.setJobError(job, err)
@@ -110,7 +110,7 @@ func (worker *Worker) DoJob(job *model.Job) {
worker.setJobSuccess(job)
return
} else {
job.Data[JobDataKeyMigration_LAST_DONE] = progress
job.Data[JobDataKeyMigrationLastDone] = progress
if err := worker.srv.Jobs.UpdateInProgressJobData(job); err != nil {
mlog.Error("Worker: Failed to update migration status data for job", mlog.String("worker", worker.name), mlog.String("job_id", job.Id), mlog.String("error", err.Error()))
worker.setJobError(job, err)
@@ -150,7 +150,7 @@ func (worker *Worker) runMigration(key string, lastDone string) (bool, string, *
var err *model.AppError
switch key {
case model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2:
case model.MigrationKeyAdvancedPermissionsPhase2:
done, progress, err = worker.runAdvancedPermissionsPhase2Migration(lastDone)
default:
return false, "", model.NewAppError("MigrationsWorker.runMigration", "migrations.worker.run_migration.unknown_key", map[string]interface{}{"key": key}, "", http.StatusInternalServerError)