mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
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:
parent
3492f12c6c
commit
52ab19db2d
1907 changed files with 27841 additions and 30485 deletions
|
@ -330,7 +330,7 @@ export class EsoModelVersionExample
|
|||
const objectsCreated = await Promise.all(
|
||||
documentVersionConstants.map(async (obj) => {
|
||||
const createdDoc: WriteResponseBase =
|
||||
await elasticsearch.client.asInternalUser.create(obj);
|
||||
await elasticsearch.client.asInternalUser.create<unknown>(obj);
|
||||
const parts = createdDoc._id.split(':', 2);
|
||||
return { type: parts[0], id: parts[1] };
|
||||
})
|
||||
|
|
|
@ -181,13 +181,15 @@ export const SearchExamplesApp = ({
|
|||
const aggs = [{ type: metricAggType, params: { field: selectedNumericField!.name } }];
|
||||
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();
|
||||
|
||||
const body = {
|
||||
aggs: aggsDsl,
|
||||
query,
|
||||
};
|
||||
|
||||
const req = {
|
||||
params: {
|
||||
index: dataView.title,
|
||||
body: {
|
||||
aggs: aggsDsl,
|
||||
query,
|
||||
},
|
||||
...body,
|
||||
},
|
||||
// Add a custom request parameter to be consumed by `MyStrategy`.
|
||||
...(strategy ? { get_cool: getCool } : {}),
|
||||
|
@ -197,7 +199,7 @@ export const SearchExamplesApp = ({
|
|||
setAbortController(abortController);
|
||||
|
||||
// Submit the search request using the `data.search` service.
|
||||
setRequest(req.params.body);
|
||||
setRequest(body);
|
||||
setRawResponse({});
|
||||
setWarningContents([]);
|
||||
setIsLoading(true);
|
||||
|
|
|
@ -707,10 +707,8 @@ function doSearch(
|
|||
const req = {
|
||||
params: {
|
||||
index: dataView.title,
|
||||
body: {
|
||||
aggs: aggsDsl,
|
||||
query,
|
||||
},
|
||||
aggs: aggsDsl,
|
||||
query,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -39,12 +39,10 @@ export function registerServerSearchRoute(router: IRouter<DataRequestHandlerCont
|
|||
{
|
||||
params: {
|
||||
index,
|
||||
body: {
|
||||
aggs: {
|
||||
'1': {
|
||||
avg: {
|
||||
field,
|
||||
},
|
||||
aggs: {
|
||||
'1': {
|
||||
avg: {
|
||||
field,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -44,10 +44,8 @@ function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart })
|
|||
.search({
|
||||
params: {
|
||||
index: dataView?.getIndexPattern(),
|
||||
body: {
|
||||
fields: ['*'],
|
||||
_source: false,
|
||||
},
|
||||
fields: ['*'],
|
||||
_source: false,
|
||||
},
|
||||
})
|
||||
.toPromise();
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
"@elastic/datemath": "5.0.3",
|
||||
"@elastic/ebt": "^1.1.1",
|
||||
"@elastic/ecs": "^8.11.5",
|
||||
"@elastic/elasticsearch": "^8.17.0",
|
||||
"@elastic/elasticsearch": "9.0.0-alpha.3",
|
||||
"@elastic/ems-client": "8.6.3",
|
||||
"@elastic/eui": "99.2.0-borealis.0",
|
||||
"@elastic/eui-theme-borealis": "0.0.10",
|
||||
|
|
|
@ -37,6 +37,7 @@ export async function reportFailuresToEs(log: ToolingLog, failures: TestFailure[
|
|||
password: process.env.TEST_FAILURES_ES_PASSWORD,
|
||||
},
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
const body = failures.flatMap((failure) => [
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { SearchRequest, MsearchRequestItem } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { ToolingLog } from '@kbn/tooling-log';
|
||||
|
@ -109,6 +109,8 @@ export class ESClient {
|
|||
username: options.username,
|
||||
password: options.password,
|
||||
},
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
this.log = log;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ export class ElasticsearchService
|
|||
|
||||
this.esNodesCompatibility$ = esNodesCompatibility$;
|
||||
|
||||
this.clusterInfo$ = getClusterInfo$(this.client.asInternalUser);
|
||||
this.clusterInfo$ = getClusterInfo$(this.client.asInternalUser).pipe(takeUntil(this.stop$));
|
||||
registerAnalyticsContextProvider(deps.analytics, this.clusterInfo$);
|
||||
|
||||
return {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 { isInlineScriptingEnabled } from './is_scripting_enabled';
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from '../repository.test.mock';
|
||||
|
||||
import type { Payload } from '@hapi/boom';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import type {
|
||||
SavedObjectsBulkDeleteObject,
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
getSavedObjectFromSourceMock,
|
||||
rawDocExistsInNamespaceMock,
|
||||
} 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 { apiContextMock, ApiExecutionContextMock } from '../../mocks';
|
||||
import { performBulkGet } from './bulk_get';
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
import type { ISavedObjectsSecurityExtension } from '@kbn/core-saved-objects-server';
|
||||
|
||||
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 SavedObjectsRawDocSource, type SavedObject } from '@kbn/core-saved-objects-server';
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
} from '../repository.test.mock';
|
||||
|
||||
import type { Payload } from '@hapi/boom';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import type {
|
||||
SavedObjectsBulkUpdateObject,
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} 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 { SavedObjectsRepository } from '../repository';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} 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 {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} 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 { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 { apiContextMock, ApiExecutionContextMock } from '../../mocks';
|
||||
import { performFind } from './find';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 {
|
||||
SavedObjectsErrorHelpers,
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} 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 { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} from '../repository.test.mock';
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import type {
|
||||
SavedObjectsIncrementCounterField,
|
||||
|
|
|
@ -65,7 +65,6 @@ describe('preflightCheckForCreate', () => {
|
|||
docs: results.map(({ found, disabled }, i) => {
|
||||
return found
|
||||
? {
|
||||
// @ts-expect-error
|
||||
_id: params!.docs![i]._id, // needed for mockRawDocExistsInNamespaces mock implementation and existingDocument assertions
|
||||
_index: 'doesnt-matter',
|
||||
_source: {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 {
|
||||
type ISavedObjectTypeRegistry,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 type { Logger } from '@kbn/logging';
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} from '../repository.test.mock';
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import { SavedObjectsRepository } from '../repository';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
import { mockGetCurrentTime, mockPreflightCheckForCreate } from '../repository.test.mock';
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import {
|
||||
type SavedObjectUnsanitizedDoc,
|
||||
type SavedObjectReference,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 {
|
||||
SavedObjectsErrorHelpers,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 {
|
||||
SavedObjectsFindOptions,
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
mockGetSearchDsl,
|
||||
} from './repository.test.mock';
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import { SavedObjectsRepository } from './repository';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
|
||||
import { SavedObjectsRepository } from './repository';
|
||||
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 { SavedObjectsBulkUpdateObject } from '@kbn/core-saved-objects-api-server';
|
||||
import { SavedObjectsSerializer } from '@kbn/core-saved-objects-base-server-internal';
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
mockDeleteLegacyUrlAliases,
|
||||
} from './repository.test.mock';
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
|
||||
import { SavedObjectsRepository } from './repository';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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';
|
||||
|
||||
type AggsMap = Record<string, estypes.AggregationsAggregationContainer>;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { isPlainObject, isArray } from 'lodash';
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
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 { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import type { IndexMapping } from '@kbn/core-saved-objects-base-server-internal';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { loggerMock } from '@kbn/logging-mocks';
|
||||
import type { Payload } from 'elastic-apm-node';
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
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 type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import {
|
||||
|
|
|
@ -28,9 +28,7 @@ export const closePit =
|
|||
({ client, pitId }: ClosePitParams): TaskEither.TaskEither<RetryableEsClientError, {}> =>
|
||||
() => {
|
||||
return client
|
||||
.closePointInTime({
|
||||
body: { id: pitId },
|
||||
})
|
||||
.closePointInTime({ id: pitId })
|
||||
.then((response) => {
|
||||
if (!response.succeeded) {
|
||||
throw new Error(`Failed to close PointInTime with id: ${pitId}`);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import * as Either from 'fp-ts/lib/Either';
|
||||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import { pipe } from 'fp-ts/lib/function';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import type {
|
||||
ElasticsearchClient,
|
||||
ElasticsearchCapabilities,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
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 type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
|
|
|
@ -73,22 +73,21 @@ describe('reindex', () => {
|
|||
/** ignore */
|
||||
}
|
||||
expect(client.reindex).toHaveBeenCalledTimes(1);
|
||||
expect(client.reindex).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body: {
|
||||
conflicts: 'proceed',
|
||||
source: {
|
||||
index: 'my_source_index',
|
||||
size: 99,
|
||||
query: { match_all: {} },
|
||||
},
|
||||
dest: {
|
||||
index: 'my_target_index',
|
||||
op_type: 'create',
|
||||
},
|
||||
script: { lang: 'painless', source: 'my script' },
|
||||
},
|
||||
})
|
||||
);
|
||||
expect(client.reindex).toHaveBeenCalledWith({
|
||||
conflicts: 'proceed',
|
||||
source: {
|
||||
index: 'my_source_index',
|
||||
size: 99,
|
||||
query: { match_all: {} },
|
||||
},
|
||||
dest: {
|
||||
index: 'my_target_index',
|
||||
op_type: 'create',
|
||||
},
|
||||
script: { lang: 'painless', source: 'my script' },
|
||||
refresh: true,
|
||||
require_alias: false,
|
||||
wait_for_completion: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -62,29 +62,27 @@ export const reindex =
|
|||
// Require targetIndex to be an alias. Prevents a new index from being
|
||||
// created if targetIndex doesn't exist.
|
||||
require_alias: requireAlias,
|
||||
body: {
|
||||
// Ignore version conflicts from existing documents
|
||||
conflicts: 'proceed',
|
||||
source: {
|
||||
index: sourceIndex,
|
||||
// Set reindex batch size
|
||||
size: batchSize,
|
||||
// Exclude saved object types
|
||||
query: excludeOnUpgradeQuery,
|
||||
},
|
||||
dest: {
|
||||
index: targetIndex,
|
||||
// Don't override existing documents, only create if missing
|
||||
op_type: 'create',
|
||||
},
|
||||
script: Option.fold<string, undefined | { source: string; lang: 'painless' }>(
|
||||
() => undefined,
|
||||
(script) => ({
|
||||
source: script,
|
||||
lang: 'painless',
|
||||
})
|
||||
)(reindexScript),
|
||||
// Ignore version conflicts from existing documents
|
||||
conflicts: 'proceed',
|
||||
source: {
|
||||
index: sourceIndex,
|
||||
// Set reindex batch size
|
||||
size: batchSize,
|
||||
// Exclude saved object types
|
||||
query: excludeOnUpgradeQuery,
|
||||
},
|
||||
dest: {
|
||||
index: targetIndex,
|
||||
// Don't override existing documents, only create if missing
|
||||
op_type: 'create',
|
||||
},
|
||||
script: Option.fold<string, undefined | { source: string; lang: 'painless' }>(
|
||||
() => undefined,
|
||||
(script) => ({
|
||||
source: script,
|
||||
lang: 'painless',
|
||||
})
|
||||
)(reindexScript),
|
||||
// force a refresh so that we can query the target index
|
||||
refresh: true,
|
||||
// Create a task and return task id instead of blocking until complete
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import * as Option from 'fp-ts/lib/Option';
|
||||
|
|
|
@ -174,11 +174,9 @@ describe('unknown saved object types deprecation', () => {
|
|||
expect(esClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({
|
||||
index: ['foo-index', 'bar-index'],
|
||||
wait_for_completion: false,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [{ term: { type: 'foo' } }, { term: { type: 'bar' } }],
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [{ term: { type: 'foo' } }, { term: { type: 'bar' } }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -141,8 +141,6 @@ export const deleteUnknownTypeObjects = async ({
|
|||
await esClient.asInternalUser.deleteByQuery({
|
||||
index: targetIndices,
|
||||
wait_for_completion: false,
|
||||
body: {
|
||||
query: nonRegisteredTypesQuery,
|
||||
},
|
||||
query: nonRegisteredTypesQuery,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -182,26 +182,24 @@ export class CoreUsageDataService
|
|||
{ aliases: UsageDataAggs }
|
||||
>({
|
||||
index: MAIN_SAVED_OBJECT_INDEX, // depends on the .kibana split (assuming 'legacy-url-alias' is stored in '.kibana')
|
||||
body: {
|
||||
track_total_hits: true,
|
||||
query: { match: { type: LEGACY_URL_ALIAS_TYPE } },
|
||||
aggs: {
|
||||
aliases: {
|
||||
track_total_hits: true,
|
||||
query: { match: { type: LEGACY_URL_ALIAS_TYPE } },
|
||||
aggs: {
|
||||
aliases: {
|
||||
filters: {
|
||||
filters: {
|
||||
filters: {
|
||||
disabled: { term: { [`${LEGACY_URL_ALIAS_TYPE}.disabled`]: true } },
|
||||
active: {
|
||||
bool: {
|
||||
must_not: { term: { [`${LEGACY_URL_ALIAS_TYPE}.disabled`]: true } },
|
||||
must: { range: { [`${LEGACY_URL_ALIAS_TYPE}.resolveCounter`]: { gte: 1 } } },
|
||||
},
|
||||
disabled: { term: { [`${LEGACY_URL_ALIAS_TYPE}.disabled`]: true } },
|
||||
active: {
|
||||
bool: {
|
||||
must_not: { term: { [`${LEGACY_URL_ALIAS_TYPE}.disabled`]: true } },
|
||||
must: { range: { [`${LEGACY_URL_ALIAS_TYPE}.resolveCounter`]: { gte: 1 } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
},
|
||||
size: 0,
|
||||
});
|
||||
|
||||
const { hits, aggregations } = resp;
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
module.exports = {
|
||||
bail: true, // only report 1 issue
|
||||
// TODO replace the line below with
|
||||
// preset: '@kbn/test/jest_integration_node
|
||||
// TODO remove the line below once we've addressed all the open handles
|
||||
// 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
|
||||
// see https://github.com/elastic/kibana/pull/130255/
|
||||
preset: '@kbn/test/jest_integration',
|
||||
forceExit: true,
|
||||
preset: '@kbn/test/jest_integration_node',
|
||||
rootDir: '../../../../..',
|
||||
roots: ['<rootDir>/src/core/server/integration_tests/ci_checks'],
|
||||
// must override to match all test given there is no `integration_tests` subfolder
|
||||
|
|
|
@ -138,11 +138,9 @@ describe('migration actions', () => {
|
|||
describe('fetchIndices', () => {
|
||||
afterAll(async () => {
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Reset persistent test settings
|
||||
cluster: { routing: { allocation: { enable: null } } },
|
||||
},
|
||||
persistent: {
|
||||
// Reset persistent test settings
|
||||
cluster: { routing: { allocation: { enable: null } } },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -209,11 +207,9 @@ describe('migration actions', () => {
|
|||
it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => {
|
||||
expect.assertions(3);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Disable all routing allocation
|
||||
cluster: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Disable all routing allocation
|
||||
cluster: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
});
|
||||
const task = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -226,11 +222,9 @@ describe('migration actions', () => {
|
|||
}
|
||||
`);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Allow routing to existing primaries only
|
||||
cluster: { routing: { allocation: { enable: 'primaries' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Allow routing to existing primaries only
|
||||
cluster: { routing: { allocation: { enable: 'primaries' } } },
|
||||
},
|
||||
});
|
||||
const task2 = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -243,11 +237,9 @@ describe('migration actions', () => {
|
|||
}
|
||||
`);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Allow routing to new primaries only
|
||||
cluster: { routing: { allocation: { enable: 'new_primaries' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Allow routing to new primaries only
|
||||
cluster: { routing: { allocation: { enable: 'new_primaries' } } },
|
||||
},
|
||||
});
|
||||
const task3 = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -263,10 +255,8 @@ describe('migration actions', () => {
|
|||
it('resolves right when cluster.routing.allocation.enabled=all', async () => {
|
||||
expect.assertions(1);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
cluster: { routing: { allocation: { enable: 'all' } } },
|
||||
},
|
||||
persistent: {
|
||||
cluster: { routing: { allocation: { enable: 'all' } } },
|
||||
},
|
||||
});
|
||||
const task = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -398,14 +388,12 @@ describe('migration actions', () => {
|
|||
await client.indices.create({
|
||||
index: 'red_then_yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
routing: { allocation: { enable: 'none' } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
routing: { allocation: { enable: 'none' } },
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -421,7 +409,7 @@ describe('migration actions', () => {
|
|||
|
||||
void client.indices.putSettings({
|
||||
index: 'red_then_yellow_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status turns yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -439,14 +427,12 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'red_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays red
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays red
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -474,12 +460,10 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays yellow
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays yellow
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -546,14 +530,12 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'clone_red_then_green_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index can go to green
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index can go to green
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -570,7 +552,7 @@ describe('migration actions', () => {
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'clone_red_then_green_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status goes green
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -598,14 +580,12 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'clone_red_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -633,7 +613,7 @@ describe('migration actions', () => {
|
|||
|
||||
await client.indices.putSettings({
|
||||
index: 'clone_red_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status goes yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -662,7 +642,7 @@ describe('migration actions', () => {
|
|||
|
||||
await client.indices.putSettings({
|
||||
index: 'clone_red_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Set zero replicas so status goes green
|
||||
number_of_replicas: 0,
|
||||
},
|
||||
|
@ -1126,11 +1106,7 @@ describe('migration actions', () => {
|
|||
|
||||
expect(pitResponse.right.pitId).toEqual(expect.any(String));
|
||||
|
||||
const searchResponse = await client.search({
|
||||
body: {
|
||||
pit: { id: pitResponse.right.pitId },
|
||||
},
|
||||
});
|
||||
const searchResponse = await client.search({ pit: { id: pitResponse.right.pitId } });
|
||||
|
||||
await expect(searchResponse.hits.hits.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
@ -1346,11 +1322,7 @@ describe('migration actions', () => {
|
|||
const pitId = pitResponse.right.pitId;
|
||||
await closePit({ client, pitId })();
|
||||
|
||||
const searchTask = client.search({
|
||||
body: {
|
||||
pit: { id: pitId },
|
||||
},
|
||||
});
|
||||
const searchTask = client.search({ pit: { id: pitId } });
|
||||
|
||||
await expect(searchTask).rejects.toThrow('search_phase_execution_exception');
|
||||
});
|
||||
|
@ -1811,14 +1783,12 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'red_then_yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status starts as red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status starts as red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {
|
||||
|
@ -1840,7 +1810,7 @@ describe('migration actions', () => {
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'red_then_yellow_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Renable allocation so that the status becomes yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -1869,12 +1839,10 @@ describe('migration actions', () => {
|
|||
.create({
|
||||
index: 'yellow_then_green_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
},
|
||||
})
|
||||
.catch((e) => {
|
||||
|
@ -1893,7 +1861,7 @@ describe('migration actions', () => {
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'yellow_then_green_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Set 0 replican so that this index becomes green
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
|
|
|
@ -176,11 +176,9 @@ export const runActionTestSuite = ({
|
|||
describe('fetchIndices', () => {
|
||||
afterAll(async () => {
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Reset persistent test settings
|
||||
cluster: { routing: { allocation: { enable: null } } },
|
||||
},
|
||||
persistent: {
|
||||
// Reset persistent test settings
|
||||
cluster: { routing: { allocation: { enable: null } } },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -247,11 +245,9 @@ export const runActionTestSuite = ({
|
|||
it('resolves left when cluster.routing.allocation.enabled is incompatible', async () => {
|
||||
expect.assertions(3);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Disable all routing allocation
|
||||
cluster: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Disable all routing allocation
|
||||
cluster: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
});
|
||||
const task = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -264,11 +260,9 @@ export const runActionTestSuite = ({
|
|||
}
|
||||
`);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Allow routing to existing primaries only
|
||||
cluster: { routing: { allocation: { enable: 'primaries' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Allow routing to existing primaries only
|
||||
cluster: { routing: { allocation: { enable: 'primaries' } } },
|
||||
},
|
||||
});
|
||||
const task2 = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -281,11 +275,9 @@ export const runActionTestSuite = ({
|
|||
}
|
||||
`);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
// Allow routing to new primaries only
|
||||
cluster: { routing: { allocation: { enable: 'new_primaries' } } },
|
||||
},
|
||||
persistent: {
|
||||
// Allow routing to new primaries only
|
||||
cluster: { routing: { allocation: { enable: 'new_primaries' } } },
|
||||
},
|
||||
});
|
||||
const task3 = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -301,10 +293,8 @@ export const runActionTestSuite = ({
|
|||
it('resolves right when cluster.routing.allocation.enabled=all', async () => {
|
||||
expect.assertions(1);
|
||||
await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
cluster: { routing: { allocation: { enable: 'all' } } },
|
||||
},
|
||||
persistent: {
|
||||
cluster: { routing: { allocation: { enable: 'all' } } },
|
||||
},
|
||||
});
|
||||
const task = checkClusterRoutingAllocationEnabled(client);
|
||||
|
@ -436,14 +426,12 @@ export const runActionTestSuite = ({
|
|||
{
|
||||
index: 'red_then_yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
routing: { allocation: { enable: 'none' } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
routing: { allocation: { enable: 'none' } },
|
||||
},
|
||||
},
|
||||
{ maxRetries: 0 /** handle retry ourselves for now */ }
|
||||
|
@ -461,7 +449,7 @@ export const runActionTestSuite = ({
|
|||
|
||||
void client.indices.putSettings({
|
||||
index: 'red_then_yellow_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status turns yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -483,14 +471,12 @@ export const runActionTestSuite = ({
|
|||
.create({
|
||||
index: 'red_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays red
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays red
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -518,12 +504,10 @@ export const runActionTestSuite = ({
|
|||
.create({
|
||||
index: 'yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays yellow
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate no replicas so that this index stays yellow
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -580,8 +564,7 @@ export const runActionTestSuite = ({
|
|||
const { clone_target_1: cloneTarget1 } = await client.indices.getSettings({
|
||||
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();
|
||||
});
|
||||
it('resolves right if clone target already existed after waiting for index status to be green ', async () => {
|
||||
|
@ -592,14 +575,12 @@ export const runActionTestSuite = ({
|
|||
.create({
|
||||
index: 'clone_red_then_green_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index can go to green
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index can go to green
|
||||
number_of_replicas: '0',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -616,7 +597,7 @@ export const runActionTestSuite = ({
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'clone_red_then_green_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status goes green
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -644,14 +625,12 @@ export const runActionTestSuite = ({
|
|||
.create({
|
||||
index: 'clone_red_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status is red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
})
|
||||
.catch((e) => {});
|
||||
|
@ -679,7 +658,7 @@ export const runActionTestSuite = ({
|
|||
|
||||
await client.indices.putSettings({
|
||||
index: 'clone_red_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Enable all shard allocation so that the index status goes yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -708,7 +687,7 @@ export const runActionTestSuite = ({
|
|||
|
||||
await client.indices.putSettings({
|
||||
index: 'clone_red_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Set zero replicas so status goes green
|
||||
number_of_replicas: 0,
|
||||
},
|
||||
|
@ -1178,11 +1157,7 @@ export const runActionTestSuite = ({
|
|||
|
||||
expect(pitResponse.right.pitId).toEqual(expect.any(String));
|
||||
|
||||
const searchResponse = await client.search({
|
||||
body: {
|
||||
pit: { id: pitResponse.right.pitId },
|
||||
},
|
||||
});
|
||||
const searchResponse = await client.search({ pit: { id: pitResponse.right.pitId } });
|
||||
|
||||
await expect(searchResponse.hits.hits.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
@ -1398,11 +1373,7 @@ export const runActionTestSuite = ({
|
|||
const pitId = pitResponse.right.pitId;
|
||||
await closePit({ client, pitId })();
|
||||
|
||||
const searchTask = client.search({
|
||||
body: {
|
||||
pit: { id: pitId },
|
||||
},
|
||||
});
|
||||
const searchTask = client.search({ pit: { id: pitId } });
|
||||
|
||||
await expect(searchTask).rejects.toThrow('search_phase_execution_exception');
|
||||
});
|
||||
|
@ -1867,14 +1838,12 @@ export const runActionTestSuite = ({
|
|||
{
|
||||
index: 'red_then_yellow_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status starts as red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
// Disable all shard allocation so that the index status starts as red
|
||||
index: { routing: { allocation: { enable: 'none' } } },
|
||||
},
|
||||
},
|
||||
{ maxRetries: 0 /** handle retry ourselves for now */ }
|
||||
|
@ -1895,7 +1864,7 @@ export const runActionTestSuite = ({
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'red_then_yellow_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Renable allocation so that the status becomes yellow
|
||||
routing: { allocation: { enable: 'all' } },
|
||||
},
|
||||
|
@ -1924,12 +1893,10 @@ export const runActionTestSuite = ({
|
|||
.create({
|
||||
index: 'yellow_then_green_index',
|
||||
timeout: '5s',
|
||||
body: {
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
},
|
||||
mappings: { properties: {} },
|
||||
settings: {
|
||||
// Allocate 1 replica so that this index stays yellow
|
||||
number_of_replicas: '1',
|
||||
},
|
||||
})
|
||||
.catch((e) => {
|
||||
|
@ -1948,7 +1915,7 @@ export const runActionTestSuite = ({
|
|||
setTimeout(() => {
|
||||
void client.indices.putSettings({
|
||||
index: 'yellow_then_green_index',
|
||||
body: {
|
||||
settings: {
|
||||
// Set 0 replican so that this index becomes green
|
||||
number_of_replicas: '0',
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { Root } from '@kbn/core-root-server-internal';
|
||||
import { elasticsearchServiceMock } from '@kbn/core-elasticsearch-server-mocks';
|
||||
|
@ -68,7 +68,7 @@ describe('Elasticsearch Errors', () => {
|
|||
index: 'existing_index_with_write_block',
|
||||
id: 'some-id',
|
||||
op_type: 'index',
|
||||
body: {
|
||||
document: {
|
||||
hello: 'dolly',
|
||||
},
|
||||
},
|
||||
|
@ -98,7 +98,7 @@ describe('Elasticsearch Errors', () => {
|
|||
it('correctly identify errors from bulk index operations', async () => {
|
||||
const res = await client.bulk({
|
||||
refresh: 'wait_for',
|
||||
body: [
|
||||
operations: [
|
||||
{
|
||||
index: {
|
||||
_index: 'existing_index_with_write_block',
|
||||
|
@ -119,7 +119,7 @@ describe('Elasticsearch Errors', () => {
|
|||
it('correctly identify errors from bulk create operations', async () => {
|
||||
const res = await client.bulk({
|
||||
refresh: 'wait_for',
|
||||
body: [
|
||||
operations: [
|
||||
{
|
||||
create: {
|
||||
_index: 'existing_index_with_write_block',
|
||||
|
|
|
@ -38,15 +38,13 @@ async function fetchDocs(esClient: ElasticsearchClient, index: string, type: str
|
|||
const body = await esClient.search<any>({
|
||||
index,
|
||||
size: 10000,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
should: [
|
||||
{
|
||||
term: { type },
|
||||
},
|
||||
],
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
should: [
|
||||
{
|
||||
term: { type },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -102,7 +102,7 @@ describe('getOutdatedDocumentsQuery', () => {
|
|||
|
||||
await client.bulk({
|
||||
refresh: 'true',
|
||||
body: bulkCreateParams,
|
||||
operations: bulkCreateParams,
|
||||
});
|
||||
|
||||
return { client };
|
||||
|
|
|
@ -75,11 +75,9 @@ describe('POST /internal/saved_objects/deprecations/_delete_unknown_types', () =
|
|||
expect(elasticsearchClient.asInternalUser.deleteByQuery).toHaveBeenCalledWith({
|
||||
index: ['known-type-index_8.0.0'],
|
||||
wait_for_completion: false,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must_not: expect.any(Array),
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
must_not: expect.any(Array),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -24,9 +24,7 @@ export const docExistsSuite = (savedObjectsIndex: string) => () => {
|
|||
await esClient.deleteByQuery({
|
||||
index: savedObjectsIndex,
|
||||
conflicts: 'proceed',
|
||||
body: {
|
||||
query: { match_all: {} },
|
||||
},
|
||||
query: { match_all: {} },
|
||||
refresh: true,
|
||||
wait_for_completion: true,
|
||||
});
|
||||
|
|
|
@ -19,9 +19,7 @@ export const docMissingSuite = (savedObjectsIndex: string) => () => {
|
|||
// delete all docs from kibana index to ensure savedConfig is not found
|
||||
await esClient.deleteByQuery({
|
||||
index: savedObjectsIndex,
|
||||
body: {
|
||||
query: { match_all: {} },
|
||||
},
|
||||
query: { match_all: {} },
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ const getServerlessESClient = ({ port }: { port: number }) => {
|
|||
return new Client({
|
||||
node: `http://localhost:${port}`,
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
auth: { ...systemIndicesSuperuser },
|
||||
});
|
||||
};
|
||||
|
|
|
@ -28,11 +28,11 @@ export const ingestList = (log) => async (xs) => {
|
|||
async function bulkIngest() {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ export const KEBAB_CASE_DIRECTORY_GLOBS = [
|
|||
'packages/*',
|
||||
'x-pack',
|
||||
'x-pack/packages/*',
|
||||
'src/dev/packages/*',
|
||||
'src/core/packages/*/*',
|
||||
'src/platform/packages/private/*',
|
||||
'src/platform/packages/shared/*',
|
||||
|
|
|
@ -377,7 +377,7 @@ describe('CsvGenerator', () => {
|
|||
|
||||
expect(mockDataClient.search).toHaveBeenCalledTimes(10);
|
||||
expect(mockDataClient.search).toBeCalledWith(
|
||||
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } },
|
||||
{ params: { max_concurrent_shard_requests: 5 } },
|
||||
{
|
||||
abortSignal: expect.any(AbortSignal),
|
||||
strategy: 'es',
|
||||
|
@ -402,7 +402,7 @@ describe('CsvGenerator', () => {
|
|||
|
||||
expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledTimes(1);
|
||||
expect(mockEsClient.asCurrentUser.closePointInTime).toHaveBeenCalledWith({
|
||||
body: { id: mockCursorId },
|
||||
id: mockCursorId,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -676,7 +676,7 @@ describe('CsvGenerator', () => {
|
|||
);
|
||||
|
||||
expect(mockDataClientSearchFn).toBeCalledWith(
|
||||
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } },
|
||||
{ params: { max_concurrent_shard_requests: 5 } },
|
||||
{
|
||||
abortSignal: expect.any(AbortSignal),
|
||||
strategy: 'es',
|
||||
|
@ -762,7 +762,7 @@ describe('CsvGenerator', () => {
|
|||
);
|
||||
|
||||
expect(mockDataClientSearchFn).toBeCalledWith(
|
||||
{ params: { body: {}, ignore_throttled: undefined, max_concurrent_shard_requests: 5 } },
|
||||
{ params: { max_concurrent_shard_requests: 5 } },
|
||||
{
|
||||
abortSignal: expect.any(AbortSignal),
|
||||
strategy: 'es',
|
||||
|
@ -1439,7 +1439,6 @@ describe('CsvGenerator', () => {
|
|||
expect(mockDataClient.search).toBeCalledWith(
|
||||
{
|
||||
params: {
|
||||
body: {},
|
||||
max_concurrent_shard_requests: 5,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -101,10 +101,10 @@ describe('CSV Export Search Cursor', () => {
|
|||
expect(dataSearchSpy).toBeCalledTimes(1);
|
||||
expect(dataSearchSpy).toBeCalledWith(
|
||||
{
|
||||
params: {
|
||||
body: expect.objectContaining({ pit: { id: 'somewhat-pit-id', keep_alive: '10m' } }),
|
||||
params: expect.objectContaining({
|
||||
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
|
||||
max_concurrent_shard_requests: 5,
|
||||
},
|
||||
}),
|
||||
},
|
||||
expect.objectContaining({
|
||||
strategy: 'es',
|
||||
|
@ -160,14 +160,12 @@ describe('CSV Export Search Cursor', () => {
|
|||
expect(dataSearchSpy).toBeCalledWith(
|
||||
{
|
||||
params: {
|
||||
body: {
|
||||
fields: [],
|
||||
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
},
|
||||
fields: [],
|
||||
pit: { id: 'somewhat-pit-id', keep_alive: '10m' },
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
max_concurrent_shard_requests: undefined,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -80,7 +80,7 @@ export class SearchCursorPit extends SearchCursor {
|
|||
|
||||
const searchParamsPit = {
|
||||
params: {
|
||||
body: searchBody,
|
||||
...searchBody,
|
||||
max_concurrent_shard_requests: effectiveMaxConcurrentShardRequests,
|
||||
},
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ export class SearchCursorPit extends SearchCursor {
|
|||
public async closeCursor() {
|
||||
if (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 {
|
||||
this.logger.warn(`No PIT Id to clear!`);
|
||||
}
|
||||
|
|
|
@ -80,13 +80,11 @@ describe('CSV Export Search Cursor', () => {
|
|||
expect(dataSearchSpy).toBeCalledWith(
|
||||
{
|
||||
params: {
|
||||
body: {
|
||||
fields: [],
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
},
|
||||
fields: [],
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
ignore_throttled: undefined,
|
||||
index: 'test-index-pattern-string',
|
||||
max_concurrent_shard_requests: 5,
|
||||
|
@ -135,13 +133,11 @@ describe('CSV Export Search Cursor', () => {
|
|||
expect(dataSearchSpy).toBeCalledWith(
|
||||
{
|
||||
params: {
|
||||
body: {
|
||||
fields: [],
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
},
|
||||
fields: [],
|
||||
query: { bool: { filter: [], must: [], must_not: [], should: [] } },
|
||||
runtime_mappings: {},
|
||||
script_fields: {},
|
||||
stored_fields: ['*'],
|
||||
ignore_throttled: undefined,
|
||||
index: 'test-index-pattern-string',
|
||||
max_concurrent_shard_requests: undefined,
|
||||
|
|
|
@ -38,7 +38,7 @@ export class SearchCursorScroll extends SearchCursor {
|
|||
|
||||
const searchParamsScan = {
|
||||
params: {
|
||||
body: searchBody,
|
||||
...searchBody,
|
||||
index: this.indexPatternTitle,
|
||||
scroll: scroll.duration(taskInstanceFields),
|
||||
size: scroll.size,
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
* 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 { createFailError } from '@kbn/dev-cli-errors';
|
||||
|
||||
|
@ -28,7 +32,11 @@ export async function getValidatedESClient(
|
|||
}
|
||||
): Promise<ESClient> {
|
||||
const { log, cli = false } = helperSettings;
|
||||
const es = new ESClient(esClientOptions);
|
||||
const es = new ESClient({
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
...esClientOptions,
|
||||
});
|
||||
|
||||
try {
|
||||
const esInfo = await es.info();
|
||||
|
|
|
@ -16,7 +16,7 @@ import type {
|
|||
AggregationsAggregationContainer,
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
import { BASE_RAC_ALERTS_API_PATH } from '../constants';
|
||||
|
||||
export interface UseGetAlertsGroupAggregationsQueryProps {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { Logger } from '../../lib/utils/create_logger';
|
||||
import { RunOptions } from './parse_run_cli_flags';
|
||||
|
@ -26,6 +26,8 @@ export function getApmEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
const apmEsClient = new ApmSynthtraceEsClient({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { Logger } from '../../lib/utils/create_logger';
|
||||
import { RunOptions } from './parse_run_cli_flags';
|
||||
|
@ -24,6 +24,8 @@ export function getEntitiesEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
return new EntitiesSynthtraceEsClient({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { Logger } from '../../lib/utils/create_logger';
|
||||
import { RunOptions } from './parse_run_cli_flags';
|
||||
|
@ -24,6 +24,8 @@ export function getInfraEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
return new InfraSynthtraceEsClient({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { Logger } from '../../lib/utils/create_logger';
|
||||
import { RunOptions } from './parse_run_cli_flags';
|
||||
|
@ -24,6 +24,8 @@ export function getLogsEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
return new LogsSynthtraceEsClient({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { RunOptions } from './parse_run_cli_flags';
|
||||
import { getEsClientTlsSettings } from './ssl';
|
||||
|
@ -24,6 +24,8 @@ export function getOtelSynthtraceEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
return new OtelSynthtraceEsClient({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { RunOptions } from './parse_run_cli_flags';
|
||||
import { getEsClientTlsSettings } from './ssl';
|
||||
|
@ -24,6 +24,8 @@ export function getSyntheticsEsClient({
|
|||
const client = new Client({
|
||||
node: target,
|
||||
tls: getEsClientTlsSettings(target),
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
|
||||
return new SyntheticsSynthtraceEsClient({
|
||||
|
|
|
@ -33,7 +33,7 @@ import type {
|
|||
SortOrder,
|
||||
AggregationsAggregationContainer,
|
||||
SortResults,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
import type {
|
||||
MutatingOperationRefreshSetting,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import { tabifyDocs, flattenHit } from './tabify_docs';
|
||||
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 { stubbedSavedObjectIndexPattern } from '@kbn/data-views-plugin/common/data_view.stub';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 {
|
||||
Datatable,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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';
|
||||
|
||||
export type { IgnoredReason, ShouldShowFieldInTableHandler } from './utils';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 type { DataViewField } from '@kbn/data-views-plugin/public';
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ export function runCli() {
|
|||
node: esUrl,
|
||||
tls: esCa ? { ca: esCa } : undefined,
|
||||
Connection: HttpConnection,
|
||||
requestTimeout: 30_000,
|
||||
});
|
||||
addCleanupTask(() => client.close());
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ export const createStubClient = (
|
|||
|
||||
return { statusCode: 404 };
|
||||
}),
|
||||
updateAliases: sinon.spy(async ({ body }) => {
|
||||
updateAliases: sinon.spy(async (body) => {
|
||||
body.actions.forEach(
|
||||
({ add: { index, alias } }: { add: { index: string; alias: string } }) => {
|
||||
if (!existingIndices.includes(index)) {
|
||||
|
|
|
@ -141,16 +141,12 @@ describe('esArchiver: createCreateIndexStream()', () => {
|
|||
|
||||
sinon.assert.calledWith(client.indices.create as sinon.SinonSpy, {
|
||||
index: 'index',
|
||||
body: {
|
||||
settings: undefined,
|
||||
mappings: undefined,
|
||||
},
|
||||
settings: undefined,
|
||||
mappings: undefined,
|
||||
});
|
||||
|
||||
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'
|
||||
sinon.assert.callCount(client.indices.updateAliases as sinon.SinonSpy, 1);
|
||||
expect((client.indices.updateAliases as sinon.SinonSpy).args[0][0]).toHaveProperty('body', {
|
||||
actions: [{ add: { alias: 'new-index-alias', index: 'new-index' } }],
|
||||
});
|
||||
expect((client.indices.updateAliases as sinon.SinonSpy).args[0][0]).toHaveProperty(
|
||||
'actions',
|
||||
[{ add: { alias: 'new-index-alias', index: 'new-index' } }]
|
||||
);
|
||||
});
|
||||
|
||||
it('filters documents for skipped indices', async () => {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import { Transform, Readable } from 'stream';
|
||||
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 { ToolingLog } from '@kbn/tooling-log';
|
||||
|
||||
|
@ -162,10 +162,8 @@ export function createCreateIndexStream({
|
|||
await client.indices.create(
|
||||
{
|
||||
index,
|
||||
body: {
|
||||
settings,
|
||||
mappings,
|
||||
},
|
||||
settings,
|
||||
mappings,
|
||||
},
|
||||
{
|
||||
headers: ES_CLIENT_HEADERS,
|
||||
|
@ -184,7 +182,7 @@ export function createCreateIndexStream({
|
|||
);
|
||||
|
||||
if (actions.length) {
|
||||
await client.indices.updateAliases({ body: { actions } });
|
||||
await client.indices.updateAliases({ actions });
|
||||
}
|
||||
|
||||
stats.createdIndex(index, { settings });
|
||||
|
|
|
@ -45,7 +45,7 @@ export async function deleteSavedObjectIndices({
|
|||
await client.indices.putSettings(
|
||||
{
|
||||
index: indexNames,
|
||||
body: { blocks: { read_only: false } },
|
||||
settings: { blocks: { read_only: false } },
|
||||
},
|
||||
{
|
||||
headers: ES_CLIENT_HEADERS,
|
||||
|
@ -123,13 +123,11 @@ export async function cleanSavedObjectIndices({
|
|||
{
|
||||
index,
|
||||
refresh: true,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must_not: {
|
||||
ids: {
|
||||
values: ['space:default'],
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
must_not: {
|
||||
ids: {
|
||||
values: ['space:default'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -168,7 +166,7 @@ export async function createDefaultSpace({ index, client }: { index: string; cli
|
|||
index,
|
||||
id: 'space:default',
|
||||
refresh: 'wait_for',
|
||||
body: {
|
||||
document: {
|
||||
type: 'space',
|
||||
updated_at: new Date().toISOString(),
|
||||
space: {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { extend, defaults } from 'lodash';
|
||||
import { getTimeZoneFromSettings } from '../utils';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 { filterMatchesIndex } from './filter_matches_index';
|
||||
import { Filter, cleanFilter, isFilterDisabled } from '../filters';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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';
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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';
|
||||
|
||||
/** @public */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { has } from 'lodash';
|
||||
import type { Filter, FilterMeta } from './types';
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from './phrase_filter';
|
||||
import { fields, getField } from '../stubs';
|
||||
import { DataViewBase } from '../../es_query';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import { Filter } from './types';
|
||||
|
||||
describe('Phrase filter builder', () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { get, has, isPlainObject } from 'lodash';
|
||||
import type { Filter, FilterMeta } from './types';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { getPhraseScript, PhraseFilterValue } from './phrase_filter';
|
||||
import type { DataViewFieldBase, DataViewBaseNoFields } from '../../es_query';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 type { SerializableRecord } from '@kbn/utility-types';
|
||||
import type { Filter, FilterMeta, FilterMetaParams } from './types';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 { KQLSyntaxError } from '../kuery_syntax_error';
|
||||
import type { KqlContext, KueryNode, KueryParseOptions, KueryQueryOptions } from '../types';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
|
||||
import type { KqlFunctionNode } from '../node_types';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 { KqlFunctionNode, KqlLiteralNode } from '../node_types';
|
||||
import type { KqlContext } from '../types';
|
||||
|
|
|
@ -12,7 +12,7 @@ import { fields } from '../../filters/stubs';
|
|||
|
||||
import * as is from './is';
|
||||
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_LITERAL } from '../node_types/literal';
|
||||
import { KqlIsFunctionNode } from './is';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
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 { getFields } from './utils/get_fields';
|
||||
import { getTimeZoneFromSettings, getDataViewFieldSubtypeNested } from '../../utils';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 literal from '../node_types/literal';
|
||||
import type { DataViewBase, KueryQueryOptions } from '../../..';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
|
||||
import type { KqlFunctionNode } from '../node_types';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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 type { DataViewBase, KueryNode, KueryQueryOptions } from '../../..';
|
||||
import type { KqlFunctionNode } from '../node_types';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue