Upgrade ES client to 9.0.0-alpha.3 (#208776)

## Summary

Updating the ES client to 9.0. 

Resolves #116102

## What changes?

**Breaking change**: `body` has been removed.

Most of the changes are about bringing all the content inside the body
as a root attribute to the API params:

```diff
const response = await client.search({
  index: 'test',
-  body: {
    query: {
      match_all: {}
    }
-  }
})
```

For this reason, enabling the "Hide whitespace changes" option when
reviewing is recommended.

Some exceptions to this rule:

* Bulk APIs replace the `body` array with `operations` array (direct
replacement)
* Index Put Settings API replace `body` array with `settings` (direct
replacement)
* Msearch replaces the `body` array with `searches` array (direct
replacement)
* Document Index API replaces `body` with `document` (direct
replacement)
* Create Repository replaces `body` with `repository` (direct
replacement)

Because of a known issue in the client
(https://github.com/elastic/elasticsearch-js/issues/2584), there's still
an escape hatch to send data in the body in case the specific use case
requires it via `// @ts-expect-error elasticsearch@9.0.0
https://github.com/elastic/elasticsearch-js/issues/2584`, but it
shouldn't be abused because we lose types. In this PR we've used it in
those scenarios where we reuse the response of a GET as the body of a
PUT/POST.

### Other changes

* `estypes` can be imported from the root of the library as `import type
{ estypes } from '@elastic/elasticsearch';`
* `estypesWithBody` have been removed
* `requestTimeout`'s 30s default has been removed in the client. This PR
explicitly adds the setting in all client usages.


### Identify risks

- [x] The client places unknown properties as querystring, risking body
params leaking there, and causing 400 errors from ES => Solved by
forcing `body` usage there via `// @ts-expect-error elasticsearch@9.0.0
https://github.com/elastic/elasticsearch-js/issues/2584`. The next
version of the client will address this.
- [x] We need to run the MKI tests to make sure that we're not breaking
anything there =>
https://elastic.slack.com/archives/C04HT4P1YS3/p1739528112482629?thread_ts=1739480136.231439&cid=C04HT4P1YS3

---------

Co-authored-by: Gloria Hornero <gloria.hornero@elastic.co>
This commit is contained in:
Alejandro Fernández Haro 2025-02-25 15:37:23 +01:00 committed by GitHub
parent 3492f12c6c
commit 52ab19db2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1907 changed files with 27841 additions and 30485 deletions

View file

@ -330,7 +330,7 @@ export class EsoModelVersionExample
const objectsCreated = await Promise.all( const objectsCreated = await Promise.all(
documentVersionConstants.map(async (obj) => { documentVersionConstants.map(async (obj) => {
const createdDoc: WriteResponseBase = const createdDoc: WriteResponseBase =
await elasticsearch.client.asInternalUser.create(obj); await elasticsearch.client.asInternalUser.create<unknown>(obj);
const parts = createdDoc._id.split(':', 2); const parts = createdDoc._id.split(':', 2);
return { type: parts[0], id: parts[1] }; return { type: parts[0], id: parts[1] };
}) })

View file

@ -181,13 +181,15 @@ export const SearchExamplesApp = ({
const aggs = [{ type: metricAggType, params: { field: selectedNumericField!.name } }]; const aggs = [{ type: metricAggType, params: { field: selectedNumericField!.name } }];
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl(); const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();
const body = {
aggs: aggsDsl,
query,
};
const req = { const req = {
params: { params: {
index: dataView.title, index: dataView.title,
body: { ...body,
aggs: aggsDsl,
query,
},
}, },
// Add a custom request parameter to be consumed by `MyStrategy`. // Add a custom request parameter to be consumed by `MyStrategy`.
...(strategy ? { get_cool: getCool } : {}), ...(strategy ? { get_cool: getCool } : {}),
@ -197,7 +199,7 @@ export const SearchExamplesApp = ({
setAbortController(abortController); setAbortController(abortController);
// Submit the search request using the `data.search` service. // Submit the search request using the `data.search` service.
setRequest(req.params.body); setRequest(body);
setRawResponse({}); setRawResponse({});
setWarningContents([]); setWarningContents([]);
setIsLoading(true); setIsLoading(true);

View file

@ -707,11 +707,9 @@ function doSearch(
const req = { const req = {
params: { params: {
index: dataView.title, index: dataView.title,
body: {
aggs: aggsDsl, aggs: aggsDsl,
query, query,
}, },
},
}; };
const startTs = performance.now(); const startTs = performance.now();

View file

@ -39,7 +39,6 @@ export function registerServerSearchRoute(router: IRouter<DataRequestHandlerCont
{ {
params: { params: {
index, index,
body: {
aggs: { aggs: {
'1': { '1': {
avg: { avg: {
@ -48,7 +47,6 @@ export function registerServerSearchRoute(router: IRouter<DataRequestHandlerCont
}, },
}, },
}, },
},
} as IEsSearchRequest, } as IEsSearchRequest,
{ abortSignal } { abortSignal }
) )

View file

@ -44,11 +44,9 @@ function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart })
.search({ .search({
params: { params: {
index: dataView?.getIndexPattern(), index: dataView?.getIndexPattern(),
body: {
fields: ['*'], fields: ['*'],
_source: false, _source: false,
}, },
},
}) })
.toPromise(); .toPromise();
const docs = response?.rawResponse?.hits?.hits ?? []; const docs = response?.rawResponse?.hits?.hits ?? [];

View file

@ -115,7 +115,7 @@
"@elastic/datemath": "5.0.3", "@elastic/datemath": "5.0.3",
"@elastic/ebt": "^1.1.1", "@elastic/ebt": "^1.1.1",
"@elastic/ecs": "^8.11.5", "@elastic/ecs": "^8.11.5",
"@elastic/elasticsearch": "^8.17.0", "@elastic/elasticsearch": "9.0.0-alpha.3",
"@elastic/ems-client": "8.6.3", "@elastic/ems-client": "8.6.3",
"@elastic/eui": "99.2.0-borealis.0", "@elastic/eui": "99.2.0-borealis.0",
"@elastic/eui-theme-borealis": "0.0.10", "@elastic/eui-theme-borealis": "0.0.10",

View file

@ -37,6 +37,7 @@ export async function reportFailuresToEs(log: ToolingLog, failures: TestFailure[
password: process.env.TEST_FAILURES_ES_PASSWORD, password: process.env.TEST_FAILURES_ES_PASSWORD,
}, },
Connection: HttpConnection, Connection: HttpConnection,
requestTimeout: 30_000,
}); });
const body = failures.flatMap((failure) => [ const body = failures.flatMap((failure) => [

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { SearchRequest, MsearchRequestItem } from '@elastic/elasticsearch/lib/api/types'; import { SearchRequest, MsearchRequestItem } from '@elastic/elasticsearch/lib/api/types';
import { ToolingLog } from '@kbn/tooling-log'; import { ToolingLog } from '@kbn/tooling-log';
@ -109,6 +109,8 @@ export class ESClient {
username: options.username, username: options.username,
password: options.password, password: options.password,
}, },
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
this.log = log; this.log = log;
} }

View file

@ -116,7 +116,7 @@ export class ElasticsearchService
this.esNodesCompatibility$ = esNodesCompatibility$; this.esNodesCompatibility$ = esNodesCompatibility$;
this.clusterInfo$ = getClusterInfo$(this.client.asInternalUser); this.clusterInfo$ = getClusterInfo$(this.client.asInternalUser).pipe(takeUntil(this.stop$));
registerAnalyticsContextProvider(deps.analytics, this.clusterInfo$); registerAnalyticsContextProvider(deps.analytics, this.clusterInfo$);
return { return {

View file

@ -8,7 +8,7 @@
*/ */
import { isRetryableEsClientErrorMock } from './is_scripting_enabled.test.mocks'; import { isRetryableEsClientErrorMock } from './is_scripting_enabled.test.mocks';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks'; import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import { isInlineScriptingEnabled } from './is_scripting_enabled'; import { isInlineScriptingEnabled } from './is_scripting_enabled';

View file

@ -18,7 +18,7 @@ import {
} from '../repository.test.mock'; } from '../repository.test.mock';
import type { Payload } from '@hapi/boom'; import type { Payload } from '@hapi/boom';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { import type {
SavedObjectsBulkDeleteObject, SavedObjectsBulkDeleteObject,

View file

@ -11,7 +11,7 @@ import {
getSavedObjectFromSourceMock, getSavedObjectFromSourceMock,
rawDocExistsInNamespaceMock, rawDocExistsInNamespaceMock,
} from './bulk_get.isolated.test.mocks'; } from './bulk_get.isolated.test.mocks';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { SavedObject, CheckAuthorizationResult } from '@kbn/core-saved-objects-server'; import { SavedObject, CheckAuthorizationResult } from '@kbn/core-saved-objects-server';
import { apiContextMock, ApiExecutionContextMock } from '../../mocks'; import { apiContextMock, ApiExecutionContextMock } from '../../mocks';
import { performBulkGet } from './bulk_get'; import { performBulkGet } from './bulk_get';

View file

@ -17,7 +17,7 @@ import {
import type { ISavedObjectsSecurityExtension } from '@kbn/core-saved-objects-server'; import type { ISavedObjectsSecurityExtension } from '@kbn/core-saved-objects-server';
import type { Payload } from '@hapi/boom'; import type { Payload } from '@hapi/boom';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { SavedObjectsBulkGetObject } from '@kbn/core-saved-objects-api-server'; import type { SavedObjectsBulkGetObject } from '@kbn/core-saved-objects-api-server';
import { type SavedObjectsRawDocSource, type SavedObject } from '@kbn/core-saved-objects-server'; import { type SavedObjectsRawDocSource, type SavedObject } from '@kbn/core-saved-objects-server';

View file

@ -17,7 +17,7 @@ import {
} from '../repository.test.mock'; } from '../repository.test.mock';
import type { Payload } from '@hapi/boom'; import type { Payload } from '@hapi/boom';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { import type {
SavedObjectsBulkUpdateObject, SavedObjectsBulkUpdateObject,

View file

@ -13,7 +13,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server'; import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';
import { SavedObjectsRepository } from '../repository'; import { SavedObjectsRepository } from '../repository';

View file

@ -16,7 +16,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { SavedObjectsCreateOptions } from '@kbn/core-saved-objects-api-server'; import type { SavedObjectsCreateOptions } from '@kbn/core-saved-objects-api-server';
import { import {

View file

@ -16,7 +16,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { SavedObjectsDeleteOptions } from '@kbn/core-saved-objects-api-server'; import type { SavedObjectsDeleteOptions } from '@kbn/core-saved-objects-api-server';
import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server'; import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';

View file

@ -8,7 +8,7 @@
*/ */
import { isSupportedEsServerMock } from './find.isolated.test.mocks'; import { isSupportedEsServerMock } from './find.isolated.test.mocks';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { SavedObject, AuthorizationTypeMap } from '@kbn/core-saved-objects-server'; import { SavedObject, AuthorizationTypeMap } from '@kbn/core-saved-objects-server';
import { apiContextMock, ApiExecutionContextMock } from '../../mocks'; import { apiContextMock, ApiExecutionContextMock } from '../../mocks';
import { performFind } from './find'; import { performFind } from './find';

View file

@ -8,7 +8,7 @@
*/ */
import Boom from '@hapi/boom'; import Boom from '@hapi/boom';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { isSupportedEsServer } from '@kbn/core-elasticsearch-server-internal'; import { isSupportedEsServer } from '@kbn/core-elasticsearch-server-internal';
import { import {
SavedObjectsErrorHelpers, SavedObjectsErrorHelpers,

View file

@ -15,7 +15,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { SavedObjectsBaseOptions } from '@kbn/core-saved-objects-api-server'; import type { SavedObjectsBaseOptions } from '@kbn/core-saved-objects-api-server';
import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server'; import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';

View file

@ -16,7 +16,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { import type {
SavedObjectsIncrementCounterField, SavedObjectsIncrementCounterField,

View file

@ -65,7 +65,6 @@ describe('preflightCheckForCreate', () => {
docs: results.map(({ found, disabled }, i) => { docs: results.map(({ found, disabled }, i) => {
return found return found
? { ? {
// @ts-expect-error
_id: params!.docs![i]._id, // needed for mockRawDocExistsInNamespaces mock implementation and existingDocument assertions _id: params!.docs![i]._id, // needed for mockRawDocExistsInNamespaces mock implementation and existingDocument assertions
_index: 'doesnt-matter', _index: 'doesnt-matter',
_source: { _source: {

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { isNotFoundFromUnsupportedServer } from '@kbn/core-elasticsearch-server-internal'; import { isNotFoundFromUnsupportedServer } from '@kbn/core-elasticsearch-server-internal';
import { import {
type ISavedObjectTypeRegistry, type ISavedObjectTypeRegistry,

View file

@ -8,7 +8,7 @@
*/ */
import pMap from 'p-map'; import pMap from 'p-map';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import intersection from 'lodash/intersection'; import intersection from 'lodash/intersection';
import type { Logger } from '@kbn/logging'; import type { Logger } from '@kbn/logging';

View file

@ -15,7 +15,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from '../repository.test.mock'; } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { SavedObjectsRepository } from '../repository'; import { SavedObjectsRepository } from '../repository';
import { loggerMock } from '@kbn/logging-mocks'; import { loggerMock } from '@kbn/logging-mocks';

View file

@ -11,7 +11,7 @@
import { mockGetCurrentTime, mockPreflightCheckForCreate } from '../repository.test.mock'; import { mockGetCurrentTime, mockPreflightCheckForCreate } from '../repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { import {
type SavedObjectUnsanitizedDoc, type SavedObjectUnsanitizedDoc,
type SavedObjectReference, type SavedObjectReference,

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
/** /**
* Type and type guard function for converting a possibly not existent doc to an existent doc. * Type and type guard function for converting a possibly not existent doc to an existent doc.

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { Payload } from '@hapi/boom'; import type { Payload } from '@hapi/boom';
import { import {
SavedObjectsErrorHelpers, SavedObjectsErrorHelpers,

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { Logger } from '@kbn/logging'; import type { Logger } from '@kbn/logging';
import type { import type {
SavedObjectsFindOptions, SavedObjectsFindOptions,

View file

@ -14,7 +14,7 @@ import {
mockGetSearchDsl, mockGetSearchDsl,
} from './repository.test.mock'; } from './repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { SavedObjectsRepository } from './repository'; import { SavedObjectsRepository } from './repository';
import { loggerMock } from '@kbn/logging-mocks'; import { loggerMock } from '@kbn/logging-mocks';

View file

@ -17,7 +17,7 @@ import {
import { SavedObjectsRepository } from './repository'; import { SavedObjectsRepository } from './repository';
import { loggerMock } from '@kbn/logging-mocks'; import { loggerMock } from '@kbn/logging-mocks';
import { estypes } from '@elastic/elasticsearch'; import type { estypes } from '@elastic/elasticsearch';
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks'; import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import { SavedObjectsBulkUpdateObject } from '@kbn/core-saved-objects-api-server'; import { SavedObjectsBulkUpdateObject } from '@kbn/core-saved-objects-api-server';
import { SavedObjectsSerializer } from '@kbn/core-saved-objects-base-server-internal'; import { SavedObjectsSerializer } from '@kbn/core-saved-objects-base-server-internal';

View file

@ -18,7 +18,7 @@ import {
mockDeleteLegacyUrlAliases, mockDeleteLegacyUrlAliases,
} from './repository.test.mock'; } from './repository.test.mock';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { SavedObjectsRepository } from './repository'; import { SavedObjectsRepository } from './repository';
import { loggerMock } from '@kbn/logging-mocks'; import { loggerMock } from '@kbn/logging-mocks';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { validateAndConvertAggregations } from './validation'; import { validateAndConvertAggregations } from './validation';
type AggsMap = Record<string, estypes.AggregationsAggregationContainer>; type AggsMap = Record<string, estypes.AggregationsAggregationContainer>;

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { ObjectType } from '@kbn/config-schema'; import { ObjectType } from '@kbn/config-schema';
import { isPlainObject, isArray } from 'lodash'; import { isPlainObject, isArray } from 'lodash';

View file

@ -9,7 +9,7 @@
import Boom from '@hapi/boom'; import Boom from '@hapi/boom';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { SavedObjectsPitParams } from '@kbn/core-saved-objects-api-server'; import type { SavedObjectsPitParams } from '@kbn/core-saved-objects-api-server';
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server'; import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
import type { IndexMapping } from '@kbn/core-saved-objects-base-server-internal'; import type { IndexMapping } from '@kbn/core-saved-objects-base-server-internal';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { schema } from '@kbn/config-schema'; import { schema } from '@kbn/config-schema';
import { loggerMock } from '@kbn/logging-mocks'; import { loggerMock } from '@kbn/logging-mocks';
import type { Payload } from 'elastic-apm-node'; import type { Payload } from 'elastic-apm-node';

View file

@ -9,7 +9,7 @@
import * as Either from 'fp-ts/lib/Either'; import * as Either from 'fp-ts/lib/Either';
import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as TaskEither from 'fp-ts/lib/TaskEither';
import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { errors as esErrors } from '@elastic/elasticsearch'; import { errors as esErrors } from '@elastic/elasticsearch';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { import {

View file

@ -28,9 +28,7 @@ export const closePit =
({ client, pitId }: ClosePitParams): TaskEither.TaskEither<RetryableEsClientError, {}> => ({ client, pitId }: ClosePitParams): TaskEither.TaskEither<RetryableEsClientError, {}> =>
() => { () => {
return client return client
.closePointInTime({ .closePointInTime({ id: pitId })
body: { id: pitId },
})
.then((response) => { .then((response) => {
if (!response.succeeded) { if (!response.succeeded) {
throw new Error(`Failed to close PointInTime with id: ${pitId}`); throw new Error(`Failed to close PointInTime with id: ${pitId}`);

View file

@ -10,7 +10,7 @@
import * as Either from 'fp-ts/lib/Either'; import * as Either from 'fp-ts/lib/Either';
import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as TaskEither from 'fp-ts/lib/TaskEither';
import { pipe } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/function';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { import type {
ElasticsearchClient, ElasticsearchClient,
ElasticsearchCapabilities, ElasticsearchCapabilities,

View file

@ -9,7 +9,7 @@
import * as Either from 'fp-ts/lib/Either'; import * as Either from 'fp-ts/lib/Either';
import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as TaskEither from 'fp-ts/lib/TaskEither';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { errors as EsErrors } from '@elastic/elasticsearch'; import { errors as EsErrors } from '@elastic/elasticsearch';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server'; import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';

View file

@ -73,9 +73,7 @@ describe('reindex', () => {
/** ignore */ /** ignore */
} }
expect(client.reindex).toHaveBeenCalledTimes(1); expect(client.reindex).toHaveBeenCalledTimes(1);
expect(client.reindex).toHaveBeenCalledWith( expect(client.reindex).toHaveBeenCalledWith({
expect.objectContaining({
body: {
conflicts: 'proceed', conflicts: 'proceed',
source: { source: {
index: 'my_source_index', index: 'my_source_index',
@ -87,8 +85,9 @@ describe('reindex', () => {
op_type: 'create', op_type: 'create',
}, },
script: { lang: 'painless', source: 'my script' }, script: { lang: 'painless', source: 'my script' },
}, refresh: true,
}) require_alias: false,
); wait_for_completion: false,
});
}); });
}); });

View file

@ -62,7 +62,6 @@ export const reindex =
// Require targetIndex to be an alias. Prevents a new index from being // Require targetIndex to be an alias. Prevents a new index from being
// created if targetIndex doesn't exist. // created if targetIndex doesn't exist.
require_alias: requireAlias, require_alias: requireAlias,
body: {
// Ignore version conflicts from existing documents // Ignore version conflicts from existing documents
conflicts: 'proceed', conflicts: 'proceed',
source: { source: {
@ -84,7 +83,6 @@ export const reindex =
lang: 'painless', lang: 'painless',
}) })
)(reindexScript), )(reindexScript),
},
// force a refresh so that we can query the target index // force a refresh so that we can query the target index
refresh: true, refresh: true,
// Create a task and return task id instead of blocking until complete // Create a task and return task id instead of blocking until complete

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import * as Either from 'fp-ts/lib/Either'; import * as Either from 'fp-ts/lib/Either';
import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as TaskEither from 'fp-ts/lib/TaskEither';
import * as Option from 'fp-ts/lib/Option'; import * as Option from 'fp-ts/lib/Option';

View file

@ -174,13 +174,11 @@ describe('unknown saved object types deprecation', () => {
expect(esClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({ expect(esClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({
index: ['foo-index', 'bar-index'], index: ['foo-index', 'bar-index'],
wait_for_completion: false, wait_for_completion: false,
body: {
query: { query: {
bool: { bool: {
must_not: [{ term: { type: 'foo' } }, { term: { type: 'bar' } }], must_not: [{ term: { type: 'foo' } }, { term: { type: 'bar' } }],
}, },
}, },
},
}); });
}); });
}); });

View file

@ -141,8 +141,6 @@ export const deleteUnknownTypeObjects = async ({
await esClient.asInternalUser.deleteByQuery({ await esClient.asInternalUser.deleteByQuery({
index: targetIndices, index: targetIndices,
wait_for_completion: false, wait_for_completion: false,
body: {
query: nonRegisteredTypesQuery, query: nonRegisteredTypesQuery,
},
}); });
}; };

View file

@ -182,7 +182,6 @@ export class CoreUsageDataService
{ aliases: UsageDataAggs } { aliases: UsageDataAggs }
>({ >({
index: MAIN_SAVED_OBJECT_INDEX, // depends on the .kibana split (assuming 'legacy-url-alias' is stored in '.kibana') index: MAIN_SAVED_OBJECT_INDEX, // depends on the .kibana split (assuming 'legacy-url-alias' is stored in '.kibana')
body: {
track_total_hits: true, track_total_hits: true,
query: { match: { type: LEGACY_URL_ALIAS_TYPE } }, query: { match: { type: LEGACY_URL_ALIAS_TYPE } },
aggs: { aggs: {
@ -201,7 +200,6 @@ export class CoreUsageDataService
}, },
}, },
size: 0, size: 0,
},
}); });
const { hits, aggregations } = resp; const { hits, aggregations } = resp;

View file

@ -9,11 +9,12 @@
module.exports = { module.exports = {
bail: true, // only report 1 issue bail: true, // only report 1 issue
// TODO replace the line below with // TODO remove the line below once we've addressed all the open handles
// preset: '@kbn/test/jest_integration_node // We stop the server very soon, and plugins installing (and retrying indices) might keep Kibana running until a timeout occurs.
// to do so, we must fix all integration tests first // to do so, we must fix all integration tests first
// see https://github.com/elastic/kibana/pull/130255/ // see https://github.com/elastic/kibana/pull/130255/
preset: '@kbn/test/jest_integration', forceExit: true,
preset: '@kbn/test/jest_integration_node',
rootDir: '../../../../..', rootDir: '../../../../..',
roots: ['<rootDir>/src/core/server/integration_tests/ci_checks'], roots: ['<rootDir>/src/core/server/integration_tests/ci_checks'],
// must override to match all test given there is no `integration_tests` subfolder // must override to match all test given there is no `integration_tests` subfolder

View file

@ -138,12 +138,10 @@ describe('migration actions', () => {
describe('fetchIndices', () => { describe('fetchIndices', () => {
afterAll(async () => { afterAll(async () => {
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Reset persistent test settings // Reset persistent test settings
cluster: { routing: { allocation: { enable: null } } }, cluster: { routing: { allocation: { enable: null } } },
}, },
},
}); });
}); });
it('resolves right empty record if no indices were found', async () => { it('resolves right empty record if no indices were found', async () => {
@ -209,12 +207,10 @@ describe('migration actions', () => {
it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => { it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => {
expect.assertions(3); expect.assertions(3);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Disable all routing allocation // Disable all routing allocation
cluster: { routing: { allocation: { enable: 'none' } } }, cluster: { routing: { allocation: { enable: 'none' } } },
}, },
},
}); });
const task = checkClusterRoutingAllocationEnabled(client); const task = checkClusterRoutingAllocationEnabled(client);
await expect(task()).resolves.toMatchInlineSnapshot(` await expect(task()).resolves.toMatchInlineSnapshot(`
@ -226,12 +222,10 @@ describe('migration actions', () => {
} }
`); `);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Allow routing to existing primaries only // Allow routing to existing primaries only
cluster: { routing: { allocation: { enable: 'primaries' } } }, cluster: { routing: { allocation: { enable: 'primaries' } } },
}, },
},
}); });
const task2 = checkClusterRoutingAllocationEnabled(client); const task2 = checkClusterRoutingAllocationEnabled(client);
await expect(task2()).resolves.toMatchInlineSnapshot(` await expect(task2()).resolves.toMatchInlineSnapshot(`
@ -243,12 +237,10 @@ describe('migration actions', () => {
} }
`); `);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Allow routing to new primaries only // Allow routing to new primaries only
cluster: { routing: { allocation: { enable: 'new_primaries' } } }, cluster: { routing: { allocation: { enable: 'new_primaries' } } },
}, },
},
}); });
const task3 = checkClusterRoutingAllocationEnabled(client); const task3 = checkClusterRoutingAllocationEnabled(client);
await expect(task3()).resolves.toMatchInlineSnapshot(` await expect(task3()).resolves.toMatchInlineSnapshot(`
@ -263,11 +255,9 @@ describe('migration actions', () => {
it('resolves right when cluster.routing.allocation.enabled=all', async () => { it('resolves right when cluster.routing.allocation.enabled=all', async () => {
expect.assertions(1); expect.assertions(1);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
cluster: { routing: { allocation: { enable: 'all' } } }, cluster: { routing: { allocation: { enable: 'all' } } },
}, },
},
}); });
const task = checkClusterRoutingAllocationEnabled(client); const task = checkClusterRoutingAllocationEnabled(client);
const result = await task(); const result = await task();
@ -398,7 +388,6 @@ describe('migration actions', () => {
await client.indices.create({ await client.indices.create({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -406,7 +395,6 @@ describe('migration actions', () => {
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
routing: { allocation: { enable: 'none' } }, routing: { allocation: { enable: 'none' } },
}, },
},
}); });
// Start tracking the index status // Start tracking the index status
@ -421,7 +409,7 @@ describe('migration actions', () => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
body: { settings: {
// Enable all shard allocation so that the index status turns yellow // Enable all shard allocation so that the index status turns yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -439,7 +427,6 @@ describe('migration actions', () => {
.create({ .create({
index: 'red_index', index: 'red_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate no replicas so that this index stays red // Allocate no replicas so that this index stays red
@ -447,7 +434,6 @@ describe('migration actions', () => {
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
// try to wait for index status yellow: // try to wait for index status yellow:
@ -474,13 +460,11 @@ describe('migration actions', () => {
.create({ .create({
index: 'yellow_index', index: 'yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate no replicas so that this index stays yellow // Allocate no replicas so that this index stays yellow
number_of_replicas: '0', number_of_replicas: '0',
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
// try to wait for index status yellow: // try to wait for index status yellow:
@ -546,7 +530,6 @@ describe('migration actions', () => {
.create({ .create({
index: 'clone_red_then_green_index', index: 'clone_red_then_green_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index can go to green // Allocate 1 replica so that this index can go to green
@ -554,7 +537,6 @@ describe('migration actions', () => {
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
@ -570,7 +552,7 @@ describe('migration actions', () => {
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'clone_red_then_green_index', index: 'clone_red_then_green_index',
body: { settings: {
// Enable all shard allocation so that the index status goes green // Enable all shard allocation so that the index status goes green
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -598,7 +580,6 @@ describe('migration actions', () => {
.create({ .create({
index: 'clone_red_index', index: 'clone_red_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -606,7 +587,6 @@ describe('migration actions', () => {
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
@ -633,7 +613,7 @@ describe('migration actions', () => {
await client.indices.putSettings({ await client.indices.putSettings({
index: 'clone_red_index', index: 'clone_red_index',
body: { settings: {
// Enable all shard allocation so that the index status goes yellow // Enable all shard allocation so that the index status goes yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -662,7 +642,7 @@ describe('migration actions', () => {
await client.indices.putSettings({ await client.indices.putSettings({
index: 'clone_red_index', index: 'clone_red_index',
body: { settings: {
// Set zero replicas so status goes green // Set zero replicas so status goes green
number_of_replicas: 0, number_of_replicas: 0,
}, },
@ -1126,11 +1106,7 @@ describe('migration actions', () => {
expect(pitResponse.right.pitId).toEqual(expect.any(String)); expect(pitResponse.right.pitId).toEqual(expect.any(String));
const searchResponse = await client.search({ const searchResponse = await client.search({ pit: { id: pitResponse.right.pitId } });
body: {
pit: { id: pitResponse.right.pitId },
},
});
await expect(searchResponse.hits.hits.length).toBeGreaterThan(0); await expect(searchResponse.hits.hits.length).toBeGreaterThan(0);
}); });
@ -1346,11 +1322,7 @@ describe('migration actions', () => {
const pitId = pitResponse.right.pitId; const pitId = pitResponse.right.pitId;
await closePit({ client, pitId })(); await closePit({ client, pitId })();
const searchTask = client.search({ const searchTask = client.search({ pit: { id: pitId } });
body: {
pit: { id: pitId },
},
});
await expect(searchTask).rejects.toThrow('search_phase_execution_exception'); await expect(searchTask).rejects.toThrow('search_phase_execution_exception');
}); });
@ -1811,7 +1783,6 @@ describe('migration actions', () => {
.create({ .create({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -1819,7 +1790,6 @@ describe('migration actions', () => {
// Disable all shard allocation so that the index status starts as red // Disable all shard allocation so that the index status starts as red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => { .catch((e) => {
/** ignore */ /** ignore */
@ -1840,7 +1810,7 @@ describe('migration actions', () => {
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
body: { settings: {
// Renable allocation so that the status becomes yellow // Renable allocation so that the status becomes yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -1869,13 +1839,11 @@ describe('migration actions', () => {
.create({ .create({
index: 'yellow_then_green_index', index: 'yellow_then_green_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
number_of_replicas: '1', number_of_replicas: '1',
}, },
},
}) })
.catch((e) => { .catch((e) => {
/** ignore */ /** ignore */
@ -1893,7 +1861,7 @@ describe('migration actions', () => {
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'yellow_then_green_index', index: 'yellow_then_green_index',
body: { settings: {
// Set 0 replican so that this index becomes green // Set 0 replican so that this index becomes green
number_of_replicas: '0', number_of_replicas: '0',
}, },

View file

@ -176,12 +176,10 @@ export const runActionTestSuite = ({
describe('fetchIndices', () => { describe('fetchIndices', () => {
afterAll(async () => { afterAll(async () => {
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Reset persistent test settings // Reset persistent test settings
cluster: { routing: { allocation: { enable: null } } }, cluster: { routing: { allocation: { enable: null } } },
}, },
},
}); });
}); });
it('resolves right empty record if no indices were found', async () => { it('resolves right empty record if no indices were found', async () => {
@ -247,12 +245,10 @@ export const runActionTestSuite = ({
it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => { it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => {
expect.assertions(3); expect.assertions(3);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Disable all routing allocation // Disable all routing allocation
cluster: { routing: { allocation: { enable: 'none' } } }, cluster: { routing: { allocation: { enable: 'none' } } },
}, },
},
}); });
const task = checkClusterRoutingAllocationEnabled(client); const task = checkClusterRoutingAllocationEnabled(client);
await expect(task()).resolves.toMatchInlineSnapshot(` await expect(task()).resolves.toMatchInlineSnapshot(`
@ -264,12 +260,10 @@ export const runActionTestSuite = ({
} }
`); `);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Allow routing to existing primaries only // Allow routing to existing primaries only
cluster: { routing: { allocation: { enable: 'primaries' } } }, cluster: { routing: { allocation: { enable: 'primaries' } } },
}, },
},
}); });
const task2 = checkClusterRoutingAllocationEnabled(client); const task2 = checkClusterRoutingAllocationEnabled(client);
await expect(task2()).resolves.toMatchInlineSnapshot(` await expect(task2()).resolves.toMatchInlineSnapshot(`
@ -281,12 +275,10 @@ export const runActionTestSuite = ({
} }
`); `);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
// Allow routing to new primaries only // Allow routing to new primaries only
cluster: { routing: { allocation: { enable: 'new_primaries' } } }, cluster: { routing: { allocation: { enable: 'new_primaries' } } },
}, },
},
}); });
const task3 = checkClusterRoutingAllocationEnabled(client); const task3 = checkClusterRoutingAllocationEnabled(client);
await expect(task3()).resolves.toMatchInlineSnapshot(` await expect(task3()).resolves.toMatchInlineSnapshot(`
@ -301,11 +293,9 @@ export const runActionTestSuite = ({
it('resolves right when cluster.routing.allocation.enabled=all', async () => { it('resolves right when cluster.routing.allocation.enabled=all', async () => {
expect.assertions(1); expect.assertions(1);
await client.cluster.putSettings({ await client.cluster.putSettings({
body: {
persistent: { persistent: {
cluster: { routing: { allocation: { enable: 'all' } } }, cluster: { routing: { allocation: { enable: 'all' } } },
}, },
},
}); });
const task = checkClusterRoutingAllocationEnabled(client); const task = checkClusterRoutingAllocationEnabled(client);
const result = await task(); const result = await task();
@ -436,7 +426,6 @@ export const runActionTestSuite = ({
{ {
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -445,7 +434,6 @@ export const runActionTestSuite = ({
routing: { allocation: { enable: 'none' } }, routing: { allocation: { enable: 'none' } },
}, },
}, },
},
{ maxRetries: 0 /** handle retry ourselves for now */ } { maxRetries: 0 /** handle retry ourselves for now */ }
); );
@ -461,7 +449,7 @@ export const runActionTestSuite = ({
void client.indices.putSettings({ void client.indices.putSettings({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
body: { settings: {
// Enable all shard allocation so that the index status turns yellow // Enable all shard allocation so that the index status turns yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -483,7 +471,6 @@ export const runActionTestSuite = ({
.create({ .create({
index: 'red_index', index: 'red_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate no replicas so that this index stays red // Allocate no replicas so that this index stays red
@ -491,7 +478,6 @@ export const runActionTestSuite = ({
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
// try to wait for index status yellow: // try to wait for index status yellow:
@ -518,13 +504,11 @@ export const runActionTestSuite = ({
.create({ .create({
index: 'yellow_index', index: 'yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate no replicas so that this index stays yellow // Allocate no replicas so that this index stays yellow
number_of_replicas: '0', number_of_replicas: '0',
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
// try to wait for index status yellow: // try to wait for index status yellow:
@ -580,8 +564,7 @@ export const runActionTestSuite = ({
const { clone_target_1: cloneTarget1 } = await client.indices.getSettings({ const { clone_target_1: cloneTarget1 } = await client.indices.getSettings({
index: 'clone_target_1', index: 'clone_target_1',
}); });
// @ts-expect-error https://github.com/elastic/elasticsearch/issues/89381 expect(cloneTarget1.settings?.index?.mapping?.total_fields?.limit).toBe('1500');
expect(cloneTarget1.settings?.index.mapping?.total_fields.limit).toBe('1500');
expect(cloneTarget1.settings?.blocks?.write).toBeUndefined(); expect(cloneTarget1.settings?.blocks?.write).toBeUndefined();
}); });
it('resolves right if clone target already existed after waiting for index status to be green ', async () => { it('resolves right if clone target already existed after waiting for index status to be green ', async () => {
@ -592,7 +575,6 @@ export const runActionTestSuite = ({
.create({ .create({
index: 'clone_red_then_green_index', index: 'clone_red_then_green_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index can go to green // Allocate 1 replica so that this index can go to green
@ -600,7 +582,6 @@ export const runActionTestSuite = ({
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
@ -616,7 +597,7 @@ export const runActionTestSuite = ({
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'clone_red_then_green_index', index: 'clone_red_then_green_index',
body: { settings: {
// Enable all shard allocation so that the index status goes green // Enable all shard allocation so that the index status goes green
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -644,7 +625,6 @@ export const runActionTestSuite = ({
.create({ .create({
index: 'clone_red_index', index: 'clone_red_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -652,7 +632,6 @@ export const runActionTestSuite = ({
// Disable all shard allocation so that the index status is red // Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
},
}) })
.catch((e) => {}); .catch((e) => {});
@ -679,7 +658,7 @@ export const runActionTestSuite = ({
await client.indices.putSettings({ await client.indices.putSettings({
index: 'clone_red_index', index: 'clone_red_index',
body: { settings: {
// Enable all shard allocation so that the index status goes yellow // Enable all shard allocation so that the index status goes yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -708,7 +687,7 @@ export const runActionTestSuite = ({
await client.indices.putSettings({ await client.indices.putSettings({
index: 'clone_red_index', index: 'clone_red_index',
body: { settings: {
// Set zero replicas so status goes green // Set zero replicas so status goes green
number_of_replicas: 0, number_of_replicas: 0,
}, },
@ -1178,11 +1157,7 @@ export const runActionTestSuite = ({
expect(pitResponse.right.pitId).toEqual(expect.any(String)); expect(pitResponse.right.pitId).toEqual(expect.any(String));
const searchResponse = await client.search({ const searchResponse = await client.search({ pit: { id: pitResponse.right.pitId } });
body: {
pit: { id: pitResponse.right.pitId },
},
});
await expect(searchResponse.hits.hits.length).toBeGreaterThan(0); await expect(searchResponse.hits.hits.length).toBeGreaterThan(0);
}); });
@ -1398,11 +1373,7 @@ export const runActionTestSuite = ({
const pitId = pitResponse.right.pitId; const pitId = pitResponse.right.pitId;
await closePit({ client, pitId })(); await closePit({ client, pitId })();
const searchTask = client.search({ const searchTask = client.search({ pit: { id: pitId } });
body: {
pit: { id: pitId },
},
});
await expect(searchTask).rejects.toThrow('search_phase_execution_exception'); await expect(searchTask).rejects.toThrow('search_phase_execution_exception');
}); });
@ -1867,7 +1838,6 @@ export const runActionTestSuite = ({
{ {
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
@ -1876,7 +1846,6 @@ export const runActionTestSuite = ({
index: { routing: { allocation: { enable: 'none' } } }, index: { routing: { allocation: { enable: 'none' } } },
}, },
}, },
},
{ maxRetries: 0 /** handle retry ourselves for now */ } { maxRetries: 0 /** handle retry ourselves for now */ }
) )
.catch((e) => { .catch((e) => {
@ -1895,7 +1864,7 @@ export const runActionTestSuite = ({
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'red_then_yellow_index', index: 'red_then_yellow_index',
body: { settings: {
// Renable allocation so that the status becomes yellow // Renable allocation so that the status becomes yellow
routing: { allocation: { enable: 'all' } }, routing: { allocation: { enable: 'all' } },
}, },
@ -1924,13 +1893,11 @@ export const runActionTestSuite = ({
.create({ .create({
index: 'yellow_then_green_index', index: 'yellow_then_green_index',
timeout: '5s', timeout: '5s',
body: {
mappings: { properties: {} }, mappings: { properties: {} },
settings: { settings: {
// Allocate 1 replica so that this index stays yellow // Allocate 1 replica so that this index stays yellow
number_of_replicas: '1', number_of_replicas: '1',
}, },
},
}) })
.catch((e) => { .catch((e) => {
/** ignore */ /** ignore */
@ -1948,7 +1915,7 @@ export const runActionTestSuite = ({
setTimeout(() => { setTimeout(() => {
void client.indices.putSettings({ void client.indices.putSettings({
index: 'yellow_then_green_index', index: 'yellow_then_green_index',
body: { settings: {
// Set 0 replican so that this index becomes green // Set 0 replican so that this index becomes green
number_of_replicas: '0', number_of_replicas: '0',
}, },

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import { InternalCoreStart } from '@kbn/core-lifecycle-server-internal'; import { InternalCoreStart } from '@kbn/core-lifecycle-server-internal';
import { Root } from '@kbn/core-root-server-internal'; import { Root } from '@kbn/core-root-server-internal';
import { elasticsearchServiceMock } from '@kbn/core-elasticsearch-server-mocks'; import { elasticsearchServiceMock } from '@kbn/core-elasticsearch-server-mocks';
@ -68,7 +68,7 @@ describe('Elasticsearch Errors', () => {
index: 'existing_index_with_write_block', index: 'existing_index_with_write_block',
id: 'some-id', id: 'some-id',
op_type: 'index', op_type: 'index',
body: { document: {
hello: 'dolly', hello: 'dolly',
}, },
}, },
@ -98,7 +98,7 @@ describe('Elasticsearch Errors', () => {
it('correctly identify errors from bulk index operations', async () => { it('correctly identify errors from bulk index operations', async () => {
const res = await client.bulk({ const res = await client.bulk({
refresh: 'wait_for', refresh: 'wait_for',
body: [ operations: [
{ {
index: { index: {
_index: 'existing_index_with_write_block', _index: 'existing_index_with_write_block',
@ -119,7 +119,7 @@ describe('Elasticsearch Errors', () => {
it('correctly identify errors from bulk create operations', async () => { it('correctly identify errors from bulk create operations', async () => {
const res = await client.bulk({ const res = await client.bulk({
refresh: 'wait_for', refresh: 'wait_for',
body: [ operations: [
{ {
create: { create: {
_index: 'existing_index_with_write_block', _index: 'existing_index_with_write_block',

View file

@ -38,7 +38,6 @@ async function fetchDocs(esClient: ElasticsearchClient, index: string, type: str
const body = await esClient.search<any>({ const body = await esClient.search<any>({
index, index,
size: 10000, size: 10000,
body: {
query: { query: {
bool: { bool: {
should: [ should: [
@ -48,7 +47,6 @@ async function fetchDocs(esClient: ElasticsearchClient, index: string, type: str
], ],
}, },
}, },
},
}); });
return body.hits.hits return body.hits.hits

View file

@ -102,7 +102,7 @@ describe('getOutdatedDocumentsQuery', () => {
await client.bulk({ await client.bulk({
refresh: 'true', refresh: 'true',
body: bulkCreateParams, operations: bulkCreateParams,
}); });
return { client }; return { client };

View file

@ -75,13 +75,11 @@ describe('POST /internal/saved_objects/deprecations/_delete_unknown_types', () =
expect(elasticsearchClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({ expect(elasticsearchClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({
index: ['known-type-index_8.0.0'], index: ['known-type-index_8.0.0'],
wait_for_completion: false, wait_for_completion: false,
body: {
query: { query: {
bool: { bool: {
must_not: expect.any(Array), must_not: expect.any(Array),
}, },
}, },
},
}); });
}); });
}); });

View file

@ -24,9 +24,7 @@ export const docExistsSuite = (savedObjectsIndex: string) => () => {
await esClient.deleteByQuery({ await esClient.deleteByQuery({
index: savedObjectsIndex, index: savedObjectsIndex,
conflicts: 'proceed', conflicts: 'proceed',
body: {
query: { match_all: {} }, query: { match_all: {} },
},
refresh: true, refresh: true,
wait_for_completion: true, wait_for_completion: true,
}); });

View file

@ -19,9 +19,7 @@ export const docMissingSuite = (savedObjectsIndex: string) => () => {
// delete all docs from kibana index to ensure savedConfig is not found // delete all docs from kibana index to ensure savedConfig is not found
await esClient.deleteByQuery({ await esClient.deleteByQuery({
index: savedObjectsIndex, index: savedObjectsIndex,
body: {
query: { match_all: {} }, query: { match_all: {} },
},
}); });
}); });

View file

@ -116,6 +116,7 @@ const getServerlessESClient = ({ port }: { port: number }) => {
return new Client({ return new Client({
node: `http://localhost:${port}`, node: `http://localhost:${port}`,
Connection: HttpConnection, Connection: HttpConnection,
requestTimeout: 30_000,
auth: { ...systemIndicesSuperuser }, auth: { ...systemIndicesSuperuser },
}); });
}; };

View file

@ -28,11 +28,11 @@ export const ingestList = (log) => async (xs) => {
async function bulkIngest() { async function bulkIngest() {
log.verbose(`\n${ccMark} Ingesting ${xs.length} docs at a time`); log.verbose(`\n${ccMark} Ingesting ${xs.length} docs at a time`);
const body = parseIndexes(xs); const operations = parseIndexes(xs);
const bulkResponse = await client.bulk({ refresh: true, body }); const bulkResponse = await client.bulk({ refresh: true, operations });
handleErrors(body, bulkResponse)(log); handleErrors(operations, bulkResponse)(log);
} }
}; };

View file

@ -102,6 +102,7 @@ export const KEBAB_CASE_DIRECTORY_GLOBS = [
'packages/*', 'packages/*',
'x-pack', 'x-pack',
'x-pack/packages/*', 'x-pack/packages/*',
'src/dev/packages/*',
'src/core/packages/*/*', 'src/core/packages/*/*',
'src/platform/packages/private/*', 'src/platform/packages/private/*',
'src/platform/packages/shared/*', 'src/platform/packages/shared/*',

View file

@ -377,7 +377,7 @@ describe('CsvGenerator', () => {
expect(mockDataClient.search).toHaveBeenCalledTimes(10); expect(mockDataClient.search).toHaveBeenCalledTimes(10);
expect(mockDataClient.search).toBeCalledWith( expect(mockDataClient.search).toBeCalledWith(
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } }, { params: { max_concurrent_shard_requests: 5 } },
{ {
abortSignal: expect.any(AbortSignal), abortSignal: expect.any(AbortSignal),
strategy: 'es', strategy: 'es',
@ -402,7 +402,7 @@ describe('CsvGenerator', () => {
expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledTimes(1); expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledTimes(1);
expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledWith({ expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledWith({
body: { id: mockCursorId }, id: mockCursorId,
}); });
}); });
@ -676,7 +676,7 @@ describe('CsvGenerator', () => {
); );
expect(mockDataClientSearchFn).toBeCalledWith( expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } }, { params: { max_concurrent_shard_requests: 5 } },
{ {
abortSignal: expect.any(AbortSignal), abortSignal: expect.any(AbortSignal),
strategy: 'es', strategy: 'es',
@ -762,7 +762,7 @@ describe('CsvGenerator', () => {
); );
expect(mockDataClientSearchFn).toBeCalledWith( expect(mockDataClientSearchFn).toBeCalledWith(
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } }, { params: { max_concurrent_shard_requests: 5 } },
{ {
abortSignal: expect.any(AbortSignal), abortSignal: expect.any(AbortSignal),
strategy: 'es', strategy: 'es',
@ -1439,7 +1439,6 @@ describe('CsvGenerator', () => {
expect(mockDataClient.search).toBeCalledWith( expect(mockDataClient.search).toBeCalledWith(
{ {
params: { params: {
body: {},
max_concurrent_shard_requests: 5, max_concurrent_shard_requests: 5,
}, },
}, },

View file

@ -101,10 +101,10 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledTimes(1); expect(dataSearchSpy).toBeCalledTimes(1);
expect(dataSearchSpy).toBeCalledWith( expect(dataSearchSpy).toBeCalledWith(
{ {
params: { params: expect.objectContaining({
body: expect.objectContaining({ pit: { id: 'somewhat-pit-id', keep_alive: '10m' } }), pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
max_concurrent_shard_requests: 5, max_concurrent_shard_requests: 5,
}, }),
}, },
expect.objectContaining({ expect.objectContaining({
strategy: 'es', strategy: 'es',
@ -160,14 +160,12 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith( expect(dataSearchSpy).toBeCalledWith(
{ {
params: { params: {
body: {
fields: [], fields: [],
pit: { id: 'somewhat-pit-id', keep_alive: '10m' }, pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
query: { bool: { filter: [], must: [], must_not: [], should: [] } }, query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {}, runtime_mappings: {},
script_fields: {}, script_fields: {},
stored_fields: ['*'], stored_fields: ['*'],
},
max_concurrent_shard_requests: undefined, max_concurrent_shard_requests: undefined,
}, },
}, },

View file

@ -80,7 +80,7 @@ export class SearchCursorPit extends SearchCursor {
const searchParamsPit = { const searchParamsPit = {
params: { params: {
body: searchBody, ...searchBody,
max_concurrent_shard_requests: effectiveMaxConcurrentShardRequests, max_concurrent_shard_requests: effectiveMaxConcurrentShardRequests,
}, },
}; };
@ -164,7 +164,7 @@ export class SearchCursorPit extends SearchCursor {
public async closeCursor() { public async closeCursor() {
if (this.cursorId) { if (this.cursorId) {
this.logger.debug(`Executing close PIT on ${this.formatCursorId(this.cursorId)}`); this.logger.debug(`Executing close PIT on ${this.formatCursorId(this.cursorId)}`);
await this.clients.es.asCurrentUser.closePointInTime({ body: { id: this.cursorId } }); await this.clients.es.asCurrentUser.closePointInTime({ id: this.cursorId });
} else { } else {
this.logger.warn(`No PIT Id to clear!`); this.logger.warn(`No PIT Id to clear!`);
} }

View file

@ -80,13 +80,11 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith( expect(dataSearchSpy).toBeCalledWith(
{ {
params: { params: {
body: {
fields: [], fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } }, query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {}, runtime_mappings: {},
script_fields: {}, script_fields: {},
stored_fields: ['*'], stored_fields: ['*'],
},
ignore_throttled: undefined, ignore_throttled: undefined,
index: 'test-index-pattern-string', index: 'test-index-pattern-string',
max_concurrent_shard_requests: 5, max_concurrent_shard_requests: 5,
@ -135,13 +133,11 @@ describe('CSV Export Search Cursor', () => {
expect(dataSearchSpy).toBeCalledWith( expect(dataSearchSpy).toBeCalledWith(
{ {
params: { params: {
body: {
fields: [], fields: [],
query: { bool: { filter: [], must: [], must_not: [], should: [] } }, query: { bool: { filter: [], must: [], must_not: [], should: [] } },
runtime_mappings: {}, runtime_mappings: {},
script_fields: {}, script_fields: {},
stored_fields: ['*'], stored_fields: ['*'],
},
ignore_throttled: undefined, ignore_throttled: undefined,
index: 'test-index-pattern-string', index: 'test-index-pattern-string',
max_concurrent_shard_requests: undefined, max_concurrent_shard_requests: undefined,

View file

@ -38,7 +38,7 @@ export class SearchCursorScroll extends SearchCursor {
const searchParamsScan = { const searchParamsScan = {
params: { params: {
body: searchBody, ...searchBody,
index: this.indexPatternTitle, index: this.indexPatternTitle,
scroll: scroll.duration(taskInstanceFields), scroll: scroll.duration(taskInstanceFields),
size: scroll.size, size: scroll.size,

View file

@ -7,7 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client as ESClient, ClientOptions as ESClientOptions } from '@elastic/elasticsearch'; import {
Client as ESClient,
ClientOptions as ESClientOptions,
HttpConnection,
} from '@elastic/elasticsearch';
import { ToolingLog } from '@kbn/tooling-log'; import { ToolingLog } from '@kbn/tooling-log';
import { createFailError } from '@kbn/dev-cli-errors'; import { createFailError } from '@kbn/dev-cli-errors';
@ -28,7 +32,11 @@ export async function getValidatedESClient(
} }
): Promise<ESClient> { ): Promise<ESClient> {
const { log, cli = false } = helperSettings; const { log, cli = false } = helperSettings;
const es = new ESClient(esClientOptions); const es = new ESClient({
Connection: HttpConnection,
requestTimeout: 30_000,
...esClientOptions,
});
try { try {
const esInfo = await es.info(); const esInfo = await es.info();

View file

@ -16,7 +16,7 @@ import type {
AggregationsAggregationContainer, AggregationsAggregationContainer,
QueryDslQueryContainer, QueryDslQueryContainer,
SortCombinations, SortCombinations,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; } from '@elastic/elasticsearch/lib/api/types';
import { BASE_RAC_ALERTS_API_PATH } from '../constants'; import { BASE_RAC_ALERTS_API_PATH } from '../constants';
export interface UseGetAlertsGroupAggregationsQueryProps { export interface UseGetAlertsGroupAggregationsQueryProps {

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { ApmSynthtraceEsClient } from '../../..'; import { ApmSynthtraceEsClient } from '../../..';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
@ -26,6 +26,8 @@ export function getApmEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
const apmEsClient = new ApmSynthtraceEsClient({ const apmEsClient = new ApmSynthtraceEsClient({

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { EntitiesSynthtraceEsClient } from '../../lib/entities/entities_synthtrace_es_client'; import { EntitiesSynthtraceEsClient } from '../../lib/entities/entities_synthtrace_es_client';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
@ -24,6 +24,8 @@ export function getEntitiesEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
return new EntitiesSynthtraceEsClient({ return new EntitiesSynthtraceEsClient({

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { InfraSynthtraceEsClient } from '../../lib/infra/infra_synthtrace_es_client'; import { InfraSynthtraceEsClient } from '../../lib/infra/infra_synthtrace_es_client';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
@ -24,6 +24,8 @@ export function getInfraEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
return new InfraSynthtraceEsClient({ return new InfraSynthtraceEsClient({

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { LogsSynthtraceEsClient } from '../../lib/logs/logs_synthtrace_es_client'; import { LogsSynthtraceEsClient } from '../../lib/logs/logs_synthtrace_es_client';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
@ -24,6 +24,8 @@ export function getLogsEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
return new LogsSynthtraceEsClient({ return new LogsSynthtraceEsClient({

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
import { getEsClientTlsSettings } from './ssl'; import { getEsClientTlsSettings } from './ssl';
@ -24,6 +24,8 @@ export function getOtelSynthtraceEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
return new OtelSynthtraceEsClient({ return new OtelSynthtraceEsClient({

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import { Client } from '@elastic/elasticsearch'; import { Client, HttpConnection } from '@elastic/elasticsearch';
import { Logger } from '../../lib/utils/create_logger'; import { Logger } from '../../lib/utils/create_logger';
import { RunOptions } from './parse_run_cli_flags'; import { RunOptions } from './parse_run_cli_flags';
import { getEsClientTlsSettings } from './ssl'; import { getEsClientTlsSettings } from './ssl';
@ -24,6 +24,8 @@ export function getSyntheticsEsClient({
const client = new Client({ const client = new Client({
node: target, node: target,
tls: getEsClientTlsSettings(target), tls: getEsClientTlsSettings(target),
Connection: HttpConnection,
requestTimeout: 30_000,
}); });
return new SyntheticsSynthtraceEsClient({ return new SyntheticsSynthtraceEsClient({

View file

@ -33,7 +33,7 @@ import type {
SortOrder, SortOrder,
AggregationsAggregationContainer, AggregationsAggregationContainer,
SortResults, SortResults,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; } from '@elastic/elasticsearch/lib/api/types';
import type { import type {
MutatingOperationRefreshSetting, MutatingOperationRefreshSetting,

View file

@ -9,7 +9,7 @@
import { tabifyDocs, flattenHit } from './tabify_docs'; import { tabifyDocs, flattenHit } from './tabify_docs';
import { DataView } from '@kbn/data-views-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks'; import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { stubbedSavedObjectIndexPattern } from '@kbn/data-views-plugin/common/data_view.stub'; import { stubbedSavedObjectIndexPattern } from '@kbn/data-views-plugin/common/data_view.stub';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { isPlainObject } from 'lodash'; import { isPlainObject } from 'lodash';
import { import {
Datatable, Datatable,

View file

@ -8,7 +8,7 @@
*/ */
import type { DatatableColumn } from '@kbn/expressions-plugin/common'; import type { DatatableColumn } from '@kbn/expressions-plugin/common';
import type { MappingTimeSeriesMetricType } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { MappingTimeSeriesMetricType } from '@elastic/elasticsearch/lib/api/types';
import type { FieldSpec } from '@kbn/data-views-plugin/common'; import type { FieldSpec } from '@kbn/data-views-plugin/common';
/** /**

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchHit } from '@elastic/elasticsearch/lib/api/types';
import type { DatatableColumnMeta } from '@kbn/expressions-plugin/common'; import type { DatatableColumnMeta } from '@kbn/expressions-plugin/common';
export type { IgnoredReason, ShouldShowFieldInTableHandler } from './utils'; export type { IgnoredReason, ShouldShowFieldInTableHandler } from './utils';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchHit } from '@elastic/elasticsearch/lib/api/types';
import { KBN_FIELD_TYPES } from '@kbn/field-types'; import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { DataViewField } from '@kbn/data-views-plugin/public'; import type { DataViewField } from '@kbn/data-views-plugin/public';

View file

@ -110,6 +110,7 @@ export function runCli() {
node: esUrl, node: esUrl,
tls: esCa ? { ca: esCa } : undefined, tls: esCa ? { ca: esCa } : undefined,
Connection: HttpConnection, Connection: HttpConnection,
requestTimeout: 30_000,
}); });
addCleanupTask(() => client.close()); addCleanupTask(() => client.close());

View file

@ -109,7 +109,7 @@ export const createStubClient = (
return { statusCode: 404 }; return { statusCode: 404 };
}), }),
updateAliases: sinon.spy(async ({ body }) => { updateAliases: sinon.spy(async (body) => {
body.actions.forEach( body.actions.forEach(
({ add: { index, alias } }: { add: { index: string; alias: string } }) => { ({ add: { index, alias } }: { add: { index: string; alias: string } }) => {
if (!existingIndices.includes(index)) { if (!existingIndices.includes(index)) {

View file

@ -141,16 +141,12 @@ describe('esArchiver: createCreateIndexStream()', () => {
sinon.assert.calledWith(client.indices.create as sinon.SinonSpy, { sinon.assert.calledWith(client.indices.create as sinon.SinonSpy, {
index: 'index', index: 'index',
body: {
settings: undefined, settings: undefined,
mappings: undefined, mappings: undefined,
},
}); });
sinon.assert.calledWith(client.indices.updateAliases as sinon.SinonSpy, { sinon.assert.calledWith(client.indices.updateAliases as sinon.SinonSpy, {
body: {
actions: [{ add: { alias: 'foo', index: 'index' } }], actions: [{ add: { alias: 'foo', index: 'index' } }],
},
}); });
}); });
@ -343,9 +339,10 @@ describe('esArchiver: createCreateIndexStream()', () => {
// only update aliases for the 'new-index' // only update aliases for the 'new-index'
sinon.assert.callCount(client.indices.updateAliases as sinon.SinonSpy, 1); sinon.assert.callCount(client.indices.updateAliases as sinon.SinonSpy, 1);
expect((client.indices.updateAliases as sinon.SinonSpy).args[0][0]).toHaveProperty('body', { expect((client.indices.updateAliases as sinon.SinonSpy).args[0][0]).toHaveProperty(
actions: [{ add: { alias: 'new-index-alias', index: 'new-index' } }], 'actions',
}); [{ add: { alias: 'new-index-alias', index: 'new-index' } }]
);
}); });
it('filters documents for skipped indices', async () => { it('filters documents for skipped indices', async () => {

View file

@ -10,7 +10,7 @@
import { Transform, Readable } from 'stream'; import { Transform, Readable } from 'stream';
import { inspect } from 'util'; import { inspect } from 'util';
import * as estypes from '@elastic/elasticsearch/lib/api/types'; import type { estypes } from '@elastic/elasticsearch';
import type { Client } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch';
import { ToolingLog } from '@kbn/tooling-log'; import { ToolingLog } from '@kbn/tooling-log';
@ -162,11 +162,9 @@ export function createCreateIndexStream({
await client.indices.create( await client.indices.create(
{ {
index, index,
body: {
settings, settings,
mappings, mappings,
}, },
},
{ {
headers: ES_CLIENT_HEADERS, headers: ES_CLIENT_HEADERS,
} }
@ -184,7 +182,7 @@ export function createCreateIndexStream({
); );
if (actions.length) { if (actions.length) {
await client.indices.updateAliases({ body: { actions } }); await client.indices.updateAliases({ actions });
} }
stats.createdIndex(index, { settings }); stats.createdIndex(index, { settings });

View file

@ -45,7 +45,7 @@ export async function deleteSavedObjectIndices({
await client.indices.putSettings( await client.indices.putSettings(
{ {
index: indexNames, index: indexNames,
body: { blocks: { read_only: false } }, settings: { blocks: { read_only: false } },
}, },
{ {
headers: ES_CLIENT_HEADERS, headers: ES_CLIENT_HEADERS,
@ -123,7 +123,6 @@ export async function cleanSavedObjectIndices({
{ {
index, index,
refresh: true, refresh: true,
body: {
query: { query: {
bool: { bool: {
must_not: { must_not: {
@ -134,7 +133,6 @@ export async function cleanSavedObjectIndices({
}, },
}, },
}, },
},
{ {
ignore: [404, 409], ignore: [404, 409],
headers: ES_CLIENT_HEADERS, headers: ES_CLIENT_HEADERS,
@ -168,7 +166,7 @@ export async function createDefaultSpace({ index, client }: { index: string; cli
index, index,
id: 'space:default', id: 'space:default',
refresh: 'wait_for', refresh: 'wait_for',
body: { document: {
type: 'space', type: 'space',
updated_at: new Date().toISOString(), updated_at: new Date().toISOString(),
space: { space: {

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { SerializableRecord } from '@kbn/utility-types'; import { SerializableRecord } from '@kbn/utility-types';
import { extend, defaults } from 'lodash'; import { extend, defaults } from 'lodash';
import { getTimeZoneFromSettings } from '../utils'; import { getTimeZoneFromSettings } from '../utils';

View file

@ -8,7 +8,7 @@
*/ */
import { isUndefined } from 'lodash'; import { isUndefined } from 'lodash';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { migrateFilter } from './migrate_filter'; import { migrateFilter } from './migrate_filter';
import { filterMatchesIndex } from './filter_matches_index'; import { filterMatchesIndex } from './filter_matches_index';
import { Filter, cleanFilter, isFilterDisabled } from '../filters'; import { Filter, cleanFilter, isFilterDisabled } from '../filters';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { isString } from 'lodash'; import { isString } from 'lodash';
/** /**

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
/** /**
* A field's sub type * A field's sub type

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { Filter, FilterMeta, FILTERS, FilterStateStore } from './types'; import { Filter, FilterMeta, FILTERS, FilterStateStore } from './types';
/** @public */ /** @public */

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import type { SerializableRecord } from '@kbn/utility-types'; import type { SerializableRecord } from '@kbn/utility-types';
import { has } from 'lodash'; import { has } from 'lodash';
import type { Filter, FilterMeta } from './types'; import type { Filter, FilterMeta } from './types';

View file

@ -18,7 +18,7 @@ import {
} from './phrase_filter'; } from './phrase_filter';
import { fields, getField } from '../stubs'; import { fields, getField } from '../stubs';
import { DataViewBase } from '../../es_query'; import { DataViewBase } from '../../es_query';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { Filter } from './types'; import { Filter } from './types';
describe('Phrase filter builder', () => { describe('Phrase filter builder', () => {

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import type { SerializableRecord } from '@kbn/utility-types'; import type { SerializableRecord } from '@kbn/utility-types';
import { get, has, isPlainObject } from 'lodash'; import { get, has, isPlainObject } from 'lodash';
import type { Filter, FilterMeta } from './types'; import type { Filter, FilterMeta } from './types';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { Filter, FilterMeta, FILTERS } from './types'; import { Filter, FilterMeta, FILTERS } from './types';
import { getPhraseScript, PhraseFilterValue } from './phrase_filter'; import { getPhraseScript, PhraseFilterValue } from './phrase_filter';
import type { DataViewFieldBase, DataViewBaseNoFields } from '../../es_query'; import type { DataViewFieldBase, DataViewBaseNoFields } from '../../es_query';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { map, reduce, mapValues, has, get, keys, pickBy } from 'lodash'; import { map, reduce, mapValues, has, get, keys, pickBy } from 'lodash';
import type { SerializableRecord } from '@kbn/utility-types'; import type { SerializableRecord } from '@kbn/utility-types';
import type { Filter, FilterMeta, FilterMetaParams } from './types'; import type { Filter, FilterMeta, FilterMetaParams } from './types';

View file

@ -8,7 +8,7 @@
*/ */
import { JsonObject } from '@kbn/utility-types'; import { JsonObject } from '@kbn/utility-types';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { nodeTypes } from '../node_types'; import { nodeTypes } from '../node_types';
import { KQLSyntaxError } from '../kuery_syntax_error'; import { KQLSyntaxError } from '../kuery_syntax_error';
import type { KqlContext, KueryNode, KueryParseOptions, KueryQueryOptions } from '../types'; import type { KqlContext, KueryNode, KueryParseOptions, KueryQueryOptions } from '../types';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import * as ast from '../ast'; import * as ast from '../ast';
import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..'; import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
import type { KqlFunctionNode } from '../node_types'; import type { KqlFunctionNode } from '../node_types';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import type { DataViewFieldBase, DataViewBase, KueryQueryOptions } from '../../..'; import type { DataViewFieldBase, DataViewBase, KueryQueryOptions } from '../../..';
import type { KqlFunctionNode, KqlLiteralNode } from '../node_types'; import type { KqlFunctionNode, KqlLiteralNode } from '../node_types';
import type { KqlContext } from '../types'; import type { KqlContext } from '../types';

View file

@ -12,7 +12,7 @@ import { fields } from '../../filters/stubs';
import * as is from './is'; import * as is from './is';
import { DataViewBase } from '../../..'; import { DataViewBase } from '../../..';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch';
import { KQL_NODE_TYPE_WILDCARD } from '../node_types/wildcard'; import { KQL_NODE_TYPE_WILDCARD } from '../node_types/wildcard';
import { KQL_NODE_TYPE_LITERAL } from '../node_types/literal'; import { KQL_NODE_TYPE_LITERAL } from '../node_types/literal';
import { KqlIsFunctionNode } from './is'; import { KqlIsFunctionNode } from './is';

View file

@ -8,7 +8,7 @@
*/ */
import { isUndefined } from 'lodash'; import { isUndefined } from 'lodash';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { getPhraseScript } from '../../filters'; import { getPhraseScript } from '../../filters';
import { getFields } from './utils/get_fields'; import { getFields } from './utils/get_fields';
import { getTimeZoneFromSettings, getDataViewFieldSubtypeNested } from '../../utils'; import { getTimeZoneFromSettings, getDataViewFieldSubtypeNested } from '../../utils';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import * as ast from '../ast'; import * as ast from '../ast';
import * as literal from '../node_types/literal'; import * as literal from '../node_types/literal';
import type { DataViewBase, KueryQueryOptions } from '../../..'; import type { DataViewBase, KueryQueryOptions } from '../../..';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import * as ast from '../ast'; import * as ast from '../ast';
import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..'; import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
import type { KqlFunctionNode } from '../node_types'; import type { KqlFunctionNode } from '../node_types';

View file

@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import * as ast from '../ast'; import * as ast from '../ast';
import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..'; import type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
import type { KqlFunctionNode } from '../node_types'; import type { KqlFunctionNode } from '../node_types';

Some files were not shown because too many files have changed in this diff Show more