Skip to content

Commit

Permalink
Merge branch 'main' into max-signals-follow-up-fixes-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdjere authored May 6, 2024
2 parents 7561499 + acec0e8 commit 0c49369
Show file tree
Hide file tree
Showing 327 changed files with 754 additions and 636 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ packages/kbn-search-index-documents @elastic/enterprise-search-frontend
x-pack/plugins/search_notebooks @elastic/enterprise-search-frontend
x-pack/plugins/search_playground @elastic/enterprise-search-frontend
packages/kbn-search-response-warnings @elastic/kibana-data-discovery
packages/kbn-search-types @elastic/kibana-data-discovery
x-pack/plugins/searchprofiler @elastic/kibana-management
x-pack/test/security_api_integration/packages/helpers @elastic/kibana-security
packages/kbn-security-hardening @elastic/kibana-security
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"searchErrors": "packages/kbn-search-errors",
"searchIndexDocuments": "packages/kbn-search-index-documents",
"searchResponseWarnings": "packages/kbn-search-response-warnings",
"searchTypes": "packages/kbn-search-types",
"securitySolutionPackages": "x-pack/packages/security-solution",
"serverlessPackages": "packages/serverless",
"coloring": "packages/kbn-coloring/src",
Expand Down
6 changes: 3 additions & 3 deletions examples/search_examples/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*/

import {
IEsSearchRequest,
IEsSearchResponse,
IKibanaSearchRequest,
IKibanaSearchResponse,
} from '@kbn/data-plugin/common';
IEsSearchRequest,
IEsSearchResponse,
} from '@kbn/search-types';

