* Revert "[MM-41576] Revamp database schema version (#19586)" This reverts commit645fee3fe3. * Revert "MM-42049 - license endpoint not working (#19686)" This reverts commit4fe89e5847.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
eff39010d8
Коммит
a2a78577e9
@@ -550,7 +550,6 @@ type AppIface interface {
|
||||
GetAllTeamsPage(offset int, limit int, opts *model.TeamSearch) ([]*model.Team, *model.AppError)
|
||||
GetAllTeamsPageWithCount(offset int, limit int, opts *model.TeamSearch) (*model.TeamsWithCount, *model.AppError)
|
||||
GetAnalytics(name string, teamID string) (model.AnalyticsRows, *model.AppError)
|
||||
GetAppliedSchemaMigrations() ([]model.AppliedMigration, *model.AppError)
|
||||
GetAudits(userID string, limit int) (model.Audits, *model.AppError)
|
||||
GetAuditsPage(userID string, page int, perPage int) (model.Audits, *model.AppError)
|
||||
GetAuthorizationCode(w http.ResponseWriter, r *http.Request, service string, props map[string]string, loginHint string) (string, *model.AppError)
|
||||
|
||||
@@ -56,7 +56,6 @@ func TestUnitUpdateConfig(t *testing.T) {
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("License").Return(&mockLicenseStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
prev := *th.App.Config().ServiceSettings.SiteURL
|
||||
|
||||
|
||||
@@ -2103,7 +2103,6 @@ func TestMarkChannelAsUnreadFromPostPanic(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("License").Return(&mockLicenseStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ThreadAutoFollow = true
|
||||
@@ -2133,7 +2132,6 @@ func TestClearChannelMembersCache(t *testing.T) {
|
||||
ChannelId: "1",
|
||||
}}, nil)
|
||||
mockStore.On("Channel").Return(&mockChannelStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.ClearChannelMembersCache("channelID")
|
||||
}
|
||||
@@ -2154,7 +2152,6 @@ func TestGetMemberCountsByGroup(t *testing.T) {
|
||||
}
|
||||
mockChannelStore.On("GetMemberCountsByGroup", context.Background(), "channelID", true).Return(cmc, nil)
|
||||
mockStore.On("Channel").Return(&mockChannelStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
resp, err := th.App.GetMemberCountsByGroup(context.Background(), "channelID", true)
|
||||
require.Nil(t, err)
|
||||
require.ElementsMatch(t, cmc, resp)
|
||||
|
||||
@@ -420,11 +420,6 @@ func (a *App) ClientConfigWithComputed() map[string]string {
|
||||
if installationDate, err := a.ch.srv.getSystemInstallDate(); err == nil {
|
||||
respCfg["InstallationDate"] = strconv.FormatInt(installationDate, 10)
|
||||
}
|
||||
if ver, err := a.ch.srv.Store.GetDBSchemaVersion(); err != nil {
|
||||
mlog.Error("Could not get the schema version", mlog.Err(err))
|
||||
} else {
|
||||
respCfg["Version"] = strconv.Itoa(ver)
|
||||
}
|
||||
|
||||
return respCfg
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ func TestClientConfigWithComputed(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
config := th.App.ClientConfigWithComputed()
|
||||
_, ok := config["NoAccounts"]
|
||||
|
||||
@@ -77,7 +77,6 @@ func TestSAMLSettings(t *testing.T) {
|
||||
mockSystemStore.On("GetByName", "UpgradedFromTE").Return(&model.System{Name: "UpgradedFromTE", Value: "false"}, nil)
|
||||
mockSystemStore.On("GetByName", "InstallationDate").Return(&model.System{Name: "InstallationDate", Value: "10"}, nil)
|
||||
mockSystemStore.On("GetByName", "FirstServerRunTimestamp").Return(&model.System{Name: "FirstServerRunTimestamp", Value: "10"}, nil)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
|
||||
@@ -134,6 +134,8 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
|
||||
if enterprise {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
th.App.Srv().Jobs.InitWorkers()
|
||||
th.App.Srv().Jobs.InitSchedulers()
|
||||
} else {
|
||||
th.App.Srv().SetLicense(nil)
|
||||
}
|
||||
|
||||
@@ -177,34 +177,6 @@ func (s *Server) SaveLicense(licenseBytes []byte) (*model.License, *model.AppErr
|
||||
return nil, model.NewAppError("addLicense", model.ExpiredLicenseError, nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.Config().JobSettings.RunJobs && s.Jobs != nil {
|
||||
if err := s.Jobs.StopWorkers(); err != nil && !errors.Is(err, jobs.ErrWorkersNotRunning) {
|
||||
mlog.Warn("Stopping job server workers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
if *s.Config().JobSettings.RunScheduler && s.Jobs != nil {
|
||||
if err := s.Jobs.StopSchedulers(); err != nil && !errors.Is(err, jobs.ErrSchedulersNotRunning) {
|
||||
mlog.Error("Stopping job server schedulers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
// restart job server workers - this handles the edge case where a license file is uploaded, but the job server
|
||||
// doesn't start until the server is restarted, which prevents the 'run job now' buttons in system console from
|
||||
// functioning as expected
|
||||
if *s.Config().JobSettings.RunJobs && s.Jobs != nil {
|
||||
if err := s.Jobs.StartWorkers(); err != nil {
|
||||
mlog.Error("Starting job server workers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
if *s.Config().JobSettings.RunScheduler && s.Jobs != nil {
|
||||
if err := s.Jobs.StartSchedulers(); err != nil && !errors.Is(err, jobs.ErrSchedulersRunning) {
|
||||
mlog.Error("Starting job server schedulers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if ok := s.SetLicense(&license); !ok {
|
||||
return nil, model.NewAppError("addLicense", model.ExpiredLicenseError, nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -236,6 +208,25 @@ func (s *Server) SaveLicense(licenseBytes []byte) (*model.License, *model.AppErr
|
||||
s.ReloadConfig()
|
||||
s.InvalidateAllCaches()
|
||||
|
||||
// restart job server workers - this handles the edge case where a license file is uploaded, but the job server
|
||||
// doesn't start until the server is restarted, which prevents the 'run job now' buttons in system console from
|
||||
// functioning as expected
|
||||
if *s.Config().JobSettings.RunJobs && s.Jobs != nil {
|
||||
if err := s.Jobs.StopWorkers(); err != nil && !errors.Is(err, jobs.ErrWorkersNotRunning) {
|
||||
mlog.Warn("Stopping job server workers failed", mlog.Err(err))
|
||||
}
|
||||
if err := s.Jobs.InitWorkers(); err != nil {
|
||||
mlog.Error("Initializing job server workers failed", mlog.Err(err))
|
||||
} else if err := s.Jobs.StartWorkers(); err != nil {
|
||||
mlog.Error("Starting job server workers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
if *s.Config().JobSettings.RunScheduler && s.Jobs != nil {
|
||||
if err := s.Jobs.StartSchedulers(); err != nil && !errors.Is(err, jobs.ErrSchedulersRunning) {
|
||||
mlog.Error("Starting job server schedulers failed", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
return &license, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -566,7 +566,6 @@ func TestGetPushNotificationMessage(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
Message string
|
||||
@@ -1149,7 +1148,6 @@ func TestClearPushNotificationSync(t *testing.T) {
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("Session").Return(&mockSessionStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.EmailSettings.PushNotificationServer = pushServer.URL
|
||||
@@ -1223,7 +1221,6 @@ func TestUpdateMobileAppBadgeSync(t *testing.T) {
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("Session").Return(&mockSessionStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.EmailSettings.PushNotificationServer = pushServer.URL
|
||||
@@ -1290,7 +1287,6 @@ func TestSendAckToPushProxy(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.EmailSettings.PushNotificationServer = pushServer.URL
|
||||
@@ -1532,7 +1528,6 @@ func BenchmarkPushNotificationThroughput(b *testing.B) {
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("Session").Return(&mockSessionStore)
|
||||
mockStore.On("Preference").Return(&mockPreferenceStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
// create 50 users, each having 2 sessions.
|
||||
type userSession struct {
|
||||
|
||||
@@ -4604,28 +4604,6 @@ func (a *OpenTracingAppLayer) GetAnalytics(name string, teamID string) (model.An
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetAppliedSchemaMigrations() ([]model.AppliedMigration, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAppliedSchemaMigrations")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store.SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetAppliedSchemaMigrations()
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetAudits(userID string, limit int) (model.Audits, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAudits")
|
||||
|
||||
@@ -34,7 +34,6 @@ func TestPluginPublicKeys(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
publicKeyFilename := "test-public-key.plugin.gpg"
|
||||
|
||||
@@ -464,7 +464,6 @@ func TestImageProxy(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.SiteURL = "http://mymattermost.com"
|
||||
|
||||
@@ -32,7 +32,6 @@ func TestNoticeValidation(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("Preference").Return(&mockPreferenceStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
mockSystemStore.On("SaveOrUpdate", &model.System{Name: "ActiveLicenseId", Value: ""}).Return(nil)
|
||||
mockSystemStore.On("GetByName", "UpgradedFromTE").Return(&model.System{Name: "UpgradedFromTE", Value: "false"}, nil)
|
||||
mockSystemStore.On("GetByName", "InstallationDate").Return(&model.System{Name: "InstallationDate", Value: "10"}, nil)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -753,8 +752,8 @@ func (s *Server) Channels() *Channels {
|
||||
|
||||
// Return Database type (postgres or mysql) and current version of Mattermost
|
||||
func (s *Server) DatabaseTypeAndMattermostVersion() (string, string) {
|
||||
schemaVersion, _ := s.Store.GetDBSchemaVersion()
|
||||
return *s.Config().SqlSettings.DriverName, strconv.Itoa(schemaVersion)
|
||||
mattermostVersion, _ := s.Store.System().GetByName("Version")
|
||||
return *s.Config().SqlSettings.DriverName, mattermostVersion.Value
|
||||
}
|
||||
|
||||
// initLogging initializes and configures the logger(s). This may be called more than once.
|
||||
@@ -1880,6 +1879,8 @@ func (ch *Channels) ClientConfigHash() string {
|
||||
|
||||
func (s *Server) initJobs() {
|
||||
s.Jobs = jobs.NewJobServer(s, s.Store, s.Metrics)
|
||||
s.Jobs.InitWorkers()
|
||||
s.Jobs.InitSchedulers()
|
||||
|
||||
if jobsDataRetentionJobInterface != nil {
|
||||
builder := jobsDataRetentionJobInterface(s)
|
||||
@@ -2303,11 +2304,3 @@ func runDNDStatusExpireJob(a *App) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) GetAppliedSchemaMigrations() ([]model.AppliedMigration, *model.AppError) {
|
||||
table, err := a.Srv().Store.GetAppliedMigrations()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetDBSchemaTable", "api.file.read_file.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return table, nil
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ func TestDatabaseTypeAndMattermostVersion(t *testing.T) {
|
||||
|
||||
databaseType, mattermostVersion := th.Server.DatabaseTypeAndMattermostVersion()
|
||||
assert.Equal(t, "postgres", databaseType)
|
||||
assert.GreaterOrEqual(t, mattermostVersion, strconv.Itoa(1))
|
||||
assert.Equal(t, "5.31.0", mattermostVersion)
|
||||
|
||||
os.Setenv("MM_SQLSETTINGS_DRIVERNAME", "mysql")
|
||||
|
||||
@@ -244,7 +244,7 @@ func TestDatabaseTypeAndMattermostVersion(t *testing.T) {
|
||||
|
||||
databaseType, mattermostVersion = th2.Server.DatabaseTypeAndMattermostVersion()
|
||||
assert.Equal(t, "mysql", databaseType)
|
||||
assert.GreaterOrEqual(t, mattermostVersion, strconv.Itoa(1))
|
||||
assert.Equal(t, "5.31.0", mattermostVersion)
|
||||
}
|
||||
|
||||
func TestGenerateSupportPacket(t *testing.T) {
|
||||
|
||||
@@ -125,13 +125,9 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
})
|
||||
|
||||
if enterprise {
|
||||
th.App.Srv().Jobs.StopWorkers()
|
||||
th.App.Srv().Jobs.StopSchedulers()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense())
|
||||
|
||||
th.App.Srv().Jobs.StartWorkers()
|
||||
th.App.Srv().Jobs.StartSchedulers()
|
||||
th.App.Srv().Jobs.InitWorkers()
|
||||
th.App.Srv().Jobs.InitSchedulers()
|
||||
} else {
|
||||
th.App.Srv().SetLicense(nil)
|
||||
}
|
||||
|
||||
@@ -882,7 +882,6 @@ func TestLeaveTeamPanic(t *testing.T) {
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("License").Return(&mockLicenseStore)
|
||||
mockStore.On("Team").Return(&mockTeamStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
team := &model.Team{Id: "myteam"}
|
||||
user := &model.User{Id: "userID"}
|
||||
@@ -1240,7 +1239,6 @@ func TestClearTeamMembersCache(t *testing.T) {
|
||||
TeamId: "1",
|
||||
}}, nil)
|
||||
mockStore.On("Team").Return(&mockTeamStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
th.App.ClearTeamMembersCache("teamID")
|
||||
}
|
||||
|
||||
@@ -161,7 +161,6 @@ func TestHubSessionRevokeRace(t *testing.T) {
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("System").Return(&mockSystemStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
userService, err := users.New(users.ServiceConfig{
|
||||
UserStore: &mockUserStore,
|
||||
|
||||
Ссылка в новой задаче
Block a user