Removing unnecesary unnused old layered store (#12999)

This commit is contained in:
Jesús Espino
2019-11-06 12:43:41 +01:00
committed by GitHub
parent a85c653f87
commit 8febdcf2b8
13 changed files with 138 additions and 1130 deletions

View File

@@ -61,7 +61,7 @@ func (s *Server) RunOldAppInitalization() error {
if s.FakeApp().Srv.newStore == nil {
s.FakeApp().Srv.newStore = func() store.Store {
return store.NewTimerLayer(localcachelayer.NewLocalCacheLayer(store.NewLayeredStore(sqlstore.NewSqlSupplier(s.FakeApp().Config().SqlSettings, s.Metrics), s.Metrics, s.Cluster), s.Metrics, s.Cluster), s.Metrics)
return store.NewTimerLayer(localcachelayer.NewLocalCacheLayer(sqlstore.NewSqlSupplier(s.FakeApp().Config().SqlSettings, s.Metrics), s.Metrics, s.Cluster), s.Metrics)
}
}

View File

@@ -1,203 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
import (
"context"
"github.com/mattermost/mattermost-server/einterfaces"
)
type LayeredStoreDatabaseLayer interface {
LayeredStoreSupplier
Store
}
type LayeredStore struct {
TmpContext context.Context
DatabaseLayer LayeredStoreDatabaseLayer
LocalCacheLayer *LocalCacheSupplier
LayerChainHead LayeredStoreSupplier
}
func NewLayeredStore(db LayeredStoreDatabaseLayer, metrics einterfaces.MetricsInterface, cluster einterfaces.ClusterInterface) Store {
store := &LayeredStore{
TmpContext: context.TODO(),
DatabaseLayer: db,
LocalCacheLayer: NewLocalCacheSupplier(metrics, cluster),
}
// Setup the chain
store.LocalCacheLayer.SetChainNext(store.DatabaseLayer)
store.LayerChainHead = store.LocalCacheLayer
return store
}
type QueryFunction func(LayeredStoreSupplier) *LayeredStoreSupplierResult
func (s *LayeredStore) GetCurrentSchemaVersion() string {
return s.DatabaseLayer.GetCurrentSchemaVersion()
}
func (s *LayeredStore) Team() TeamStore {
return s.DatabaseLayer.Team()
}
func (s *LayeredStore) Channel() ChannelStore {
return s.DatabaseLayer.Channel()
}
func (s *LayeredStore) Post() PostStore {
return s.DatabaseLayer.Post()
}
func (s *LayeredStore) User() UserStore {
return s.DatabaseLayer.User()
}
func (s *LayeredStore) Bot() BotStore {
return s.DatabaseLayer.Bot()
}
func (s *LayeredStore) Audit() AuditStore {
return s.DatabaseLayer.Audit()
}
func (s *LayeredStore) ClusterDiscovery() ClusterDiscoveryStore {
return s.DatabaseLayer.ClusterDiscovery()
}
func (s *LayeredStore) Compliance() ComplianceStore {
return s.DatabaseLayer.Compliance()
}
func (s *LayeredStore) Session() SessionStore {
return s.DatabaseLayer.Session()
}
func (s *LayeredStore) OAuth() OAuthStore {
return s.DatabaseLayer.OAuth()
}
func (s *LayeredStore) System() SystemStore {
return s.DatabaseLayer.System()
}
func (s *LayeredStore) Webhook() WebhookStore {
return s.DatabaseLayer.Webhook()
}
func (s *LayeredStore) Command() CommandStore {
return s.DatabaseLayer.Command()
}
func (s *LayeredStore) CommandWebhook() CommandWebhookStore {
return s.DatabaseLayer.CommandWebhook()
}
func (s *LayeredStore) Preference() PreferenceStore {
return s.DatabaseLayer.Preference()
}
func (s *LayeredStore) License() LicenseStore {
return s.DatabaseLayer.License()
}
func (s *LayeredStore) Token() TokenStore {
return s.DatabaseLayer.Token()
}
func (s *LayeredStore) Emoji() EmojiStore {
return s.DatabaseLayer.Emoji()
}
func (s *LayeredStore) Status() StatusStore {
return s.DatabaseLayer.Status()
}
func (s *LayeredStore) FileInfo() FileInfoStore {
return s.DatabaseLayer.FileInfo()
}
func (s *LayeredStore) Reaction() ReactionStore {
return s.DatabaseLayer.Reaction()
}
func (s *LayeredStore) Job() JobStore {
return s.DatabaseLayer.Job()
}
func (s *LayeredStore) UserAccessToken() UserAccessTokenStore {
return s.DatabaseLayer.UserAccessToken()
}
func (s *LayeredStore) ChannelMemberHistory() ChannelMemberHistoryStore {
return s.DatabaseLayer.ChannelMemberHistory()
}
func (s *LayeredStore) Plugin() PluginStore {
return s.DatabaseLayer.Plugin()
}
func (s *LayeredStore) Role() RoleStore {
return s.DatabaseLayer.Role()
}
func (s *LayeredStore) TermsOfService() TermsOfServiceStore {
return s.DatabaseLayer.TermsOfService()
}
func (s *LayeredStore) UserTermsOfService() UserTermsOfServiceStore {
return s.DatabaseLayer.UserTermsOfService()
}
func (s *LayeredStore) Scheme() SchemeStore {
return s.DatabaseLayer.Scheme()
}
func (s *LayeredStore) Group() GroupStore {
return s.DatabaseLayer.Group()
}
func (s *LayeredStore) LinkMetadata() LinkMetadataStore {
return s.DatabaseLayer.LinkMetadata()
}
func (s *LayeredStore) MarkSystemRanUnitTests() {
s.DatabaseLayer.MarkSystemRanUnitTests()
}
func (s *LayeredStore) Close() {
s.DatabaseLayer.Close()
}
func (s *LayeredStore) LockToMaster() {
s.DatabaseLayer.LockToMaster()
}
func (s *LayeredStore) UnlockFromMaster() {
s.DatabaseLayer.UnlockFromMaster()
}
func (s *LayeredStore) DropAllTables() {
defer s.LocalCacheLayer.Invalidate()
s.DatabaseLayer.DropAllTables()
}
func (s *LayeredStore) TotalMasterDbConnections() int {
return s.DatabaseLayer.TotalMasterDbConnections()
}
func (s *LayeredStore) TotalReadDbConnections() int {
return s.DatabaseLayer.TotalReadDbConnections()
}
func (s *LayeredStore) TotalSearchDbConnections() int {
return s.DatabaseLayer.TotalSearchDbConnections()
}
func (s *LayeredStore) CheckIntegrity() <-chan IntegrityCheckResult {
return s.DatabaseLayer.CheckIntegrity()
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
type LayeredStoreHint int
const (
LSH_NO_CACHE LayeredStoreHint = iota
LSH_MASTER_ONLY
)

View File

@@ -1,20 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
type LayeredStoreSupplierResult struct {
StoreResult
}
func NewSupplierResult() *LayeredStoreSupplierResult {
return &LayeredStoreSupplierResult{}
}
type LayeredStoreSupplier interface {
//
// Control
//
SetChainNext(LayeredStoreSupplier)
Next() LayeredStoreSupplier
}

View File

@@ -1,83 +0,0 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
import (
"context"
"github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model"
)
const (
CLEAR_CACHE_MESSAGE_DATA = ""
)
type LocalCacheSupplier struct {
next LayeredStoreSupplier
metrics einterfaces.MetricsInterface
cluster einterfaces.ClusterInterface
}
// Caching Interface
type ObjectCache interface {
AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64)
AddWithDefaultExpires(key, value interface{})
Purge()
Get(key interface{}) (value interface{}, ok bool)
Remove(key interface{})
Len() int
Name() string
GetInvalidateClusterEvent() string
}
func NewLocalCacheSupplier(metrics einterfaces.MetricsInterface, cluster einterfaces.ClusterInterface) *LocalCacheSupplier {
supplier := &LocalCacheSupplier{
metrics: metrics,
cluster: cluster,
}
return supplier
}
func (s *LocalCacheSupplier) SetChainNext(next LayeredStoreSupplier) {
s.next = next
}
func (s *LocalCacheSupplier) Next() LayeredStoreSupplier {
return s.next
}
func (s *LocalCacheSupplier) doStandardAddToCache(ctx context.Context, cache ObjectCache, key string, result *LayeredStoreSupplierResult, hints ...LayeredStoreHint) {
if result.Err == nil && result.Data != nil {
cache.AddWithDefaultExpires(key, result.Data)
}
}
func (s *LocalCacheSupplier) doInvalidateCacheCluster(cache ObjectCache, key string) {
cache.Remove(key)
if s.cluster != nil {
msg := &model.ClusterMessage{
Event: cache.GetInvalidateClusterEvent(),
SendType: model.CLUSTER_SEND_BEST_EFFORT,
Data: key,
}
s.cluster.SendClusterMessage(msg)
}
}
func (s *LocalCacheSupplier) doClearCacheCluster(cache ObjectCache) {
cache.Purge()
if s.cluster != nil {
msg := &model.ClusterMessage{
Event: cache.GetInvalidateClusterEvent(),
SendType: model.CLUSTER_SEND_BEST_EFFORT,
Data: CLEAR_CACHE_MESSAGE_DATA,
}
s.cluster.SendClusterMessage(msg)
}
}
func (s *LocalCacheSupplier) Invalidate() {
}

View File

@@ -58,7 +58,7 @@ func initStores() {
go func() {
defer wg.Done()
st.SqlSupplier = sqlstore.NewSqlSupplier(*st.SqlSettings, nil)
st.Store = NewLocalCacheLayer(store.NewLayeredStore(st.SqlSupplier, nil, nil), nil, nil)
st.Store = NewLocalCacheLayer(st.SqlSupplier, nil, nil)
st.Store.DropAllTables()
st.Store.MarkSystemRanUnitTests()
}()

View File

@@ -362,7 +362,7 @@ func TestCheckIntegrity(t *testing.T) {
func TestCheckParentChildIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
t.Run("should receive an error", func(t *testing.T) {
config := relationalCheckConfig{
parentName: "NotValid",
@@ -379,7 +379,7 @@ func TestCheckParentChildIntegrity(t *testing.T) {
func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -407,7 +407,7 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -437,7 +437,7 @@ func TestCheckChannelsChannelMemberHistoryIntegrity(t *testing.T) {
func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -465,7 +465,7 @@ func TestCheckChannelsChannelMembersIntegrity(t *testing.T) {
func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -493,7 +493,7 @@ func TestCheckChannelsIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -523,7 +523,7 @@ func TestCheckChannelsOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckChannelsPostsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -550,7 +550,7 @@ func TestCheckChannelsPostsIntegrity(t *testing.T) {
func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -578,7 +578,7 @@ func TestCheckCommandsCommandWebhooksIntegrity(t *testing.T) {
func TestCheckPostsFileInfoIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -605,7 +605,7 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -637,7 +637,7 @@ func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -667,7 +667,7 @@ func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
func TestCheckPostsReactionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -694,7 +694,7 @@ func TestCheckPostsReactionsIntegrity(t *testing.T) {
func TestCheckSchemesChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -725,7 +725,7 @@ func TestCheckSchemesChannelsIntegrity(t *testing.T) {
func TestCheckSchemesTeamsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -756,7 +756,7 @@ func TestCheckSchemesTeamsIntegrity(t *testing.T) {
func TestCheckSessionsAuditsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -787,7 +787,7 @@ func TestCheckSessionsAuditsIntegrity(t *testing.T) {
func TestCheckTeamsChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -814,7 +814,7 @@ func TestCheckTeamsChannelsIntegrity(t *testing.T) {
func TestCheckTeamsCommandsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -842,7 +842,7 @@ func TestCheckTeamsCommandsIntegrity(t *testing.T) {
func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -870,7 +870,7 @@ func TestCheckTeamsIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -898,7 +898,7 @@ func TestCheckTeamsOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -926,7 +926,7 @@ func TestCheckTeamsTeamMembersIntegrity(t *testing.T) {
func TestCheckUsersAuditsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -956,7 +956,7 @@ func TestCheckUsersAuditsIntegrity(t *testing.T) {
func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -984,7 +984,7 @@ func TestCheckUsersCommandWebhooksIntegrity(t *testing.T) {
func TestCheckUsersChannelsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1011,7 +1011,7 @@ func TestCheckUsersChannelsIntegrity(t *testing.T) {
func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1041,7 +1041,7 @@ func TestCheckUsersChannelMemberHistoryIntegrity(t *testing.T) {
func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1071,7 +1071,7 @@ func TestCheckUsersChannelMembersIntegrity(t *testing.T) {
func TestCheckUsersCommandsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1099,7 +1099,7 @@ func TestCheckUsersCommandsIntegrity(t *testing.T) {
func TestCheckUsersCompliancesIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1129,7 +1129,7 @@ func TestCheckUsersCompliancesIntegrity(t *testing.T) {
func TestCheckUsersEmojiIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1159,7 +1159,7 @@ func TestCheckUsersEmojiIntegrity(t *testing.T) {
func TestCheckUsersFileInfoIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1188,7 +1188,7 @@ func TestCheckUsersFileInfoIntegrity(t *testing.T) {
func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1216,7 +1216,7 @@ func TestCheckUsersIncomingWebhooksIntegrity(t *testing.T) {
func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1246,7 +1246,7 @@ func TestCheckUsersOAuthAccessDataIntegrity(t *testing.T) {
func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1276,7 +1276,7 @@ func TestCheckUsersOAuthAppsIntegrity(t *testing.T) {
func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1306,7 +1306,7 @@ func TestCheckUsersOAuthAuthDataIntegrity(t *testing.T) {
func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1334,7 +1334,7 @@ func TestCheckUsersOutgoingWebhooksIntegrity(t *testing.T) {
func TestCheckUsersPostsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1361,7 +1361,7 @@ func TestCheckUsersPostsIntegrity(t *testing.T) {
func TestCheckUsersPreferencesIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1390,7 +1390,7 @@ func TestCheckUsersPreferencesIntegrity(t *testing.T) {
func TestCheckUsersReactionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1419,7 +1419,7 @@ func TestCheckUsersReactionsIntegrity(t *testing.T) {
func TestCheckUsersSessionsIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1447,7 +1447,7 @@ func TestCheckUsersSessionsIntegrity(t *testing.T) {
func TestCheckUsersStatusIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1476,7 +1476,7 @@ func TestCheckUsersStatusIntegrity(t *testing.T) {
func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
@@ -1506,7 +1506,7 @@ func TestCheckUsersTeamMembersIntegrity(t *testing.T) {
func TestCheckUsersUserAccessTokensIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
supplier := ss.(*store.LayeredStore).DatabaseLayer.(*SqlSupplier)
supplier := ss.(*SqlSupplier)
dbmap := supplier.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {

View File

@@ -70,7 +70,7 @@ func initStores() {
go func() {
defer wg.Done()
st.SqlSupplier = NewSqlSupplier(*st.SqlSettings, nil)
st.Store = store.NewLayeredStore(st.SqlSupplier, nil, nil)
st.Store = st.SqlSupplier
st.Store.DropAllTables()
st.Store.MarkSystemRanUnitTests()
}()

View File

@@ -67,7 +67,7 @@ const (
EXIT_DOES_COLUMN_EXISTS_SQLITE = 138
)
type SqlSupplierOldStores struct {
type SqlSupplierStores struct {
team store.TeamStore
channel store.ChannelStore
post store.PostStore
@@ -106,11 +106,10 @@ type SqlSupplier struct {
// See https://github.com/mattermost/mattermost-server/pull/7281
rrCounter int64
srCounter int64
next store.LayeredStoreSupplier
master *gorp.DbMap
replicas []*gorp.DbMap
searchReplicas []*gorp.DbMap
oldStores SqlSupplierOldStores
stores SqlSupplierStores
settings *model.SqlSettings
lockedToMaster bool
}
@@ -124,37 +123,37 @@ func NewSqlSupplier(settings model.SqlSettings, metrics einterfaces.MetricsInter
supplier.initConnection()
supplier.oldStores.team = NewSqlTeamStore(supplier, metrics)
supplier.oldStores.channel = NewSqlChannelStore(supplier, metrics)
supplier.oldStores.post = NewSqlPostStore(supplier, metrics)
supplier.oldStores.user = NewSqlUserStore(supplier, metrics)
supplier.oldStores.bot = NewSqlBotStore(supplier, metrics)
supplier.oldStores.audit = NewSqlAuditStore(supplier)
supplier.oldStores.cluster = NewSqlClusterDiscoveryStore(supplier)
supplier.oldStores.compliance = NewSqlComplianceStore(supplier)
supplier.oldStores.session = NewSqlSessionStore(supplier)
supplier.oldStores.oauth = NewSqlOAuthStore(supplier)
supplier.oldStores.system = NewSqlSystemStore(supplier)
supplier.oldStores.webhook = NewSqlWebhookStore(supplier, metrics)
supplier.oldStores.command = NewSqlCommandStore(supplier)
supplier.oldStores.commandWebhook = NewSqlCommandWebhookStore(supplier)
supplier.oldStores.preference = NewSqlPreferenceStore(supplier)
supplier.oldStores.license = NewSqlLicenseStore(supplier)
supplier.oldStores.token = NewSqlTokenStore(supplier)
supplier.oldStores.emoji = NewSqlEmojiStore(supplier, metrics)
supplier.oldStores.status = NewSqlStatusStore(supplier)
supplier.oldStores.fileInfo = NewSqlFileInfoStore(supplier, metrics)
supplier.oldStores.job = NewSqlJobStore(supplier)
supplier.oldStores.userAccessToken = NewSqlUserAccessTokenStore(supplier)
supplier.oldStores.channelMemberHistory = NewSqlChannelMemberHistoryStore(supplier)
supplier.oldStores.plugin = NewSqlPluginStore(supplier)
supplier.oldStores.TermsOfService = NewSqlTermsOfServiceStore(supplier, metrics)
supplier.oldStores.UserTermsOfService = NewSqlUserTermsOfServiceStore(supplier)
supplier.oldStores.linkMetadata = NewSqlLinkMetadataStore(supplier)
supplier.oldStores.reaction = NewSqlReactionStore(supplier)
supplier.oldStores.role = NewSqlRoleStore(supplier)
supplier.oldStores.scheme = NewSqlSchemeStore(supplier)
supplier.oldStores.group = NewSqlGroupStore(supplier)
supplier.stores.team = NewSqlTeamStore(supplier, metrics)
supplier.stores.channel = NewSqlChannelStore(supplier, metrics)
supplier.stores.post = NewSqlPostStore(supplier, metrics)
supplier.stores.user = NewSqlUserStore(supplier, metrics)
supplier.stores.bot = NewSqlBotStore(supplier, metrics)
supplier.stores.audit = NewSqlAuditStore(supplier)
supplier.stores.cluster = NewSqlClusterDiscoveryStore(supplier)
supplier.stores.compliance = NewSqlComplianceStore(supplier)
supplier.stores.session = NewSqlSessionStore(supplier)
supplier.stores.oauth = NewSqlOAuthStore(supplier)
supplier.stores.system = NewSqlSystemStore(supplier)
supplier.stores.webhook = NewSqlWebhookStore(supplier, metrics)
supplier.stores.command = NewSqlCommandStore(supplier)
supplier.stores.commandWebhook = NewSqlCommandWebhookStore(supplier)
supplier.stores.preference = NewSqlPreferenceStore(supplier)
supplier.stores.license = NewSqlLicenseStore(supplier)
supplier.stores.token = NewSqlTokenStore(supplier)
supplier.stores.emoji = NewSqlEmojiStore(supplier, metrics)
supplier.stores.status = NewSqlStatusStore(supplier)
supplier.stores.fileInfo = NewSqlFileInfoStore(supplier, metrics)
supplier.stores.job = NewSqlJobStore(supplier)
supplier.stores.userAccessToken = NewSqlUserAccessTokenStore(supplier)
supplier.stores.channelMemberHistory = NewSqlChannelMemberHistoryStore(supplier)
supplier.stores.plugin = NewSqlPluginStore(supplier)
supplier.stores.TermsOfService = NewSqlTermsOfServiceStore(supplier, metrics)
supplier.stores.UserTermsOfService = NewSqlUserTermsOfServiceStore(supplier)
supplier.stores.linkMetadata = NewSqlLinkMetadataStore(supplier)
supplier.stores.reaction = NewSqlReactionStore(supplier)
supplier.stores.role = NewSqlRoleStore(supplier)
supplier.stores.scheme = NewSqlSchemeStore(supplier)
supplier.stores.group = NewSqlGroupStore(supplier)
err := supplier.GetMaster().CreateTablesIfNotExists()
if err != nil {
@@ -170,46 +169,37 @@ func NewSqlSupplier(settings model.SqlSettings, metrics einterfaces.MetricsInter
os.Exit(EXIT_GENERIC_FAILURE)
}
supplier.oldStores.team.(*SqlTeamStore).CreateIndexesIfNotExists()
supplier.oldStores.channel.(*SqlChannelStore).CreateIndexesIfNotExists()
supplier.oldStores.post.(*SqlPostStore).CreateIndexesIfNotExists()
supplier.oldStores.user.(*SqlUserStore).CreateIndexesIfNotExists()
supplier.oldStores.bot.(*SqlBotStore).CreateIndexesIfNotExists()
supplier.oldStores.audit.(*SqlAuditStore).CreateIndexesIfNotExists()
supplier.oldStores.compliance.(*SqlComplianceStore).CreateIndexesIfNotExists()
supplier.oldStores.session.(*SqlSessionStore).CreateIndexesIfNotExists()
supplier.oldStores.oauth.(*SqlOAuthStore).CreateIndexesIfNotExists()
supplier.oldStores.system.(*SqlSystemStore).CreateIndexesIfNotExists()
supplier.oldStores.webhook.(*SqlWebhookStore).CreateIndexesIfNotExists()
supplier.oldStores.command.(*SqlCommandStore).CreateIndexesIfNotExists()
supplier.oldStores.commandWebhook.(*SqlCommandWebhookStore).CreateIndexesIfNotExists()
supplier.oldStores.preference.(*SqlPreferenceStore).CreateIndexesIfNotExists()
supplier.oldStores.license.(*SqlLicenseStore).CreateIndexesIfNotExists()
supplier.oldStores.token.(*SqlTokenStore).CreateIndexesIfNotExists()
supplier.oldStores.emoji.(*SqlEmojiStore).CreateIndexesIfNotExists()
supplier.oldStores.status.(*SqlStatusStore).CreateIndexesIfNotExists()
supplier.oldStores.fileInfo.(*SqlFileInfoStore).CreateIndexesIfNotExists()
supplier.oldStores.job.(*SqlJobStore).CreateIndexesIfNotExists()
supplier.oldStores.userAccessToken.(*SqlUserAccessTokenStore).CreateIndexesIfNotExists()
supplier.oldStores.plugin.(*SqlPluginStore).CreateIndexesIfNotExists()
supplier.oldStores.TermsOfService.(SqlTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.oldStores.UserTermsOfService.(SqlUserTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.oldStores.linkMetadata.(*SqlLinkMetadataStore).CreateIndexesIfNotExists()
supplier.oldStores.group.(*SqlGroupStore).CreateIndexesIfNotExists()
supplier.oldStores.preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
supplier.stores.team.(*SqlTeamStore).CreateIndexesIfNotExists()
supplier.stores.channel.(*SqlChannelStore).CreateIndexesIfNotExists()
supplier.stores.post.(*SqlPostStore).CreateIndexesIfNotExists()
supplier.stores.user.(*SqlUserStore).CreateIndexesIfNotExists()
supplier.stores.bot.(*SqlBotStore).CreateIndexesIfNotExists()
supplier.stores.audit.(*SqlAuditStore).CreateIndexesIfNotExists()
supplier.stores.compliance.(*SqlComplianceStore).CreateIndexesIfNotExists()
supplier.stores.session.(*SqlSessionStore).CreateIndexesIfNotExists()
supplier.stores.oauth.(*SqlOAuthStore).CreateIndexesIfNotExists()
supplier.stores.system.(*SqlSystemStore).CreateIndexesIfNotExists()
supplier.stores.webhook.(*SqlWebhookStore).CreateIndexesIfNotExists()
supplier.stores.command.(*SqlCommandStore).CreateIndexesIfNotExists()
supplier.stores.commandWebhook.(*SqlCommandWebhookStore).CreateIndexesIfNotExists()
supplier.stores.preference.(*SqlPreferenceStore).CreateIndexesIfNotExists()
supplier.stores.license.(*SqlLicenseStore).CreateIndexesIfNotExists()
supplier.stores.token.(*SqlTokenStore).CreateIndexesIfNotExists()
supplier.stores.emoji.(*SqlEmojiStore).CreateIndexesIfNotExists()
supplier.stores.status.(*SqlStatusStore).CreateIndexesIfNotExists()
supplier.stores.fileInfo.(*SqlFileInfoStore).CreateIndexesIfNotExists()
supplier.stores.job.(*SqlJobStore).CreateIndexesIfNotExists()
supplier.stores.userAccessToken.(*SqlUserAccessTokenStore).CreateIndexesIfNotExists()
supplier.stores.plugin.(*SqlPluginStore).CreateIndexesIfNotExists()
supplier.stores.TermsOfService.(SqlTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.stores.UserTermsOfService.(SqlUserTermsOfServiceStore).CreateIndexesIfNotExists()
supplier.stores.linkMetadata.(*SqlLinkMetadataStore).CreateIndexesIfNotExists()
supplier.stores.group.(*SqlGroupStore).CreateIndexesIfNotExists()
supplier.stores.preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
return supplier
}
func (s *SqlSupplier) SetChainNext(next store.LayeredStoreSupplier) {
s.next = next
}
func (s *SqlSupplier) Next() store.LayeredStoreSupplier {
return s.next
}
func setupConnection(con_type string, dataSource string, settings *model.SqlSettings) *gorp.DbMap {
db, err := dbsql.Open(*settings.DriverName, dataSource)
if err != nil {
@@ -930,127 +920,127 @@ func (ss *SqlSupplier) UnlockFromMaster() {
}
func (ss *SqlSupplier) Team() store.TeamStore {
return ss.oldStores.team
return ss.stores.team
}
func (ss *SqlSupplier) Channel() store.ChannelStore {
return ss.oldStores.channel
return ss.stores.channel
}
func (ss *SqlSupplier) Post() store.PostStore {
return ss.oldStores.post
return ss.stores.post
}
func (ss *SqlSupplier) User() store.UserStore {
return ss.oldStores.user
return ss.stores.user
}
func (ss *SqlSupplier) Bot() store.BotStore {
return ss.oldStores.bot
return ss.stores.bot
}
func (ss *SqlSupplier) Session() store.SessionStore {
return ss.oldStores.session
return ss.stores.session
}
func (ss *SqlSupplier) Audit() store.AuditStore {
return ss.oldStores.audit
return ss.stores.audit
}
func (ss *SqlSupplier) ClusterDiscovery() store.ClusterDiscoveryStore {
return ss.oldStores.cluster
return ss.stores.cluster
}
func (ss *SqlSupplier) Compliance() store.ComplianceStore {
return ss.oldStores.compliance
return ss.stores.compliance
}
func (ss *SqlSupplier) OAuth() store.OAuthStore {
return ss.oldStores.oauth
return ss.stores.oauth
}
func (ss *SqlSupplier) System() store.SystemStore {
return ss.oldStores.system
return ss.stores.system
}
func (ss *SqlSupplier) Webhook() store.WebhookStore {
return ss.oldStores.webhook
return ss.stores.webhook
}
func (ss *SqlSupplier) Command() store.CommandStore {
return ss.oldStores.command
return ss.stores.command
}
func (ss *SqlSupplier) CommandWebhook() store.CommandWebhookStore {
return ss.oldStores.commandWebhook
return ss.stores.commandWebhook
}
func (ss *SqlSupplier) Preference() store.PreferenceStore {
return ss.oldStores.preference
return ss.stores.preference
}
func (ss *SqlSupplier) License() store.LicenseStore {
return ss.oldStores.license
return ss.stores.license
}
func (ss *SqlSupplier) Token() store.TokenStore {
return ss.oldStores.token
return ss.stores.token
}
func (ss *SqlSupplier) Emoji() store.EmojiStore {
return ss.oldStores.emoji
return ss.stores.emoji
}
func (ss *SqlSupplier) Status() store.StatusStore {
return ss.oldStores.status
return ss.stores.status
}
func (ss *SqlSupplier) FileInfo() store.FileInfoStore {
return ss.oldStores.fileInfo
return ss.stores.fileInfo
}
func (ss *SqlSupplier) Reaction() store.ReactionStore {
return ss.oldStores.reaction
return ss.stores.reaction
}
func (ss *SqlSupplier) Job() store.JobStore {
return ss.oldStores.job
return ss.stores.job
}
func (ss *SqlSupplier) UserAccessToken() store.UserAccessTokenStore {
return ss.oldStores.userAccessToken
return ss.stores.userAccessToken
}
func (ss *SqlSupplier) ChannelMemberHistory() store.ChannelMemberHistoryStore {
return ss.oldStores.channelMemberHistory
return ss.stores.channelMemberHistory
}
func (ss *SqlSupplier) Plugin() store.PluginStore {
return ss.oldStores.plugin
return ss.stores.plugin
}
func (ss *SqlSupplier) Role() store.RoleStore {
return ss.oldStores.role
return ss.stores.role
}
func (ss *SqlSupplier) TermsOfService() store.TermsOfServiceStore {
return ss.oldStores.TermsOfService
return ss.stores.TermsOfService
}
func (ss *SqlSupplier) UserTermsOfService() store.UserTermsOfServiceStore {
return ss.oldStores.UserTermsOfService
return ss.stores.UserTermsOfService
}
func (ss *SqlSupplier) Scheme() store.SchemeStore {
return ss.oldStores.scheme
return ss.stores.scheme
}
func (ss *SqlSupplier) Group() store.GroupStore {
return ss.oldStores.group
return ss.stores.group
}
func (ss *SqlSupplier) LinkMetadata() store.LinkMetadataStore {
return ss.oldStores.linkMetadata
return ss.stores.linkMetadata
}
func (ss *SqlSupplier) DropAllTables() {

View File

@@ -12,7 +12,7 @@ import (
func TestStoreUpgrade(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
sqlStore := ss.(*store.LayeredStore).DatabaseLayer.(SqlStore)
sqlStore := ss.(SqlStore)
t.Run("invalid currentModelVersion", func(t *testing.T) {
err := UpgradeDatabase(sqlStore, "notaversion")
@@ -81,7 +81,7 @@ func TestStoreUpgrade(t *testing.T) {
func TestSaveSchemaVersion(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
sqlStore := ss.(*store.LayeredStore).DatabaseLayer.(SqlStore)
sqlStore := ss.(SqlStore)
t.Run("set earliest version", func(t *testing.T) {
saveSchemaVersion(sqlStore, VERSION_3_0_0)

View File

@@ -1,629 +0,0 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Regenerate this file using `make store-mocks`.
package mocks
import (
store "github.com/mattermost/mattermost-server/store"
mock "github.com/stretchr/testify/mock"
)
// LayeredStoreDatabaseLayer is an autogenerated mock type for the LayeredStoreDatabaseLayer type
type LayeredStoreDatabaseLayer struct {
mock.Mock
}
// Audit provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Audit() store.AuditStore {
ret := _m.Called()
var r0 store.AuditStore
if rf, ok := ret.Get(0).(func() store.AuditStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.AuditStore)
}
}
return r0
}
// Bot provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Bot() store.BotStore {
ret := _m.Called()
var r0 store.BotStore
if rf, ok := ret.Get(0).(func() store.BotStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.BotStore)
}
}
return r0
}
// Channel provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Channel() store.ChannelStore {
ret := _m.Called()
var r0 store.ChannelStore
if rf, ok := ret.Get(0).(func() store.ChannelStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.ChannelStore)
}
}
return r0
}
// ChannelMemberHistory provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) ChannelMemberHistory() store.ChannelMemberHistoryStore {
ret := _m.Called()
var r0 store.ChannelMemberHistoryStore
if rf, ok := ret.Get(0).(func() store.ChannelMemberHistoryStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.ChannelMemberHistoryStore)
}
}
return r0
}
// CheckIntegrity provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) CheckIntegrity() <-chan store.IntegrityCheckResult {
ret := _m.Called()
var r0 <-chan store.IntegrityCheckResult
if rf, ok := ret.Get(0).(func() <-chan store.IntegrityCheckResult); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan store.IntegrityCheckResult)
}
}
return r0
}
// Close provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Close() {
_m.Called()
}
// ClusterDiscovery provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) ClusterDiscovery() store.ClusterDiscoveryStore {
ret := _m.Called()
var r0 store.ClusterDiscoveryStore
if rf, ok := ret.Get(0).(func() store.ClusterDiscoveryStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.ClusterDiscoveryStore)
}
}
return r0
}
// Command provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Command() store.CommandStore {
ret := _m.Called()
var r0 store.CommandStore
if rf, ok := ret.Get(0).(func() store.CommandStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.CommandStore)
}
}
return r0
}
// CommandWebhook provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) CommandWebhook() store.CommandWebhookStore {
ret := _m.Called()
var r0 store.CommandWebhookStore
if rf, ok := ret.Get(0).(func() store.CommandWebhookStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.CommandWebhookStore)
}
}
return r0
}
// Compliance provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Compliance() store.ComplianceStore {
ret := _m.Called()
var r0 store.ComplianceStore
if rf, ok := ret.Get(0).(func() store.ComplianceStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.ComplianceStore)
}
}
return r0
}
// DropAllTables provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) DropAllTables() {
_m.Called()
}
// Emoji provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Emoji() store.EmojiStore {
ret := _m.Called()
var r0 store.EmojiStore
if rf, ok := ret.Get(0).(func() store.EmojiStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.EmojiStore)
}
}
return r0
}
// FileInfo provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) FileInfo() store.FileInfoStore {
ret := _m.Called()
var r0 store.FileInfoStore
if rf, ok := ret.Get(0).(func() store.FileInfoStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.FileInfoStore)
}
}
return r0
}
// GetCurrentSchemaVersion provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) GetCurrentSchemaVersion() string {
ret := _m.Called()
var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}
return r0
}
// Group provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Group() store.GroupStore {
ret := _m.Called()
var r0 store.GroupStore
if rf, ok := ret.Get(0).(func() store.GroupStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.GroupStore)
}
}
return r0
}
// Job provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Job() store.JobStore {
ret := _m.Called()
var r0 store.JobStore
if rf, ok := ret.Get(0).(func() store.JobStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.JobStore)
}
}
return r0
}
// License provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) License() store.LicenseStore {
ret := _m.Called()
var r0 store.LicenseStore
if rf, ok := ret.Get(0).(func() store.LicenseStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.LicenseStore)
}
}
return r0
}
// LinkMetadata provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) LinkMetadata() store.LinkMetadataStore {
ret := _m.Called()
var r0 store.LinkMetadataStore
if rf, ok := ret.Get(0).(func() store.LinkMetadataStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.LinkMetadataStore)
}
}
return r0
}
// LockToMaster provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) LockToMaster() {
_m.Called()
}
// MarkSystemRanUnitTests provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) MarkSystemRanUnitTests() {
_m.Called()
}
// Next provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Next() store.LayeredStoreSupplier {
ret := _m.Called()
var r0 store.LayeredStoreSupplier
if rf, ok := ret.Get(0).(func() store.LayeredStoreSupplier); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.LayeredStoreSupplier)
}
}
return r0
}
// OAuth provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) OAuth() store.OAuthStore {
ret := _m.Called()
var r0 store.OAuthStore
if rf, ok := ret.Get(0).(func() store.OAuthStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.OAuthStore)
}
}
return r0
}
// Plugin provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Plugin() store.PluginStore {
ret := _m.Called()
var r0 store.PluginStore
if rf, ok := ret.Get(0).(func() store.PluginStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.PluginStore)
}
}
return r0
}
// Post provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Post() store.PostStore {
ret := _m.Called()
var r0 store.PostStore
if rf, ok := ret.Get(0).(func() store.PostStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.PostStore)
}
}
return r0
}
// Preference provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Preference() store.PreferenceStore {
ret := _m.Called()
var r0 store.PreferenceStore
if rf, ok := ret.Get(0).(func() store.PreferenceStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.PreferenceStore)
}
}
return r0
}
// Reaction provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Reaction() store.ReactionStore {
ret := _m.Called()
var r0 store.ReactionStore
if rf, ok := ret.Get(0).(func() store.ReactionStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.ReactionStore)
}
}
return r0
}
// Role provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Role() store.RoleStore {
ret := _m.Called()
var r0 store.RoleStore
if rf, ok := ret.Get(0).(func() store.RoleStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.RoleStore)
}
}
return r0
}
// Scheme provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Scheme() store.SchemeStore {
ret := _m.Called()
var r0 store.SchemeStore
if rf, ok := ret.Get(0).(func() store.SchemeStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.SchemeStore)
}
}
return r0
}
// Session provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Session() store.SessionStore {
ret := _m.Called()
var r0 store.SessionStore
if rf, ok := ret.Get(0).(func() store.SessionStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.SessionStore)
}
}
return r0
}
// SetChainNext provides a mock function with given fields: _a0
func (_m *LayeredStoreDatabaseLayer) SetChainNext(_a0 store.LayeredStoreSupplier) {
_m.Called(_a0)
}
// Status provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Status() store.StatusStore {
ret := _m.Called()
var r0 store.StatusStore
if rf, ok := ret.Get(0).(func() store.StatusStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StatusStore)
}
}
return r0
}
// System provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) System() store.SystemStore {
ret := _m.Called()
var r0 store.SystemStore
if rf, ok := ret.Get(0).(func() store.SystemStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.SystemStore)
}
}
return r0
}
// Team provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Team() store.TeamStore {
ret := _m.Called()
var r0 store.TeamStore
if rf, ok := ret.Get(0).(func() store.TeamStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.TeamStore)
}
}
return r0
}
// TermsOfService provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) TermsOfService() store.TermsOfServiceStore {
ret := _m.Called()
var r0 store.TermsOfServiceStore
if rf, ok := ret.Get(0).(func() store.TermsOfServiceStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.TermsOfServiceStore)
}
}
return r0
}
// Token provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Token() store.TokenStore {
ret := _m.Called()
var r0 store.TokenStore
if rf, ok := ret.Get(0).(func() store.TokenStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.TokenStore)
}
}
return r0
}
// TotalMasterDbConnections provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) TotalMasterDbConnections() int {
ret := _m.Called()
var r0 int
if rf, ok := ret.Get(0).(func() int); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(int)
}
return r0
}
// TotalReadDbConnections provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) TotalReadDbConnections() int {
ret := _m.Called()
var r0 int
if rf, ok := ret.Get(0).(func() int); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(int)
}
return r0
}
// TotalSearchDbConnections provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) TotalSearchDbConnections() int {
ret := _m.Called()
var r0 int
if rf, ok := ret.Get(0).(func() int); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(int)
}
return r0
}
// UnlockFromMaster provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) UnlockFromMaster() {
_m.Called()
}
// User provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) User() store.UserStore {
ret := _m.Called()
var r0 store.UserStore
if rf, ok := ret.Get(0).(func() store.UserStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.UserStore)
}
}
return r0
}
// UserAccessToken provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) UserAccessToken() store.UserAccessTokenStore {
ret := _m.Called()
var r0 store.UserAccessTokenStore
if rf, ok := ret.Get(0).(func() store.UserAccessTokenStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.UserAccessTokenStore)
}
}
return r0
}
// UserTermsOfService provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) UserTermsOfService() store.UserTermsOfServiceStore {
ret := _m.Called()
var r0 store.UserTermsOfServiceStore
if rf, ok := ret.Get(0).(func() store.UserTermsOfServiceStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.UserTermsOfServiceStore)
}
}
return r0
}
// Webhook provides a mock function with given fields:
func (_m *LayeredStoreDatabaseLayer) Webhook() store.WebhookStore {
ret := _m.Called()
var r0 store.WebhookStore
if rf, ok := ret.Get(0).(func() store.WebhookStore); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.WebhookStore)
}
}
return r0
}