export interface IMyStrategyRequest extends IEsSearchRequest {
get_cool: boolean;
Expand Down
7 changes: 2 additions & 5 deletions examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import {
} from '@elastic/eui';
import { CoreStart } from '@kbn/core/public';
import { IInspectorInfo } from '@kbn/data-plugin/common';
import {
DataPublicPluginStart,
IKibanaSearchResponse,
isRunningResponse,
} from '@kbn/data-plugin/public';
import { DataPublicPluginStart, isRunningResponse } from '@kbn/data-plugin/public';
import type { IKibanaSearchResponse } from '@kbn/search-types';
import type { SearchResponseWarning } from '@kbn/search-response-warnings';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { i18n } from '@kbn/i18n';
Expand Down
4 changes: 2 additions & 2 deletions examples/search_examples/public/search_sessions/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
import type { TimeRange } from '@kbn/es-query';
import { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';

import type { IEsSearchRequest, IEsSearchResponse } from '@kbn/search-types';

import {
connectToQueryState,
DataPublicPluginStart,
IEsSearchRequest,
IEsSearchResponse,
isRunningResponse,
QueryState,
SearchSessionState,
Expand Down
8 changes: 2 additions & 6 deletions examples/search_examples/public/sql_search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ import {
} from '@elastic/eui';

import { CoreStart } from '@kbn/core/public';

import {
DataPublicPluginStart,
IKibanaSearchResponse,
isRunningResponse,
} from '@kbn/data-plugin/public';
import type { IKibanaSearchResponse } from '@kbn/search-types';
import { DataPublicPluginStart, isRunningResponse } from '@kbn/data-plugin/public';
import {
SQL_SEARCH_STRATEGY,
SqlSearchStrategyRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
*/

import { Observable } from 'rxjs';
import { IEsSearchRequest } from '@kbn/data-plugin/server';
import type { IEsSearchRequest, IEsSearchResponse } from '@kbn/search-types';
import { schema } from '@kbn/config-schema';
import { IEsSearchResponse } from '@kbn/data-plugin/common';
import type { DataRequestHandlerContext } from '@kbn/data-plugin/server';
import type { IRouter } from '@kbn/core/server';
import { SERVER_SEARCH_ROUTE_PATH } from '../../common';
Expand Down
3 changes: 2 additions & 1 deletion examples/search_examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"@kbn/core-mount-utils-browser-internal",
"@kbn/config-schema",
"@kbn/shared-ux-router",
"@kbn/search-response-warnings",
"@kbn/search-types",
"@kbn/shared-ux-link-redirect-app",
"@kbn/react-kibana-mount",
"@kbn/search-response-warnings",
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"@kbn/search-notebooks": "link:x-pack/plugins/search_notebooks",
"@kbn/search-playground": "link:x-pack/plugins/search_playground",
"@kbn/search-response-warnings": "link:packages/kbn-search-response-warnings",
"@kbn/search-types": "link:packages/kbn-search-types",
"@kbn/searchprofiler-plugin": "link:x-pack/plugins/searchprofiler",
"@kbn/security-hardening": "link:packages/kbn-security-hardening",
"@kbn/security-plugin": "link:x-pack/plugins/security",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-esql-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export {
getInitialESQLQuery,
getESQLWithSafeLimit,
appendToESQLQuery,
getESQLQueryColumns,
TextBasedLanguages,
} from './src';

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-esql-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export {
removeDropCommandsFromESQLQuery,
} from './utils/query_parsing_helpers';
export { appendToESQLQuery } from './utils/append_to_query';
export { getESQLQueryColumns } from './utils/run_query';
52 changes: 52 additions & 0 deletions packages/kbn-esql-utils/src/utils/run_query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { DatatableColumn } from '@kbn/expressions-plugin/common';
import type { ISearchGeneric } from '@kbn/search-types';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import type { ESQLSearchReponse } from '@kbn/es-types';
import { lastValueFrom } from 'rxjs';
import { ESQL_LATEST_VERSION } from '../../constants';

export async function getESQLQueryColumns({
esqlQuery,
search,
signal,
}: {
esqlQuery: string;
search: ISearchGeneric;
signal?: AbortSignal;
}): Promise<DatatableColumn[]> {
const response = await lastValueFrom(
search(
{
params: {
query: `${esqlQuery} | limit 0`,
version: ESQL_LATEST_VERSION,
},
},
{
abortSignal: signal,
strategy: 'esql_async',
}
)
);

const columns =
(response.rawResponse as unknown as ESQLSearchReponse).columns?.map(({ name, type }) => {
const kibanaType = esFieldTypeToKibanaFieldType(type);
const column = {
id: name,
name,
meta: { type: kibanaType, esType: type },
} as DatatableColumn;

return column;
}) ?? [];

return columns;
}
4 changes: 4 additions & 0 deletions packages/kbn-esql-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
"@kbn/crypto-browser",
"@kbn/data-view-utils",
"@kbn/esql-ast",
"@kbn/search-types",
"@kbn/expressions-plugin",
"@kbn/field-types",
"@kbn/es-types"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ run(
}

let branch: string = '';
let pipeline: string = '';
if (updateGithub) {
let isPr = false;

if (process.env.BUILDKITE === 'true') {
branch = process.env.BUILDKITE_BRANCH || '';
pipeline = process.env.BUILDKITE_PIPELINE_SLUG || '';
isPr = process.env.BUILDKITE_PULL_REQUEST === 'true';
updateGithub = process.env.REPORT_FAILED_TESTS_TO_GITHUB === 'true';
} else {
Expand Down Expand Up @@ -137,7 +139,8 @@ run(
buildUrl,
existingIssue,
githubApi,
branch
branch,
pipeline
);
const url = existingIssue.github.htmlUrl;
existingIssue.github.body = newBody;
Expand All @@ -150,7 +153,7 @@ run(
continue;
}

const newIssue = await createFailureIssue(buildUrl, failure, githubApi, branch);
const newIssue = await createFailureIssue(buildUrl, failure, githubApi, branch, pipeline);
existingIssues.addNewlyCreated(failure, newIssue);
pushMessage('Test has not failed recently on tracked branches');
if (updateGithub) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('createFailureIssue()', () => {
likelyIrrelevant: false,
},
api,
'main'
'main',
'kibana-on-merge'
);

expect(api.createIssue).toMatchInlineSnapshot(`
Expand All @@ -41,7 +42,7 @@ describe('createFailureIssue()', () => {
this is the failure text
\`\`\`
First failure: [CI Build - main](https://build-url)
First failure: [kibana-on-merge - main](https://build-url)
<!-- kibanaCiData = {\\"failed-test\\":{\\"test.class\\":\\"some.classname\\",\\"test.name\\":\\"test name\\",\\"test.failCount\\":1}} -->",
Array [
Expand Down Expand Up @@ -81,7 +82,8 @@ describe('updateFailureIssue()', () => {
},
},
api,
'main'
'main',
'kibana-on-merge'
);

expect(api.editIssueBodyAndEnsureOpen).toMatchInlineSnapshot(`
Expand All @@ -107,7 +109,7 @@ describe('updateFailureIssue()', () => {
"calls": Array [
Array [
1234,
"New failure: [CI Build - main](https://build-url)",
"New failure: [kibana-on-merge - main](https://build-url)",
],
],
"results": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export async function createFailureIssue(
buildUrl: string,
failure: TestFailure,
api: GithubApi,
branch: string
branch: string,
pipeline: string
) {
const title = `Failing test: ${failure.classname} - ${failure.name}`;

Expand All @@ -39,7 +40,7 @@ export async function createFailureIssue(
failureBody,
'```',
'',
`First failure: [CI Build - ${branch}](${buildUrl})`,
`First failure: [${pipeline || 'CI Build'} - ${branch}](${buildUrl})`,
].join('\n'),
{
'test.class': failure.classname,
Expand All @@ -55,7 +56,8 @@ export async function updateFailureIssue(
buildUrl: string,
issue: ExistingFailedTestIssue,
api: GithubApi,
branch: string
branch: string,
pipeline: string
) {
// Increment failCount
const newCount = getIssueMetadata(issue.github.body, 'test.failCount', 0) + 1;
Expand All @@ -66,7 +68,7 @@ export async function updateFailureIssue(
await api.editIssueBodyAndEnsureOpen(issue.github.number, newBody);
await api.addIssueComment(
issue.github.number,
`New failure: [CI Build - ${branch}](${buildUrl})`
`New failure: [${pipeline || 'CI Build'} - ${branch}](${buildUrl})`
);

return { newBody, newCount };
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-generate-csv/src/generate_csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
} from '@kbn/core/server/mocks';
import { createStubDataView } from '@kbn/data-views-plugin/common/data_views/data_view.stub';
import { stubLogstashFieldSpecMap } from '@kbn/data-views-plugin/common/field.stub';
import { ISearchClient, ISearchStartSearchSource } from '@kbn/data-plugin/common';
import type { ISearchClient, IKibanaSearchResponse } from '@kbn/search-types';
import { ISearchStartSearchSource } from '@kbn/data-plugin/common';
import { searchSourceInstanceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import type { IScopedSearchClient } from '@kbn/data-plugin/server';
import type { IKibanaSearchResponse } from '@kbn/data-plugin/common';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
import { CancellationToken } from '@kbn/reporting-common';
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-generate-csv/src/generate_csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type { Writable } from 'stream';

import { errors as esErrors, estypes } from '@elastic/elasticsearch';
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server';
import type { DataView, ISearchClient, ISearchStartSearchSource } from '@kbn/data-plugin/common';
import type { ISearchClient } from '@kbn/search-types';
import type { DataView, ISearchStartSearchSource } from '@kbn/data-plugin/common';
import { cellHasFormulas, tabifyDocs } from '@kbn/data-plugin/common';
import type { Datatable } from '@kbn/expressions-plugin/server';
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-generate-csv/src/generate_csv_esql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
savedObjectsClientMock,
uiSettingsServiceMock,
} from '@kbn/core/server/mocks';
import { IKibanaSearchResponse } from '@kbn/data-plugin/common';
import type { IKibanaSearchResponse } from '@kbn/search-types';
import { IScopedSearchClient } from '@kbn/data-plugin/server';
import { dataPluginMock } from '@kbn/data-plugin/server/mocks';
import { CancellationToken } from '@kbn/reporting-common';
Expand Down
9 changes: 2 additions & 7 deletions packages/kbn-generate-csv/src/generate_csv_esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ import type { Writable } from 'stream';
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
import { errors as esErrors } from '@elastic/elasticsearch';
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server';
import {
ESQL_SEARCH_STRATEGY,
type IKibanaSearchRequest,
type IKibanaSearchResponse,
cellHasFormulas,
getEsQueryConfig,
} from '@kbn/data-plugin/common';
import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-types';
import { ESQL_SEARCH_STRATEGY, cellHasFormulas, getEsQueryConfig } from '@kbn/data-plugin/common';
import type { IScopedSearchClient } from '@kbn/data-plugin/server';
import { type Filter, buildEsQuery } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchReponse } from '@kbn/es-types';
Expand Down
8 changes: 2 additions & 6 deletions packages/kbn-generate-csv/src/lib/search_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@

import type { estypes } from '@elastic/elasticsearch';
import type { IScopedClusterClient, Logger } from '@kbn/core/server';
import type {
IEsSearchResponse,
IKibanaSearchResponse,
ISearchClient,
ISearchSource,
} from '@kbn/data-plugin/common';
import type { ISearchClient, IKibanaSearchResponse, IEsSearchResponse } from '@kbn/search-types';
import type { ISearchSource } from '@kbn/data-plugin/common';
import type { CsvExportSettings } from './get_export_settings';

export interface SearchCursorClients {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as Rx from 'rxjs';
import type { estypes } from '@elastic/elasticsearch';
import type { IScopedClusterClient, Logger } from '@kbn/core/server';
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import type { ISearchClient } from '@kbn/data-plugin/common';
import type { ISearchClient } from '@kbn/search-types';
import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { createSearchRequestHandlerContext } from '@kbn/data-plugin/server/search/mocks';
import type { SearchCursorSettings } from './search_cursor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Rx from 'rxjs';

import type { IScopedClusterClient, Logger } from '@kbn/core/server';
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
import type { ISearchClient } from '@kbn/data-plugin/common';
import type { ISearchClient } from '@kbn/search-types';
import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_source/mocks';
import { createSearchRequestHandlerContext } from '@kbn/data-plugin/server/search/mocks';
import type { SearchCursorSettings } from './search_cursor';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-generate-csv/src/lib/search_cursor_scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import type { estypes } from '@elastic/elasticsearch';
import { lastValueFrom } from 'rxjs';
import type { Logger } from '@kbn/core/server';
import type { IEsSearchResponse } from '@kbn/search-types';
import {
ES_SEARCH_STRATEGY,
type IEsSearchResponse,
type ISearchSource,
type SearchRequest,
} from '@kbn/data-plugin/common';
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-generate-csv/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"@kbn/es-types",
"@kbn/esql-utils",
"@kbn/data-views-plugin",
"@kbn/search-types",
]
}
Loading

0 comments on commit 0c49369

Please sign in to comment.