Resolve "Improve test coverage for Elasticsearch"
What does this MR do and why?
- Connects to Elastic and verifies it can run a few different queries and get a non-error result.
- Created generic code for building search query config and the search query itself and added it to helper file
elastic_api_helpers.js
. - Now these functions are shared between
elastic_api.js
,elastic_api_spec.js
, andcheck_elastic_key_permissions.cjs
files. - In the test we do run the production instance search.
- Created generic code for building search query config and the search query itself and added it to helper file
Screenshots, screen recordings, or links to review app
With the added elastic_api tests, we can confirm that if the query is off, the tests do fail.
I replaced the buildSearchQuery
logic with logic from this reverted code.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/technical-writing-group/gitlab-docs-hugo/-/blob/main/doc/setup.md. -
Make sure to run make jest-tests
or watch pipeline for success, ensurecheck_elastic_key_permissions.cjs
file still runs the checks correctly (I was able to verify with no changes to credentials and creating a key without permissions cases), and also make sure search is still working as expected in terms of filters, phrase searches, normal searches, etc.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.
Closes #144 (closed)
Edited by Hiru Fernando