Skip to content

Commit

Permalink
Merge branch 'main' into task-manager/mget-poll-interval
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Aug 7, 2024
2 parents 1e6b1ac + 7df01e9 commit 08c81cb
Show file tree
Hide file tree
Showing 304 changed files with 5,361 additions and 3,062 deletions.
2 changes: 2 additions & 0 deletions .buildkite/ftr_base_serverless_configs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
disabled:
# Base config files, only necessary to inform config finding script

# Serverless deployment-agnostic default config for api-integration tests
- x-pack/test/api_integration/deployment_agnostic/default_configs/serverless.config.base.ts
# Serverless base config files
- x-pack/test_serverless/api_integration/config.base.ts
- x-pack/test_serverless/functional/config.base.ts
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/ftr_oblt_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ enabled:
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group6.ts
- x-pack/test_serverless/functional/test_suites/observability/config.screenshots.ts
# serverless config files that run deployment-agnostic tests
- x-pack/test/api_integration/deployment_agnostic/oblt.serverless.config.ts
5 changes: 4 additions & 1 deletion .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
disabled:
# Stateful base config for deployment-agnostic tests
- x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts
# Base config files, only necessary to inform config finding script
- test/functional/config.base.js
- test/functional/firefox/config.base.ts
Expand Down Expand Up @@ -155,7 +157,6 @@ enabled:
- x-pack/test/api_integration/apis/monitoring/config.ts
- x-pack/test/api_integration/apis/monitoring_collection/config.ts
- x-pack/test/api_integration/apis/osquery/config.ts
- x-pack/test/api_integration/apis/painless_lab/config.ts
- x-pack/test/api_integration/apis/search/config.ts
- x-pack/test/api_integration/apis/searchprofiler/config.ts
- x-pack/test/api_integration/apis/security/config.ts
Expand Down Expand Up @@ -359,3 +360,5 @@ enabled:
- x-pack/performance/journeys_e2e/apm_service_inventory.ts
- x-pack/performance/journeys_e2e/infra_hosts_view.ts
- x-pack/test/custom_branding/config.ts
# stateful config files that run deployment-agnostic tests
- x-pack/test/api_integration/deployment_agnostic/stateful.config.ts
2 changes: 2 additions & 0 deletions .buildkite/ftr_search_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ enabled:
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group4.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group6.ts
# serverless config files that run deployment-agnostic tests
- x-pack/test/api_integration/deployment_agnostic/search.serverless.config.ts
2 changes: 2 additions & 0 deletions .buildkite/ftr_security_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/edr_workflows/response_actions/trial_license_complete_tier/configs/serverless.config.ts
- x-pack/test/security_solution_endpoint/configs/serverless.endpoint.config.ts
- x-pack/test/security_solution_endpoint/configs/serverless.integrations.config.ts
# serverless config files that run deployment-agnostic tests
- x-pack/test/api_integration/deployment_agnostic/security.serverless.config.ts
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ module.exports = {
'test/*/*.config.ts',
'test/*/{tests,test_suites,apis,apps}/**/*',
'test/server_integration/**/*.ts',
'x-pack/test/*/{tests,test_suites,apis,apps}/**/*',
'x-pack/test/*/{tests,test_suites,apis,apps,deployment_agnostic}/**/*',
'x-pack/test/*/*config.*ts',
'x-pack/test/saved_object_api_integration/*/apis/**/*',
'x-pack/test/ui_capabilities/*/tests/**/*',
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ x-pack/test/observability_ai_assistant_functional @elastic/obs-ai-assistant
/x-pack/test_serverless/functional/test_suites/security/ftr/ @elastic/appex-qa
/x-pack/test_serverless/functional/test_suites/common/home_page/ @elastic/appex-qa
/x-pack/test_serverless/**/services/ @elastic/appex-qa
/packages/kbn-es/src/stateful_resources/roles.yml @elastic/appex-qa

# Core
/config/ @elastic/kibana-core
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export {
readRolesDescriptorsFromResource,
} from './src/utils';
export type { ArtifactLicense } from './src/artifact';
export { SERVERLESS_ROLES_ROOT_PATH } from './src/paths';
export { SERVERLESS_ROLES_ROOT_PATH, STATEFUL_ROLES_ROOT_PATH } from './src/paths';
2 changes: 2 additions & 0 deletions packages/kbn-es/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const ES_CONFIG = 'config/elasticsearch.yml';

export const ES_KEYSTORE_BIN = maybeUseBat('./bin/elasticsearch-keystore');

export const STATEFUL_ROLES_ROOT_PATH = resolve(__dirname, './stateful_resources');

export const SERVERLESS_OPERATOR_USERS_PATH = resolve(
__dirname,
'./serverless_resources/operator_users.yml'
Expand Down
130 changes: 130 additions & 0 deletions packages/kbn-es/src/stateful_resources/roles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# -----
# This file is for information purpose only. 'viewer' and 'editor' roles are defined in stateful Elasticsearch by default
# Source: https://github.com/elastic/elasticsearch/blob/4272164530807787d4d8b991e3095a6e79176dbf/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java#L861-L952
# Note: inconsistency between these roles definition and the same roles of serverless project may break FTR deployment-agnostic tests
# -----
viewer:
cluster: []
indices:
- names:
- '.alerts*'
- '.preview.alerts*'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
- names:
- '.items-*'
- '.lists-*'
- '.siem-signals*'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
- names:
- '/~(([.]|ilm-history-).*)/'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
- names:
- '.profiling-*'
- 'profiling-*'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
applications:
- application: 'kibana-.kibana'
privileges:
- 'read'
resources:
- '*'
run_as: []

editor:
cluster: []
indices:
- names:
- 'observability-annotations'
privileges:
- 'read'
- 'view_index_metadata'
- 'write'
allow_restricted_indices: false
- names:
- '.items-*'
- '.lists-*'
- '.siem-signals*'
privileges:
- 'maintenance'
- 'read'
- 'view_index_metadata'
- 'write'
allow_restricted_indices: false
- names:
- '/~(([.]|ilm-history-).*)/'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
- names:
- '.profiling-*'
- 'profiling-*'
privileges:
- 'read'
- 'view_index_metadata'
allow_restricted_indices: false
- names:
- '.alerts*'
- '.internal.alerts*'
- '.internal.preview.alerts*'
- '.preview.alerts*'
privileges:
- 'maintenance'
- 'read'
- 'view_index_metadata'
- 'write'
allow_restricted_indices: false
applications:
- application: 'kibana-.kibana'
privileges:
- 'all'
resources:
- '*'
run_as: []

# Admin role without 'remote_indices' access definition
# There is no such built-in role in stateful, and it's a role "similar" to the built-in 'admin' role in serverless
admin:
# TODO: 'all' should be replaced with explicit list both here and serverless for deployment-agnostic tests with 'admin' role to be compatible
cluster: ['all']
indices:
- names: ['*']
privileges: ['all']
allow_restricted_indices: false
- names: ['*']
privileges:
- 'monitor'
- 'read'
- 'read_cross_cluster'
- 'view_index_metadata'
allow_restricted_indices: true
applications:
- application: '*'
privileges: ['*']
resources: ['*']
run_as: ['*']

# temporarily added for testing purpose
system_indices_superuser:
cluster: ['all']
indices:
- names: ['*']
privileges: ['all']
allow_restricted_indices: true
applications:
- application: '*'
privileges: ['*']
resources: ['*']
run_as: ['*']
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const visibleIndices = indexes
.map(({ name, suggestedAs }) => suggestedAs || name)
.sort();

const addTrailingSpace = (strings: string[], predicate: (s: string) => boolean = (_s) => true) =>
strings.map((string) => (predicate(string) ? `${string} ` : string));

const metadataFields = [...METADATA_FIELDS].sort();

describe('autocomplete.suggest', () => {
Expand All @@ -33,17 +36,17 @@ describe('autocomplete.suggest', () => {
test('suggests visible indices on space', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('from /', visibleIndices);
await assertSuggestions('FROM /', visibleIndices);
await assertSuggestions('from /index', visibleIndices);
await assertSuggestions('from /', addTrailingSpace(visibleIndices));
await assertSuggestions('FROM /', addTrailingSpace(visibleIndices));
await assertSuggestions('from /index', addTrailingSpace(visibleIndices));
});

test('suggests visible indices on comma', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('FROM a,/', visibleIndices);
await assertSuggestions('FROM a, /', visibleIndices);
await assertSuggestions('from *,/', visibleIndices);
await assertSuggestions('FROM a,/', addTrailingSpace(visibleIndices));
await assertSuggestions('FROM a, /', addTrailingSpace(visibleIndices));
await assertSuggestions('from *,/', addTrailingSpace(visibleIndices));
});

test('can suggest integration data sources', async () => {
Expand All @@ -52,17 +55,21 @@ describe('autocomplete.suggest', () => {
.filter(({ hidden }) => !hidden)
.map(({ name, suggestedAs }) => suggestedAs || name)
.sort();
const expectedSuggestions = addTrailingSpace(
visibleDataSources,
(s) => !integrations.find(({ name }) => name === s)
);
const { assertSuggestions, callbacks } = await setup();
const cb = {
...callbacks,
getSources: jest.fn().mockResolvedValue(dataSources),
};

assertSuggestions('from /', visibleDataSources, { callbacks: cb });
assertSuggestions('FROM /', visibleDataSources, { callbacks: cb });
assertSuggestions('FROM a,/', visibleDataSources, { callbacks: cb });
assertSuggestions('from a, /', visibleDataSources, { callbacks: cb });
assertSuggestions('from *,/', visibleDataSources, { callbacks: cb });
await assertSuggestions('from /', expectedSuggestions, { callbacks: cb });
await assertSuggestions('FROM /', expectedSuggestions, { callbacks: cb });
await assertSuggestions('FROM a,/', expectedSuggestions, { callbacks: cb });
await assertSuggestions('from a, /', expectedSuggestions, { callbacks: cb });
await assertSuggestions('from *,/', expectedSuggestions, { callbacks: cb });
});
});

Expand All @@ -71,7 +78,7 @@ describe('autocomplete.suggest', () => {

test('on <kbd>SPACE</kbd> without comma ",", suggests adding metadata', async () => {
const { assertSuggestions } = await setup();
const expected = ['METADATA $0', ',', '|'].sort();
const expected = ['METADATA $0', ',', '| '].sort();

await assertSuggestions('from a, b /', expected);
});
Expand All @@ -86,10 +93,10 @@ describe('autocomplete.suggest', () => {
test('on <kbd>SPACE</kbd> after "METADATA" column suggests command and pipe operators', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('from a, b [metadata _index /]', [',', '|']);
await assertSuggestions('from a, b metadata _index /', [',', '|']);
await assertSuggestions('from a, b metadata _index, _source /', [',', '|']);
await assertSuggestions(`from a, b metadata ${METADATA_FIELDS.join(', ')} /`, ['|']);
await assertSuggestions('from a, b [metadata _index /]', [',', '| ']);
await assertSuggestions('from a, b metadata _index /', [',', '| ']);
await assertSuggestions('from a, b metadata _index, _source /', [',', '| ']);
await assertSuggestions(`from a, b metadata ${METADATA_FIELDS.join(', ')} /`, ['| ']);
});

test('filters out already used metadata fields', async () => {
Expand Down
Loading

0 comments on commit 08c81cb

Please sign in to comment.