Remote Cluster Service
- provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages
- trusted connections are managed via slash commands (for now)
- facilitates features requiring inter-cluster communication, such as Shared Channels
Shared Channels Service
- provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection)
- sharing/unsharing of channels is managed via slash commands (for now)
Этот коммит содержится в:
Doug Lauder
2021-04-01 13:44:56 -04:00
коммит произвёл GitHub
родитель ff980266ac
Коммит 02196e04fa
137 изменённых файлов: 15137 добавлений и 262 удалений

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

@@ -2053,3 +2053,87 @@ func TestReplyToPostWithLag(t *testing.T) {
require.NotNil(t, reply)
})
}
func TestSharedChannelSyncForPostActions(t *testing.T) {
t.Run("creating a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
remoteClusterService := NewMockSharedChannelService(nil)
th.App.srv.sharedChannelService = remoteClusterService
testCluster := &testlib.FakeClusterInterface{}
th.Server.Cluster = testCluster
user := th.BasicUser
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
_, err := th.App.CreatePost(&model.Post{
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
require.Nil(t, err, "Creating a post should not error")
assert.Len(t, remoteClusterService.notifications, 1)
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
})
t.Run("updating a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
remoteClusterService := NewMockSharedChannelService(nil)
th.App.srv.sharedChannelService = remoteClusterService
testCluster := &testlib.FakeClusterInterface{}
th.Server.Cluster = testCluster
user := th.BasicUser
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
post, err := th.App.CreatePost(&model.Post{
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
require.Nil(t, err, "Creating a post should not error")
_, err = th.App.UpdatePost(post, true)
require.Nil(t, err, "Updating a post should not error")
assert.Len(t, remoteClusterService.notifications, 2)
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
assert.Equal(t, channel.Id, remoteClusterService.notifications[1])
})
t.Run("deleting a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
remoteClusterService := NewMockSharedChannelService(nil)
th.App.srv.sharedChannelService = remoteClusterService
testCluster := &testlib.FakeClusterInterface{}
th.Server.Cluster = testCluster
user := th.BasicUser
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
post, err := th.App.CreatePost(&model.Post{
UserId: user.Id,
ChannelId: channel.Id,
Message: "Hello folks",
}, channel, false, true)
require.Nil(t, err, "Creating a post should not error")
_, err = th.App.DeletePost(post.Id, user.Id)
require.Nil(t, err, "Deleting a post should not error")
// one creation and two deletes
assert.Len(t, remoteClusterService.notifications, 3)
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
assert.Equal(t, channel.Id, remoteClusterService.notifications[1])
assert.Equal(t, channel.Id, remoteClusterService.notifications[2])
})
}