snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
This commit is contained in:
19886
server/channels/store/retrylayer/retrylayer.go
Normal file
19886
server/channels/store/retrylayer/retrylayer.go
Normal file
File diff suppressed because it is too large
Load Diff
130
server/channels/store/retrylayer/retrylayer_test.go
Normal file
130
server/channels/store/retrylayer/retrylayer_test.go
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package retrylayer
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/lib/pq/pqerror"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
||||
)
|
||||
|
||||
func genStore() *mocks.Store {
|
||||
mock := &mocks.Store{}
|
||||
mock.On("Audit").Return(&mocks.AuditStore{})
|
||||
mock.On("Bot").Return(&mocks.BotStore{})
|
||||
mock.On("Channel").Return(&mocks.ChannelStore{})
|
||||
mock.On("ChannelGuard").Return(&mocks.ChannelGuardStore{})
|
||||
mock.On("ChannelMemberHistory").Return(&mocks.ChannelMemberHistoryStore{})
|
||||
mock.On("ChannelBookmark").Return(&mocks.ChannelBookmarkStore{})
|
||||
mock.On("ClusterDiscovery").Return(&mocks.ClusterDiscoveryStore{})
|
||||
mock.On("RemoteCluster").Return(&mocks.RemoteClusterStore{})
|
||||
mock.On("Command").Return(&mocks.CommandStore{})
|
||||
mock.On("CommandWebhook").Return(&mocks.CommandWebhookStore{})
|
||||
mock.On("Compliance").Return(&mocks.ComplianceStore{})
|
||||
mock.On("Emoji").Return(&mocks.EmojiStore{})
|
||||
mock.On("FileInfo").Return(&mocks.FileInfoStore{})
|
||||
mock.On("UploadSession").Return(&mocks.UploadSessionStore{})
|
||||
mock.On("Group").Return(&mocks.GroupStore{})
|
||||
mock.On("Job").Return(&mocks.JobStore{})
|
||||
mock.On("License").Return(&mocks.LicenseStore{})
|
||||
mock.On("LinkMetadata").Return(&mocks.LinkMetadataStore{})
|
||||
mock.On("SharedChannel").Return(&mocks.SharedChannelStore{})
|
||||
mock.On("OAuth").Return(&mocks.OAuthStore{})
|
||||
mock.On("OutgoingOAuthConnection").Return(&mocks.OutgoingOAuthConnectionStore{})
|
||||
mock.On("Plugin").Return(&mocks.PluginStore{})
|
||||
mock.On("Post").Return(&mocks.PostStore{})
|
||||
mock.On("Thread").Return(&mocks.ThreadStore{})
|
||||
mock.On("Preference").Return(&mocks.PreferenceStore{})
|
||||
mock.On("ProductNotices").Return(&mocks.ProductNoticesStore{})
|
||||
mock.On("Reaction").Return(&mocks.ReactionStore{})
|
||||
mock.On("RetentionPolicy").Return(&mocks.RetentionPolicyStore{})
|
||||
mock.On("Role").Return(&mocks.RoleStore{})
|
||||
mock.On("Scheme").Return(&mocks.SchemeStore{})
|
||||
mock.On("Session").Return(&mocks.SessionStore{})
|
||||
mock.On("SessionAttribute").Return(&mocks.SessionAttributeStore{})
|
||||
mock.On("Status").Return(&mocks.StatusStore{})
|
||||
mock.On("System").Return(&mocks.SystemStore{})
|
||||
mock.On("Team").Return(&mocks.TeamStore{})
|
||||
mock.On("TermsOfService").Return(&mocks.TermsOfServiceStore{})
|
||||
mock.On("Token").Return(&mocks.TokenStore{})
|
||||
mock.On("User").Return(&mocks.UserStore{})
|
||||
mock.On("UserAccessToken").Return(&mocks.UserAccessTokenStore{})
|
||||
mock.On("UserTermsOfService").Return(&mocks.UserTermsOfServiceStore{})
|
||||
mock.On("Webhook").Return(&mocks.WebhookStore{})
|
||||
mock.On("NotifyAdmin").Return(&mocks.NotifyAdminStore{})
|
||||
mock.On("Draft").Return(&mocks.DraftStore{})
|
||||
mock.On("PostPriority").Return(&mocks.PostPriorityStore{})
|
||||
mock.On("PostAcknowledgement").Return(&mocks.PostAcknowledgementStore{})
|
||||
mock.On("PostPersistentNotification").Return(&mocks.PostPersistentNotificationStore{})
|
||||
mock.On("DesktopTokens").Return(&mocks.DesktopTokensStore{})
|
||||
mock.On("ChannelBookmark").Return(&mocks.ChannelBookmarkStore{})
|
||||
mock.On("ScheduledPost").Return(&mocks.ScheduledPostStore{})
|
||||
mock.On("PropertyField").Return(&mocks.PropertyFieldStore{})
|
||||
mock.On("PropertyGroup").Return(&mocks.PropertyGroupStore{})
|
||||
mock.On("PropertyValue").Return(&mocks.PropertyValueStore{})
|
||||
mock.On("AccessControlPolicy").Return(&mocks.AccessControlPolicyStore{})
|
||||
mock.On("Attributes").Return(&mocks.AttributesStore{})
|
||||
mock.On("AutoTranslation").Return(&mocks.AutoTranslationStore{})
|
||||
mock.On("ContentFlagging").Return(&mocks.ContentFlaggingStore{})
|
||||
mock.On("DeliveryTracking").Return(&mocks.DeliveryTrackingStore{})
|
||||
mock.On("ReadReceipt").Return(&mocks.ReadReceiptStore{})
|
||||
mock.On("Recap").Return(&mocks.RecapStore{})
|
||||
mock.On("ScheduledRecap").Return(&mocks.ScheduledRecapStore{})
|
||||
mock.On("TemporaryPost").Return(&mocks.TemporaryPostStore{})
|
||||
mock.On("View").Return(&mocks.ViewStore{})
|
||||
mock.On("ChannelJoinRequest").Return(&mocks.ChannelJoinRequestStore{})
|
||||
return mock
|
||||
}
|
||||
|
||||
func TestRetry(t *testing.T) {
|
||||
t.Run("on regular error should not retry", func(t *testing.T) {
|
||||
mock := genStore()
|
||||
mockBotStore := mock.Bot().(*mocks.BotStore)
|
||||
mockBotStore.On("Get", "test", false).Return(nil, errors.New("regular error")).Times(1)
|
||||
mock.On("Bot").Return(&mockBotStore)
|
||||
layer := New(mock)
|
||||
layer.Bot().Get("test", false)
|
||||
mockBotStore.AssertExpectations(t)
|
||||
})
|
||||
t.Run("on success should not retry", func(t *testing.T) {
|
||||
mock := genStore()
|
||||
mockBotStore := mock.Bot().(*mocks.BotStore)
|
||||
mockBotStore.On("Get", "test", false).Return(&model.Bot{}, nil).Times(1)
|
||||
mock.On("Bot").Return(&mockBotStore)
|
||||
layer := New(mock)
|
||||
layer.Bot().Get("test", false)
|
||||
mockBotStore.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("on postgres repeatable error should retry", func(t *testing.T) {
|
||||
for _, errCode := range []string{"40001", "40P01"} {
|
||||
t.Run("error "+errCode, func(t *testing.T) {
|
||||
mock := genStore()
|
||||
mockBotStore := mock.Bot().(*mocks.BotStore)
|
||||
pqErr := pq.Error{Code: pqerror.Code(errCode)}
|
||||
mockBotStore.On("Get", "test", false).Return(nil, errors.Wrap(&pqErr, "test-error")).Times(3)
|
||||
mock.On("Bot").Return(&mockBotStore)
|
||||
layer := New(mock)
|
||||
layer.Bot().Get("test", false)
|
||||
mockBotStore.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("on postgres not repeatable error should not retry", func(t *testing.T) {
|
||||
mock := genStore()
|
||||
mockBotStore := mock.Bot().(*mocks.BotStore)
|
||||
pqErr := pq.Error{Code: "20000"}
|
||||
mockBotStore.On("Get", "test", false).Return(nil, errors.Wrap(&pqErr, "test-error")).Times(1)
|
||||
mock.On("Bot").Return(&mockBotStore)
|
||||
layer := New(mock)
|
||||
layer.Bot().Get("test", false)
|
||||
mockBotStore.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user