From 424eae3f4d0f55f684a5b3c3b46847eb723233c9 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 3 May 2023 08:57:57 +0200 Subject: [PATCH] [functional tests] split security and spaces ftr configs (#156350) ## Summary Splitting ftr configs to speed up ftr tests run on CI ``` The following "Functional Tests" configs have durations that exceed the maximum amount of time desired for a single CI job. This is not an error, and if you don't own any of these configs then you can ignore this warning.If you own any of these configs please split them up ASAP and ask Operations if you have questions about how to do that. x-pack/test/spaces_api_integration/security_and_spaces/config_basic.ts: 38.2 minutes x-pack/test/spaces_api_integration/security_and_spaces/config_trial.ts: 38.2 minutes ``` After split: x-pack/test/spaces_api_integration/security_and_spaces/config_basic.ts 20m 29s x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts 20m 52s x-pack/test/spaces_api_integration/security_and_spaces/config_trial.ts 19m 57s x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts 21m 5s Rebalancing it with other configs should speedup CI by at least few minutes --- .buildkite/ftr_configs.yml | 2 ++ .../spaces_api_integration/common/config.ts | 5 ++-- .../apis/{ => copy_to_space}/copy_to_space.ts | 8 +++---- .../apis/copy_to_space/index.ts | 23 +++++++++++++++++++ .../security_and_spaces/apis/index.ts | 20 ++++++++-------- .../copy_to_space_config_basic.ts | 14 +++++++++++ .../copy_to_space_config_trial.ts | 14 +++++++++++ 7 files changed, 70 insertions(+), 16 deletions(-) rename x-pack/test/spaces_api_integration/security_and_spaces/apis/{ => copy_to_space}/copy_to_space.ts (96%) create mode 100644 x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/index.ts create mode 100644 x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts create mode 100644 x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts diff --git a/.buildkite/ftr_configs.yml b/.buildkite/ftr_configs.yml index 6c0ee435b5e20..db022ae7f0f58 100644 --- a/.buildkite/ftr_configs.yml +++ b/.buildkite/ftr_configs.yml @@ -353,7 +353,9 @@ enabled: - x-pack/test/security_solution_endpoint/config.ts - x-pack/test/session_view/basic/config.ts - x-pack/test/spaces_api_integration/security_and_spaces/config_basic.ts + - x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts - x-pack/test/spaces_api_integration/security_and_spaces/config_trial.ts + - x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts - x-pack/test/spaces_api_integration/spaces_only/config.ts - x-pack/test/timeline/security_and_spaces/config_trial.ts - x-pack/test/ui_capabilities/security_and_spaces/config.ts diff --git a/x-pack/test/spaces_api_integration/common/config.ts b/x-pack/test/spaces_api_integration/common/config.ts index da29de4033eb8..3e0cd4b0a38bb 100644 --- a/x-pack/test/spaces_api_integration/common/config.ts +++ b/x-pack/test/spaces_api_integration/common/config.ts @@ -13,10 +13,11 @@ import { FtrConfigProviderContext } from '@kbn/test'; interface CreateTestConfigOptions { license: string; disabledPlugins?: string[]; + testFiles?: string[]; } export function createTestConfig(name: string, options: CreateTestConfigOptions) { - const { license, disabledPlugins = [] } = options; + const { license, disabledPlugins = [], testFiles } = options; return async ({ readConfigFile }: FtrConfigProviderContext) => { const config = { @@ -32,7 +33,7 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) }; return { - testFiles: [require.resolve(`../${name}/apis/`)], + testFiles: testFiles ?? [require.resolve(`../${name}/apis/`)], servers: config.xpack.api.get('servers'), services: { es: config.kibana.api.get('services.es'), diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/copy_to_space.ts similarity index 96% rename from x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space.ts rename to x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/copy_to_space.ts index 2a99ae8afceb6..90b2cc67439d7 100644 --- a/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/copy_to_space.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { AUTHENTICATION } from '../../common/lib/authentication'; -import { SPACES } from '../../common/lib/spaces'; -import { copyToSpaceTestSuiteFactory } from '../../common/suites/copy_to_space'; -import { FtrProviderContext } from '../../common/ftr_provider_context'; +import { AUTHENTICATION } from '../../../common/lib/authentication'; +import { SPACES } from '../../../common/lib/spaces'; +import { copyToSpaceTestSuiteFactory } from '../../../common/suites/copy_to_space'; +import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default function copyToSpaceSpacesAndSecuritySuite(context: FtrProviderContext) { diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/index.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/index.ts new file mode 100644 index 0000000000000..c1edb1e5e5ac1 --- /dev/null +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/copy_to_space/index.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +import { createUsersAndRoles } from '../../../common/lib/create_users_and_roles'; +import { FtrProviderContext } from '../../../common/ftr_provider_context'; + +// eslint-disable-next-line import/no-default-export +export default function ({ loadTestFile, getService }: FtrProviderContext) { + const es = getService('es'); + const supertest = getService('supertest'); + + describe('copy to space with security', function () { + before(async () => { + await createUsersAndRoles(es, supertest); + }); + + loadTestFile(require.resolve('./copy_to_space')); // ~ 19m 20s + }); +} diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts index 75381f35dacd3..ae5f7b48a2809 100644 --- a/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/index.ts @@ -18,15 +18,15 @@ export default function ({ loadTestFile, getService }: FtrProviderContext) { await createUsersAndRoles(es, supertest); }); - loadTestFile(require.resolve('./copy_to_space')); - loadTestFile(require.resolve('./resolve_copy_to_space_conflicts')); - loadTestFile(require.resolve('./create')); - loadTestFile(require.resolve('./delete')); - loadTestFile(require.resolve('./get_all')); - loadTestFile(require.resolve('./get_shareable_references')); - loadTestFile(require.resolve('./get')); - loadTestFile(require.resolve('./update')); - loadTestFile(require.resolve('./update_objects_spaces')); - loadTestFile(require.resolve('./disable_legacy_url_aliases')); + // total runtime ~ 17m + loadTestFile(require.resolve('./resolve_copy_to_space_conflicts')); // ~ 10m + loadTestFile(require.resolve('./create')); // ~ 2m + loadTestFile(require.resolve('./delete')); // ~ 1m 20s + loadTestFile(require.resolve('./get_all')); // ~ 50s + loadTestFile(require.resolve('./get_shareable_references')); // ~ 30s + loadTestFile(require.resolve('./get')); // ~ 30s + loadTestFile(require.resolve('./update')); // ~ 30s + loadTestFile(require.resolve('./update_objects_spaces')); // ~ 1m + loadTestFile(require.resolve('./disable_legacy_url_aliases')); // ~ 30s }); } diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts b/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts new file mode 100644 index 0000000000000..609d747fa8861 --- /dev/null +++ b/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_basic.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +import { createTestConfig } from '../common/config'; + +// eslint-disable-next-line import/no-default-export +export default createTestConfig('security_and_spaces', { + license: 'basic', + testFiles: [require.resolve('./apis/copy_to_space')], +}); diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts b/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts new file mode 100644 index 0000000000000..da8834134f258 --- /dev/null +++ b/x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +import { createTestConfig } from '../common/config'; + +// eslint-disable-next-line import/no-default-export +export default createTestConfig('security_and_spaces', { + license: 'trial', + testFiles: [require.resolve('./apis/copy_to_space')], +});