Validate search configuration in the Search Settings page.

Review Request #11891 — Created Dec. 15, 2021 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

The Search Settings page now validates the search configuration by
performing a test search. If it succeeds, the configuration is
considered valid. If it fails, a validation error is shown on the page.

This requires some changes to how validation works. We had a
SearchBackend.validate() method, which was originally built for
Elasticsearch so that it could check for the presence of a module. Now
it takes in the generated configuration, so it can build a Haystack
backend and perform the search.

While it's unlikely there are any other custom search backends out
there, the new signature change to validate() is not yet enforced. We
emit a deprecation warning if it lacks a **kwargs argument.

Subform validation is also now limited to the selected search engine, so
that one subform's errors won't result in other subforms showing errors
when selected.

This will help prevent some confusion when configuration is broken,
particularly with the new multi-version Elasticsearch support.

Unit tests pass on Python 2 and 3.

Tested various good and bad configurations in Whoosh and Elasticsearch,
switching between the subforms to ensure only the active form attempted
validation.

Tested searching and indexing on the working configurations.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Validate search configuration in the Search Settings page.
The Search Settings page now validates the search configuration by performing a test search. If it succeeds, the configuration is considered valid. If it fails, a validation error is shown on the page. This requires some changes to how validation works. We had a `SearchBackend.validate()` method, which was originally built for Elasticsearch so that it could check for the presence of a module. Now it takes in the generated configuration, so it can build a Haystack backend and perform the search. While it's unlikely there are any other custom search backends out there, the new signature change to `validate()` is not yet enforced. We emit a deprecation warning if it lacks a `**kwargs` argument. This will help prevent some confusion when configuration is broken, particularly with the new multi-version Elasticsearch support.
59b9ce264f2325730d5e11b0a6f8f937a30f7f2f Christian Hammond
reviewboard/admin/forms/search_settings.py
reviewboard/search/haystack_backend.py
reviewboard/search/search_backends/base.py
reviewboard/search/search_backends/elasticsearch.py
reviewboard/search/tests/test_search_backend.py
Loading...