From 97c3b53873b0eca02e830dd4a92f7c9da97c3097 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Wed, 6 May 2026 10:13:58 -0300 Subject: [PATCH] MM-68532: default EnableSearchPublicChannelsWithoutMembership to true for new installations (#36399) * MM-68532: default EnableSearchPublicChannelsWithoutMembership to true for new installations * fix test: disable backfill in watcher tests to avoid mock store panic * fix test: mock System store so backfill returns early in watcher tests * MM-68532: add SetDefaults unit test for EnableSearchPublicChannelsWithoutMembership --- server/channels/app/platform/searchengine_test.go | 9 +++++++++ server/public/model/config.go | 2 +- server/public/model/config_test.go | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/server/channels/app/platform/searchengine_test.go b/server/channels/app/platform/searchengine_test.go index 24b97dc05da..52332272c45 100644 --- a/server/channels/app/platform/searchengine_test.go +++ b/server/channels/app/platform/searchengine_test.go @@ -18,6 +18,7 @@ import ( "github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/shared/mlog" "github.com/mattermost/mattermost/server/public/shared/request" + storemocks "github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks" "github.com/mattermost/mattermost/server/v8/channels/testlib" "github.com/mattermost/mattermost/server/v8/platform/services/searchengine" searchenginemocks "github.com/mattermost/mattermost/server/v8/platform/services/searchengine/mocks" @@ -64,6 +65,14 @@ func setupWatcherTest(t *testing.T) (*searchEngineWatcher, *searchenginemocks.Se engineMock.On("IsHealthy").Return(true).Maybe() engineMock.On("SetHealthy", mock.Anything).Maybe() + // Make backfillPostsChannelType return immediately by indicating the backfill + // is already done. This prevents the goroutine from calling unmocked store + // methods in tests that only exercise watcher retry/health logic. + systemMock := &storemocks.SystemStore{} + systemMock.On("GetByName", model.SystemPostChannelTypeBackfillComplete). + Return(&model.System{Name: model.SystemPostChannelTypeBackfillComplete, Value: "true"}, nil).Maybe() + ps.Store.(*storemocks.Store).On("System").Return(systemMock).Maybe() + ps.SearchEngine = searchengine.NewBroker(ps.Config()) ps.SearchEngine.ElasticsearchEngine = engineMock diff --git a/server/public/model/config.go b/server/public/model/config.go index 0f907f513a7..e7bd85b0606 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -3273,7 +3273,7 @@ func (s *ElasticsearchSettings) SetDefaults() { } if s.EnableSearchPublicChannelsWithoutMembership == nil { - s.EnableSearchPublicChannelsWithoutMembership = NewPointer(false) + s.EnableSearchPublicChannelsWithoutMembership = NewPointer(true) } } diff --git a/server/public/model/config_test.go b/server/public/model/config_test.go index ad51560fea7..7456b9275ef 100644 --- a/server/public/model/config_test.go +++ b/server/public/model/config_test.go @@ -3001,3 +3001,17 @@ func TestExperimentalSettingsEnableWatermarkDefault(t *testing.T) { require.True(t, *cfg.ExperimentalSettings.EnableWatermark) }) } + +func TestElasticsearchSettingsSetDefaults(t *testing.T) { + t.Run("EnableSearchPublicChannelsWithoutMembership defaults to true when nil", func(t *testing.T) { + s := ElasticsearchSettings{} + s.SetDefaults() + require.True(t, *s.EnableSearchPublicChannelsWithoutMembership) + }) + + t.Run("EnableSearchPublicChannelsWithoutMembership preserves explicit false", func(t *testing.T) { + s := ElasticsearchSettings{EnableSearchPublicChannelsWithoutMembership: NewPointer(false)} + s.SetDefaults() + require.False(t, *s.EnableSearchPublicChannelsWithoutMembership) + }) +}