Open theahura opened 1 year ago
I'm also seeing this issue when trying to mock an OpenSearch instance using the elastic mocks library.
I also didn't find any workable solutions to it yet.
Do we need to fork https://www.npmjs.com/package/@elastic/elasticsearch-mock and add support for cluster manager? please feel free to do so! (that comes from https://opensearch.org/docs/latest/breaking-changes/#deprecate-non-inclusive-terms).
Caveat that I totally get if this is not the right place for this bug -- the 'opensearch mock' that I'm trying to build is not directly related to this repo, but I'm hoping someone here can help me out nonetheless.
What is the bug?
When running the opensearch client with a mocked connection, I get
TypeError: Cannot read properties of undefined (reading 'cluster_manager')
.Full trace:
How can one reproduce the bug?
There's a pattern of mocking opensearch which attempts to use the elasticsearch mock client and trick the opensearch api to accept the mock. See: https://github.com/opensearch-project/opensearch-js/issues/192, or https://stackoverflow.com/questions/71358008/mock-opensearch-client-in-jest-unit-test
However, clearly there has been drift -- in particular, the following fails:
I dug into the code myself and, as best I can tell, the error is occurring because OpenSearch is looking for a node and there's no filtering information or roles present on the fake client, so the node search fails. Unfortunately just setting a fake
nodeFilter
also fails -- if thenodeFilter
defaults to true, the code hangs; if false, it fails with aNoLivingConnectionsError
It's all running locally and faked, so I'd love if there was a way to disable the cluster management entirely. Is this possible from the client input parameters alone?
What is the expected behavior?
No error.
What is your host/environment?
Linux 20.04, OpenSearch 2.5