Files
Ben SchumacherandClaude Opus 5.5 4bf16a6a10 MM-71424: Make Elasticsearch/OpenSearch TestConfig side-effect-free (#39512)
* MM-71424: Make Elasticsearch/OpenSearch TestConfig side-effect-free

TestConfig marked a stopped engine ready and swapped in a new client,
skipping Start(): no index templates, no bulk processors, no healthy
flag. The watcher then never called Start(), and SyncBulkIndexChannels
could hit a nil sync bulk processor in an unrecovered goroutine. It
also overwrote the running engine's version and plugins, without the
mutex, from a possibly unsaved candidate config.

- TestConfig now only builds a client and checks the version.
- App.TestElasticsearch wakes the search engine watcher after a
  successful test on an inactive engine, so it runs a full Start()
  right away instead of waiting out its backoff.
- SyncBulkIndexChannels returns an error instead of panicking when the
  sync bulk processor is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpCfx3XMX5sfS3hGN7Ln1M

* MM-71424: Only wake the watcher when the tested connection is the saved one

The watcher starts the engine with the saved config, and each wake
resets its backoff. Testing an unsaved candidate config (for example a
different URL) must not make it retry the saved cluster immediately.

Also fold the duplicated watcher wake subtest into a loop over both
wake functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpCfx3XMX5sfS3hGN7Ln1M

* MM-71424: Simplify the TestConfig follow-up

- Move the "wake the watcher after a successful test" decision into
  PlatformService.SearchEngineConnectionTested, next to the watcher,
  instead of exposing a raw reevaluate signal to the app layer.
- Close the probe client in TestConfig. It is now always discarded, and
  with sniffing on it would leave a discovery goroutine running.
- Drop the syncBulkProcessor nil guards: with TestConfig no longer
  setting ready, ready implies both processors exist.
- Restore the original watcher wake subtest and test the new platform
  method directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpCfx3XMX5sfS3hGN7Ln1M

* MM-71424: Use the caller's context for the TestConfig version probe

Lets callers that carry a deadline or cancellation stop the version
request. The probe client is still closed with a background context so
cleanup runs even when the caller's context is already done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpCfx3XMX5sfS3hGN7Ln1M

* MM-71424: Add watcher lifecycle tests for both search engines

Adapted from #37931 as requested in review:
- TestTestConfigThenSavingConfigStartsEngine: TestConfig leaves a
  stopped engine alone; saving the tested config wakes the watcher,
  which runs the real Start() and creates the sync bulk processor.
- TestTestElasticsearchStartsEngineWithoutWaitingForBackoff: the saved
  cluster comes back while the watcher waits out its backoff, and a
  successful App.TestElasticsearch starts the engine right away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpCfx3XMX5sfS3hGN7Ln1M

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 07:58:29 +01:00
..
2024-01-08 10:47:24 -04:00
2024-01-08 10:47:24 -04:00

Enterprise

This folder contains source available enterprise code as well as import directives for closed source enterprise code.

Build Information

The source code in this folder is only included with builds specifying the enterprise or sourceavailble build tags. If you have a copy of https://github.com/mattermost/enterprise checked out as a peer to this repository, enterprise will be set automatically and the imports from both external_imports.go and local_imports.go will apply.

In a development environment (when BUILD_NUMBER is left undefined or explicitly set to dev), the sourceavailable build tag will be set automatically and only the imports from local_imports.go will apply.

License

See the LICENSE file for license rights and limitations. See also Mattermost Source Available License to learn more.

Contributing

Contributions to source available enterprise code are welcome. Please see CONTRIBUTING.md.