Skip to content

Commit

Permalink
Merge branch 'main' into serverless/header-bar-2-ii
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Aug 9, 2023
2 parents ac44334 + a038fb0 commit 74f25d3
Show file tree
Hide file tree
Showing 76 changed files with 2,678 additions and 1,406 deletions.
4 changes: 1 addition & 3 deletions .buildkite/disabled_jest_configs.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[
"x-pack/plugins/watcher/jest.config.js"
]
[]
3 changes: 0 additions & 3 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ disabled:
- x-pack/test/osquery_cypress/cli_config.ts
- x-pack/test/osquery_cypress/config.ts
- x-pack/test/osquery_cypress/visual_config.ts
- x-pack/test/security_solution_cypress/ccs_config.ts
- x-pack/test/security_solution_cypress/cli_config.ts
- x-pack/test/security_solution_cypress/config.firefox.ts
- x-pack/test/security_solution_cypress/config.ts
- x-pack/test/security_solution_cypress/upgrade_config.ts
- x-pack/test/threat_intelligence_cypress/cli_config_parallel.ts
- x-pack/test/threat_intelligence_cypress/config.ts
- x-pack/test/functional_enterprise_search/visual_config.ts
Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,11 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/plugins/stack_connectors/server/connector_types/gen_ai @elastic/security-threat-hunting-explore
/x-pack/plugins/stack_connectors/common/gen_ai @elastic/security-threat-hunting-explore

## Defend Workflows owner connectors
/x-pack/plugins/stack_connectors/public/connector_types/sentinelone @elastic/security-defend-workflows
/x-pack/plugins/stack_connectors/server/connector_types/sentinelone @elastic/security-defend-workflows
/x-pack/plugins/stack_connectors/common/sentinelone @elastic/security-defend-workflows

## Security Solution sub teams - Detection Rule Management
/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_schema @elastic/security-detection-rule-management @elastic/security-detection-engine
/x-pack/plugins/security_solution/common/api/detection_engine/fleet_integrations @elastic/security-detection-rule-management
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^6.1.0",
"elastic-apm-node": "^3.49.0",
"elastic-apm-node": "^3.49.1",
"email-addresses": "^5.0.0",
"execa": "^4.0.2",
"expiry-js": "0.1.7",
Expand Down Expand Up @@ -1395,7 +1395,7 @@
"blob-polyfill": "^7.0.20220408",
"callsites": "^3.1.0",
"chance": "1.0.18",
"chromedriver": "^114.0.2",
"chromedriver": "^115.0.1",
"clean-webpack-plugin": "^3.0.0",
"cli-table3": "^0.6.1",
"compression-webpack-plugin": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pageLoadAssetSize:
snapshotRestore: 79032
spaces: 57868
stackAlerts: 58316
stackConnectors: 36314
stackConnectors: 52131
synthetics: 40958
telemetry: 51957
telemetryManagementSection: 38586
Expand Down
1 change: 1 addition & 0 deletions src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export PATH="$PATH:$yarnGlobalDir"

# use a proxy to fetch chromedriver/geckodriver asset
export GECKODRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_LEGACY_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export CHROMEDRIVER_CDNBINARIESURL="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
export RE2_DOWNLOAD_MIRROR="https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache"
Expand Down
32 changes: 32 additions & 0 deletions src/plugins/data_views/common/data_views/data_views.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,36 @@ describe('IndexPatterns', () => {
expect(apiClient.getFieldsForWildcard.mock.calls[0][0].allowNoIndex).toBe(true);
});
});

describe('getExistingIndices', () => {
test('getExistingIndices returns the valid matched indices', async () => {
apiClient.getFieldsForWildcard = jest
.fn()
.mockResolvedValueOnce({ fields: ['length'] })
.mockResolvedValue({ fields: [] });
const patternList = await indexPatterns.getExistingIndices(['packetbeat-*', 'filebeat-*']);
expect(apiClient.getFieldsForWildcard).toBeCalledTimes(2);
expect(patternList.length).toBe(1);
});

test('getExistingIndices checks the positive pattern if provided with a negative pattern', async () => {
const mockFn = jest.fn().mockResolvedValue({ fields: ['length'] });
apiClient.getFieldsForWildcard = mockFn;
const patternList = await indexPatterns.getExistingIndices(['-filebeat-*', 'filebeat-*']);
expect(mockFn.mock.calls[0][0].pattern).toEqual('filebeat-*');
expect(mockFn.mock.calls[1][0].pattern).toEqual('filebeat-*');
expect(patternList).toEqual(['-filebeat-*', 'filebeat-*']);
});

test('getExistingIndices handles an error', async () => {
apiClient.getFieldsForWildcard = jest
.fn()
.mockImplementationOnce(async () => {
throw new DataViewMissingIndices('Catch me if you can!');
})
.mockImplementation(() => Promise.resolve({ fields: ['length'] }));
const patternList = await indexPatterns.getExistingIndices(['packetbeat-*', 'filebeat-*']);
expect(patternList).toEqual(['filebeat-*']);
});
});
});
43 changes: 43 additions & 0 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
*/