View File

@@ -1,36 +0,0 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Regenerate this file using `make store-mocks`.
package mocks
import (
store "github.com/mattermost/mattermost-server/store"
mock "github.com/stretchr/testify/mock"
)
// LayeredStoreSupplier is an autogenerated mock type for the LayeredStoreSupplier type
type LayeredStoreSupplier struct {
mock.Mock
}
// Next provides a mock function with given fields:
func (_m *LayeredStoreSupplier) Next() store.LayeredStoreSupplier {
ret := _m.Called()
var r0 store.LayeredStoreSupplier
if rf, ok := ret.Get(0).(func() store.LayeredStoreSupplier); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.LayeredStoreSupplier)
}
}
return r0
}
// SetChainNext provides a mock function with given fields: _a0
func (_m *LayeredStoreSupplier) SetChainNext(_a0 store.LayeredStoreSupplier) {
_m.Called(_a0)
}

View File

@@ -103,7 +103,7 @@ func (h *MainHelper) setupStore() {
h.ClusterInterface = &FakeClusterInterface{}
h.SqlSupplier = sqlstore.NewSqlSupplier(*h.Settings, nil)
h.Store = &TestStore{
store.NewLayeredStore(h.SqlSupplier, nil, h.ClusterInterface),
h.SqlSupplier,
}
}