Skip to content

Commit

Permalink
[nodejs client] fix hookup issues in src/core/server/opensearch (#1194)
Browse files Browse the repository at this point in the history
1. import Client from '@opensearch-project/opensearch/api/new' to hook
up the new types
2. remove asynSearch
3. apply type assertion
4. fix undefined and mismatched types

Remove retry_call_cluster.test.ts due to removing all asyncSearch api

Issue Resolved: #1193
Partical Resolved: #837
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Mar 5, 2022
1 parent e15472d commit c56f149
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 324 deletions.
1 change: 0 additions & 1 deletion src/core/server/opensearch/client/mocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe('Mocked client', () => {
});

it('nested level API methods should be mocked', () => {
expectMocked(client.asyncSearch.get);
expectMocked(client.nodes.info);
});

Expand Down
6 changes: 4 additions & 2 deletions src/core/server/opensearch/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ const createErrorTransportRequestPromise = (err: any): MockedTransportRequestPro
return promise as MockedTransportRequestPromise<never>;
};

function createApiResponse(opts: Partial<ApiResponse> = {}): ApiResponse {
function createApiResponse<TResponse = Record<string, any>>(
opts: Partial<ApiResponse> = {}
): ApiResponse<TResponse> {
return {
body: {},
body: {} as any,
statusCode: 200,
headers: {},
warnings: [],
Expand Down
313 changes: 0 additions & 313 deletions src/core/server/opensearch/client/retry_call_cluster.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('pollOpenSearchNodesVersion', () => {
internalClient.nodes.info.mockImplementationOnce(() => createOpenSearchError(error));
};

it('returns iscCompatible=false and keeps polling when a poll request throws', (done) => {
it('returns isCompatible=false and keeps polling when a poll request throws', (done) => {
expect.assertions(3);
const expectedCompatibilityResults = [false, false, true];
jest.clearAllMocks();
Expand Down
Loading

0 comments on commit c56f149

Please sign in to comment.