import { i18n } from '@kbn/i18n';
import { defer, from } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '@kbn/field-formats-plugin/common';
import { v4 as uuidv4 } from 'uuid';
import { rateLimitingForkJoin } from './utils';
import { PersistenceAPI } from '../types';

import { createDataViewCache } from '.';
Expand Down Expand Up @@ -236,6 +238,12 @@ export interface DataViewsServicePublicMethods {
* @param options - options for getting fields
*/
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<FieldSpec[]>;
/**
* Get existing index pattern list by providing string array index pattern list.
* @param indices - index pattern list
* @returns index pattern list of index patterns that match indices
*/
getExistingIndices: (indices: string[]) => Promise<string[]>;
/**
* Get list of data view ids.
* @param refresh - clear cache and fetch from server
Expand Down Expand Up @@ -505,6 +513,41 @@ export class DataViewsService {
return fields;
};

/**
* Get existing index pattern list by providing string array index pattern list.
* @param indices index pattern list
* @returns index pattern list
*/
getExistingIndices = async (indices: string[]): Promise<string[]> => {
const indicesObs = indices.map((pattern) => {
// when checking a negative pattern, check if the positive pattern exists
const indexToQuery = pattern.trim().startsWith('-')
? pattern.trim().substring(1)
: pattern.trim();
return defer(() =>
from(
this.getFieldsForWildcard({
// check one field to keep request fast/small
fields: ['_id'],
// true so no errors thrown in browser
allowNoIndex: true,
pattern: indexToQuery,
})
)
);
});

return new Promise<boolean[]>((resolve) => {
rateLimitingForkJoin(indicesObs, 3, []).subscribe((value) => {
resolve(value.map((v) => v.length > 0));
});
})
.then((allPatterns: boolean[]) =>
indices.filter((pattern, i, self) => self.indexOf(pattern) === i && allPatterns[i])
)
.catch(() => indices);
};

/**
* Get field list by providing an index patttern (or spec).
* @param options options for getting field list
Expand Down
29 changes: 29 additions & 0 deletions src/plugins/data_views/common/data_views/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

import { catchError, from, Observable, of } from 'rxjs';
import { mergeMap, last, map, toArray } from 'rxjs/operators';
import type { RuntimeField, RuntimeFieldSpec, RuntimePrimitiveTypes } from '../types';

export const removeFieldAttrs = (runtimeField: RuntimeField): RuntimeFieldSpec => {
Expand All @@ -23,3 +25,30 @@ export const removeFieldAttrs = (runtimeField: RuntimeField): RuntimeFieldSpec =
...fieldsTypeOnly,
};
};

const MAX_CONCURRENT_REQUESTS = 3;
/**
* Helper function to run forkJoin
* with restrictions on how many input observables can be subscribed to concurrently
*/
export function rateLimitingForkJoin<T>(
observables: Array<Observable<T>>,
maxConcurrentRequests = MAX_CONCURRENT_REQUESTS,
failValue: T
): Observable<T[]> {
return from(observables).pipe(
mergeMap(
(observable, index) =>
observable.pipe(
last(),
map((value) => ({ index, value })),
catchError(() => of({ index, value: failValue }))
),
maxConcurrentRequests
),
toArray(),
map((indexedObservables) =>
indexedObservables.sort((l, r) => l.index - r.index).map((obs) => obs.value)
)
);
}
14 changes: 0 additions & 14 deletions test/scripts/jenkins_security_solution_cypress_firefox.sh

This file was deleted.

16 changes: 16 additions & 0 deletions x-pack/plugins/enterprise_search/jest.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../',
projects: [
'<rootDir>/x-pack/plugins/enterprise_search/public/**/jest.config.js',
'<rootDir>/x-pack/plugins/enterprise_search/common/**/jest.config.js',
'<rootDir>/x-pack/plugins/enterprise_search/server/**/jest.config.js',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: ['<rootDir>/x-pack/plugins/enterprise_search/public/applications/analytics'],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/analytics',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: ['<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search'],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/app_search',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: ['<rootDir>/x-pack/plugins/enterprise_search/public/applications/applications'],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/applications',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: ['<rootDir>/x-pack/plugins/enterprise_search/public/applications/elasticsearch'],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/elasticsearch',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../..',
roots: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content',
],
collectCoverage: true,
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts',
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content',
modulePathIgnorePatterns: [
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress',
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress',
],
};
Loading

0 comments on commit 74f25d3

Please sign in to comment.