[MM-54318] Add file storage information to support package (#24474)
* Reorder stats in support package struct * Add file storage information to support package * Add clusterID * Change method name to DriverName * Ordering * Fix test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4482ba0fd0
Коммит
b2f36c7cdf
@@ -59,7 +59,36 @@ func (a *App) GenerateSupportPacket() []model.FileData {
|
||||
func (a *App) generateSupportPacketYaml() (*model.FileData, error) {
|
||||
var rErr error
|
||||
|
||||
// Here we are getting information regarding Elastic Search
|
||||
/* DB */
|
||||
|
||||
databaseType, databaseSchemaVersion := a.Srv().DatabaseTypeAndSchemaVersion()
|
||||
databaseVersion, _ := a.Srv().Store().GetDbVersion(false)
|
||||
|
||||
/* Cluster */
|
||||
|
||||
var clusterID string
|
||||
if a.Cluster() != nil {
|
||||
clusterID = a.Cluster().GetClusterId()
|
||||
}
|
||||
|
||||
/* File store */
|
||||
|
||||
fileDriver := a.Srv().Platform().FileBackend().DriverName()
|
||||
fileStatus := model.StatusOk
|
||||
err := a.Srv().Platform().FileBackend().TestConnection()
|
||||
if err != nil {
|
||||
fileStatus = model.StatusFail + ": " + err.Error()
|
||||
}
|
||||
|
||||
/* LDAP */
|
||||
|
||||
var vendorName, vendorVersion string
|
||||
if ldapInterface := a.ch.Ldap; a.ch.Ldap != nil {
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion()
|
||||
}
|
||||
|
||||
/* Elastic Search */
|
||||
|
||||
var elasticServerVersion string
|
||||
var elasticServerPlugins []string
|
||||
if a.Srv().Platform().SearchEngine.ElasticsearchEngine != nil {
|
||||
@@ -67,16 +96,16 @@ func (a *App) generateSupportPacketYaml() (*model.FileData, error) {
|
||||
elasticServerPlugins = a.Srv().Platform().SearchEngine.ElasticsearchEngine.GetPlugins()
|
||||
}
|
||||
|
||||
// Here we are getting information regarding LDAP
|
||||
ldapInterface := a.ch.Ldap
|
||||
var vendorName, vendorVersion string
|
||||
if ldapInterface != nil {
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion()
|
||||
/* License */
|
||||
|
||||
licenseTo := ""
|
||||
supportedUsers := 0
|
||||
if license := a.Srv().License(); license != nil {
|
||||
supportedUsers = *license.Features.Users
|
||||
licenseTo = license.Customer.Company
|
||||
}
|
||||
|
||||
// Here we are getting information regarding the database (mysql/postgres + current schema version)
|
||||
databaseType, databaseSchemaVersion := a.Srv().DatabaseTypeAndSchemaVersion()
|
||||
databaseVersion, _ := a.Srv().Store().GetDbVersion(false)
|
||||
/* Jobs */
|
||||
|
||||
uniqueUserCount, err := a.Srv().Store().User().Count(model.UserCountOptions{})
|
||||
if err != nil {
|
||||
@@ -112,31 +141,42 @@ func (a *App) generateSupportPacketYaml() (*model.FileData, error) {
|
||||
rErr = multierror.Append(errors.Wrap(err, "error while getting migration jobs"))
|
||||
}
|
||||
|
||||
licenseTo := ""
|
||||
supportedUsers := 0
|
||||
if license := a.Srv().License(); license != nil {
|
||||
supportedUsers = *license.Features.Users
|
||||
licenseTo = license.Customer.Company
|
||||
}
|
||||
|
||||
// Creating the struct for support packet yaml file
|
||||
supportPacket := model.SupportPacket{
|
||||
LicenseTo: licenseTo,
|
||||
ServerOS: runtime.GOOS,
|
||||
ServerArchitecture: runtime.GOARCH,
|
||||
ServerVersion: model.CurrentVersion,
|
||||
BuildHash: model.BuildHash,
|
||||
/* Build information */
|
||||
ServerOS: runtime.GOOS,
|
||||
ServerArchitecture: runtime.GOARCH,
|
||||
ServerVersion: model.CurrentVersion,
|
||||
BuildHash: model.BuildHash,
|
||||
|
||||
/* DB */
|
||||
DatabaseType: databaseType,
|
||||
DatabaseVersion: databaseVersion,
|
||||
DatabaseSchemaVersion: databaseSchemaVersion,
|
||||
LdapVendorName: vendorName,
|
||||
LdapVendorVersion: vendorVersion,
|
||||
ElasticServerVersion: elasticServerVersion,
|
||||
ElasticServerPlugins: elasticServerPlugins,
|
||||
ActiveUsers: int(uniqueUserCount),
|
||||
|
||||
/* Cluster */
|
||||
ClusterID: clusterID,
|
||||
|
||||
/* File store */
|
||||
FileDriver: fileDriver,
|
||||
FileStatus: fileStatus,
|
||||
|
||||
/* LDAP */
|
||||
LdapVendorName: vendorName,
|
||||
LdapVendorVersion: vendorVersion,
|
||||
|
||||
/* Elastic Search */
|
||||
ElasticServerVersion: elasticServerVersion,
|
||||
ElasticServerPlugins: elasticServerPlugins,
|
||||
|
||||
/* License */
|
||||
LicenseTo: licenseTo,
|
||||
LicenseSupportedUsers: supportedUsers,
|
||||
|
||||
// Jobs
|
||||
/* Server stats */
|
||||
ActiveUsers: int(uniqueUserCount),
|
||||
|
||||
/* Jobs */
|
||||
DataRetentionJobs: dataRetentionJobs,
|
||||
MessageExportJobs: messageExportJobs,
|
||||
ElasticPostIndexingJobs: elasticPostIndexingJobs,
|
||||
@@ -146,6 +186,8 @@ func (a *App) generateSupportPacketYaml() (*model.FileData, error) {
|
||||
MigrationJobs: migrationJobs,
|
||||
}
|
||||
|
||||
/* Server stats */
|
||||
|
||||
analytics, appErr := a.GetAnalytics("standard", "")
|
||||
if appErr != nil {
|
||||
rErr = multierror.Append(errors.Wrap(appErr, "error while getting analytics"))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app/platform"
|
||||
fmocks "github.com/mattermost/mattermost/server/v8/platform/shared/filestore/mocks"
|
||||
)
|
||||
|
||||
func TestCreatePluginsFile(t *testing.T) {
|
||||
@@ -45,16 +48,42 @@ func TestGenerateSupportPacketYaml(t *testing.T) {
|
||||
license.Features.Users = model.NewInt(licenseUsers)
|
||||
th.App.Srv().SetLicense(license)
|
||||
|
||||
// Happy path where we have a support packet yaml file without any warnings
|
||||
fileData, err := th.App.generateSupportPacketYaml()
|
||||
require.NotNil(t, fileData)
|
||||
assert.Equal(t, "support_packet.yaml", fileData.Filename)
|
||||
assert.Positive(t, len(fileData.Body))
|
||||
assert.NoError(t, err)
|
||||
var packet model.SupportPacket
|
||||
require.NoError(t, yaml.Unmarshal(fileData.Body, &packet))
|
||||
assert.Equal(t, 3, packet.ActiveUsers) // from InitBasic.
|
||||
assert.Equal(t, licenseUsers, packet.LicenseSupportedUsers)
|
||||
t.Run("Happy path", func(t *testing.T) {
|
||||
// Happy path where we have a support packet yaml file without any warnings
|
||||
|
||||
fileData, err := th.App.generateSupportPacketYaml()
|
||||
require.NotNil(t, fileData)
|
||||
assert.Equal(t, "support_packet.yaml", fileData.Filename)
|
||||
assert.Positive(t, len(fileData.Body))
|
||||
assert.NoError(t, err)
|
||||
var packet model.SupportPacket
|
||||
require.NoError(t, yaml.Unmarshal(fileData.Body, &packet))
|
||||
|
||||
assert.Equal(t, 3, packet.ActiveUsers) // from InitBasic.
|
||||
assert.Equal(t, licenseUsers, packet.LicenseSupportedUsers)
|
||||
assert.Empty(t, packet.ClusterID)
|
||||
assert.Equal(t, "local", packet.FileDriver)
|
||||
assert.Equal(t, "OK", packet.FileStatus)
|
||||
})
|
||||
|
||||
t.Run("filestore fails", func(t *testing.T) {
|
||||
fb := &fmocks.FileBackend{}
|
||||
platform.SetFileStore(fb)(th.Server.Platform())
|
||||
fb.On("DriverName").Return("mock")
|
||||
fb.On("TestConnection").Return(errors.New("all broken"))
|
||||
|
||||
fileData, err := th.App.generateSupportPacketYaml()
|
||||
require.NotNil(t, fileData)
|
||||
assert.Equal(t, "support_packet.yaml", fileData.Filename)
|
||||
assert.Positive(t, len(fileData.Body))
|
||||
assert.NoError(t, err)
|
||||
var packet model.SupportPacket
|
||||
require.NoError(t, yaml.Unmarshal(fileData.Body, &packet))
|
||||
|
||||
assert.Equal(t, "mock", packet.FileDriver)
|
||||
assert.Equal(t, "FAIL: all broken", packet.FileStatus)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestGenerateSupportPacket(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user