From 2df08a00c7d2a290c06d01e373131aa6f2c2c9e2 Mon Sep 17 00:00:00 2001 From: Elena Shostak <elena.shostak@elastic.co> Date: Mon, 23 Dec 2024 22:16:44 +0100 Subject: [PATCH] wip --- .../default_configs/stateful.config.base.ts | 10 ++- .../fixtures/kbn_archiver/default_space.json | 40 +++++------ .../common/fixtures/kbn_archiver/space_1.json | 10 +-- .../common/fixtures/kbn_archiver/space_2.json | 12 ++-- .../common/suites/copy_to_space.agnostic.ts | 66 ++++++++++--------- .../common/suites/create.agnostic.ts | 4 +- .../common/suites/get.agnostic.ts | 4 +- .../security_and_spaces/apis/index.ts | 8 +-- .../stateful.common.config.ts | 7 ++ 9 files changed, 87 insertions(+), 74 deletions(-) diff --git a/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts b/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts index 8a6824b7475b8..c2d2fe65c4d83 100644 --- a/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts +++ b/x-pack/test/api_integration/deployment_agnostic/default_configs/stateful.config.base.ts @@ -39,10 +39,10 @@ export function createStatefulTestConfig<T extends DeploymentAgnosticCommonServi ) { return async ({ readConfigFile }: FtrConfigProviderContext) => { if (options.esServerArgs || options.kbnServerArgs) { - // throw new Error( - // `FTR doesn't provision custom ES/Kibana server arguments into the ESS deployment. - // It may lead to unexpected test failures on Cloud. Please contact #appex-qa.` - // ); + throw new Error( + `FTR doesn't provision custom ES/Kibana server arguments into the ESS deployment. + It may lead to unexpected test failures on Cloud. Please contact #appex-qa.` + ); } // if config is executed on CI or locally @@ -118,7 +118,6 @@ export function createStatefulTestConfig<T extends DeploymentAgnosticCommonServi `xpack.security.authc.realms.saml.${MOCK_IDP_REALM_NAME}.attributes.groups=${MOCK_IDP_ATTRIBUTE_ROLES}`, `xpack.security.authc.realms.saml.${MOCK_IDP_REALM_NAME}.attributes.name=${MOCK_IDP_ATTRIBUTE_NAME}`, `xpack.security.authc.realms.saml.${MOCK_IDP_REALM_NAME}.attributes.mail=${MOCK_IDP_ATTRIBUTE_EMAIL}`, - ...(options.esServerArgs ?? []), ], files: [ // Passing the roles that are equivalent to the ones we have in serverless @@ -150,7 +149,6 @@ export function createStatefulTestConfig<T extends DeploymentAgnosticCommonServi '--xpack.uptime.service.username=localKibanaIntegrationTestsUser', '--xpack.uptime.service.devUrl=mockDevUrl', '--xpack.uptime.service.manifestUrl=mockDevUrl', - ...(options.kbnServerArgs ?? []), ], }, }; diff --git a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/default_space.json b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/default_space.json index 1822fac324bde..1a6d80802bd23 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/default_space.json +++ b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/default_space.json @@ -139,7 +139,7 @@ "id": "conflict_2_default", "originId": "conflict_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUxMCwxXQ==" } @@ -151,7 +151,7 @@ "id": "conflict_2_all", "originId": "conflict_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUxMSwxXQ==" } @@ -163,7 +163,7 @@ "id": "conflict_1b_default", "originId": "conflict_1b_space_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwMywxXQ==" } @@ -175,7 +175,7 @@ "id": "conflict_1a_default", "originId": "conflict_1a", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwMCwxXQ==" } @@ -186,7 +186,7 @@ }, "id": "my_isolated_object", "references": [], - "type": "index-pattern", + "type": "url", "updated_at": "2017-09-21T18:49:16.270Z", "version": "WzQ4NywxXQ==" } @@ -197,7 +197,7 @@ }, "id": "all_spaces", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5NywxXQ==" } @@ -211,10 +211,10 @@ { "id": "each_space", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" } ], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ4OCwxXQ==" } @@ -228,25 +228,25 @@ { "id": "default_only", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" }, { "id": "space_1_only", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" }, { "id": "space_2_only", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" }, { "id": "all_spaces", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" } ], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5NiwxXQ==" } @@ -257,7 +257,7 @@ }, "id": "conflict_1c_default_and_space_1", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwNiwxXQ==" } @@ -268,7 +268,7 @@ }, "id": "default_and_space_1", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5MywxXQ==" } @@ -279,7 +279,7 @@ }, "id": "default_and_space_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5NCwxXQ==" } @@ -291,7 +291,7 @@ "id": "space_2_only_matching_origin", "originId": "space_2_only", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5MiwxXQ==" } @@ -302,7 +302,7 @@ }, "id": "alias_delete_inclusive", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5OCwxXQ==" } @@ -313,7 +313,7 @@ }, "id": "alias_delete_exclusive", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5OSwxXQ==" } @@ -324,7 +324,7 @@ }, "id": "space_1_and_space_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5NSwxXQ==" } diff --git a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_1.json b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_1.json index 06884f70a81d5..96b2b519a5da3 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_1.json +++ b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_1.json @@ -139,7 +139,7 @@ "id": "conflict_2_space_1", "originId": "conflict_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUxMCwxXQ==" } @@ -151,7 +151,7 @@ "id": "conflict_1b_space_1", "originId": "conflict_1b_space_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwNCwxXQ==" } @@ -163,7 +163,7 @@ "id": "conflict_1a_space_1", "originId": "conflict_1a", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwMSwxXQ==" } @@ -177,10 +177,10 @@ { "id": "each_space", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" } ], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ4OSwxXQ==" } diff --git a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_2.json b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_2.json index 5e60123795f7d..65d66e305d1c3 100644 --- a/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_2.json +++ b/x-pack/test/spaces_api_integration/common/fixtures/kbn_archiver/space_2.json @@ -5,7 +5,7 @@ "id": "conflict_2_space_2", "originId": "conflict_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUxMCwxXQ==" } @@ -17,7 +17,7 @@ "id": "conflict_1c_space_2", "originId": "conflict_1c_default_and_space_1", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwNywxXQ==" } @@ -28,7 +28,7 @@ }, "id": "conflict_1b_space_2", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwNSwxXQ==" } @@ -40,7 +40,7 @@ "id": "conflict_1a_space_2", "originId": "conflict_1a", "references": [], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzUwMiwxXQ==" } @@ -54,10 +54,10 @@ { "id": "each_space", "name": "refname", - "type": "index-pattern" + "type": "event-annotation-group" } ], - "type": "index-pattern", + "type": "event-annotation-group", "updated_at": "2017-09-21T18:59:16.270Z", "version": "WzQ5MSwxXQ==" } diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.agnostic.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.agnostic.ts index 3681ddb7cc658..f5ef4dc937a92 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.agnostic.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.agnostic.ts @@ -514,7 +514,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid // the status code of the HTTP response differs depending on the error type // a 403 error actually comes back as an HTTP 200 response const statusCode = outcome === 'noAccess' ? 403 : 200; - const type = 'sharedtype'; + const type = 'event-annotation-group'; const noConflictId = `${spaceId}_only`; const exactMatchId = 'each_space'; const inexactMatchIdA = `conflict_1a_${spaceId}`; @@ -529,7 +529,11 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid success: false, successCount: 0, errors: [ - { statusCode: 403, error: 'Forbidden', message: `Unable to bulk_create sharedtype` }, + { + statusCode: 403, + error: 'Forbidden', + message: `Unable to bulk_create event-annotation-group`, + }, ], }, }); @@ -541,7 +545,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid expect(successCount).to.eql(1); const destinationId = successResults![0].destinationId; expect(destinationId).to.match(UUID_PATTERN); - const meta = { title, icon: 'beaker' }; + const meta = { title, icon: 'flag' }; const managed = false; // default added By `create` expect(successResults).to.eql([{ type, id: sourceId, meta, destinationId, managed }]); expect(errors).to.be(undefined); @@ -607,7 +611,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid const { success, successCount, successResults, errors } = getResult(response); const title = 'This is used to test an inexact match conflict for an originId -> originId match'; - const meta = { title, icon: 'beaker' }; + const meta = { title, icon: 'flag' }; const destinationId = 'conflict_1a_space_2'; if (createNewCopies) { expectNewCopyResponse(response, inexactMatchIdA, title); @@ -655,7 +659,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid const { success, successCount, successResults, errors } = getResult(response); const title = 'This is used to test an inexact match conflict for an originId -> id match'; - const meta = { title, icon: 'beaker' }; + const meta = { title, icon: 'flag' }; const destinationId = 'conflict_1b_space_2'; if (createNewCopies) { expectNewCopyResponse(response, inexactMatchIdB, title); @@ -703,7 +707,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid const { success, successCount, successResults, errors } = getResult(response); const title = 'This is used to test an inexact match conflict for an id -> originId match'; - const meta = { title, icon: 'beaker' }; + const meta = { title, icon: 'flag' }; const destinationId = 'conflict_1c_space_2'; if (createNewCopies) { expectNewCopyResponse(response, inexactMatchIdC, title); @@ -779,7 +783,7 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid error: { type: 'ambiguous_conflict', destinations }, type, id: ambiguousConflictId, - meta: { title, icon: 'beaker' }, + meta: { title, icon: 'flag' }, }, ]); } @@ -945,30 +949,30 @@ export function copyToSpaceTestSuiteFactory(context: DeploymentAgnosticFtrProvid }); }); - [ - [false, false], - [false, true], // createNewCopies enabled - [true, false], // overwrite enabled - // we don't specify tese cases with both overwrite and createNewCopies enabled, since overwrite won't matter in that scenario - ].forEach(([overwrite, createNewCopies]) => { - const spaces = ['space_2']; - const includeReferences = false; - describe(`multi-namespace types with overwrite=${overwrite} and createNewCopies=${createNewCopies}`, () => { - before(async () => await testDataLoader.createFtrSavedObjectsData(SPACE_DATA_TO_LOAD)); - after(async () => await testDataLoader.deleteFtrSavedObjectsData()); - - const testCases = tests.multiNamespaceTestCases(overwrite, createNewCopies); - testCases.forEach(({ testTitle, objects, statusCode, response }) => { - it(`should return ${statusCode} when ${testTitle}`, async () => { - return supertest - .post(`${getUrlPrefix(spaceId)}/api/spaces/_copy_saved_objects`) - .send({ objects, spaces, includeReferences, createNewCopies, overwrite }) - .expect(statusCode) - .then(response); - }); - }); - }); - }); + // [ + // [false, false], + // [false, true], // createNewCopies enabled + // [true, false], // overwrite enabled + // // we don't specify tese cases with both overwrite and createNewCopies enabled, since overwrite won't matter in that scenario + // ].forEach(([overwrite, createNewCopies]) => { + // const spaces = ['space_2']; + // const includeReferences = false; + // describe(`multi-namespace types with overwrite=${overwrite} and createNewCopies=${createNewCopies}`, () => { + // before(async () => await testDataLoader.createFtrSavedObjectsData(SPACE_DATA_TO_LOAD)); + // after(async () => await testDataLoader.deleteFtrSavedObjectsData()); + + // const testCases = tests.multiNamespaceTestCases(overwrite, createNewCopies); + // testCases.forEach(({ testTitle, objects, statusCode, response }) => { + // it(`should return ${statusCode} when ${testTitle}`, async () => { + // return supertest + // .post(`${getUrlPrefix(spaceId)}/api/spaces/_copy_saved_objects`) + // .send({ objects, spaces, includeReferences, createNewCopies, overwrite }) + // .expect(statusCode) + // .then(response); + // }); + // }); + // }); + // }); }); }; diff --git a/x-pack/test/spaces_api_integration/common/suites/create.agnostic.ts b/x-pack/test/spaces_api_integration/common/suites/create.agnostic.ts index 7e99431fd2a44..9e300b40eecd1 100644 --- a/x-pack/test/spaces_api_integration/common/suites/create.agnostic.ts +++ b/x-pack/test/spaces_api_integration/common/suites/create.agnostic.ts @@ -7,7 +7,7 @@ import type { Agent as SuperTestAgent } from 'supertest'; -import expect from '@kbn/expect'; +import expect from '@kbn/expect/expect'; import type { DeploymentAgnosticFtrProviderContext, @@ -91,9 +91,11 @@ export function createTestSuiteFactory({ getService }: DeploymentAgnosticFtrProv 'inventory', 'logs', 'observabilityCases', + 'observabilityCasesV2', 'securitySolutionAssistant', 'securitySolutionAttackDiscovery', 'securitySolutionCases', + 'securitySolutionCasesV2', 'siem', 'slo', 'uptime', diff --git a/x-pack/test/spaces_api_integration/common/suites/get.agnostic.ts b/x-pack/test/spaces_api_integration/common/suites/get.agnostic.ts index b4630e750e55c..a0a5f1eeb553a 100644 --- a/x-pack/test/spaces_api_integration/common/suites/get.agnostic.ts +++ b/x-pack/test/spaces_api_integration/common/suites/get.agnostic.ts @@ -7,7 +7,7 @@ import type { Agent as SuperTestAgent } from 'supertest'; -import expect from '@kbn/expect'; +import expect from '@kbn/expect/expect'; import { getSupertest, maybeDestroySupertest } from './common'; import type { @@ -91,9 +91,11 @@ export function getTestSuiteFactory(context: DeploymentAgnosticFtrProviderContex 'inventory', 'logs', 'observabilityCases', + 'observabilityCasesV2', 'securitySolutionAssistant', 'securitySolutionAttackDiscovery', 'securitySolutionCases', + 'securitySolutionCasesV2', 'siem', 'slo', 'uptime', diff --git a/x-pack/test/spaces_api_integration/deployment_agnostic/security_and_spaces/apis/index.ts b/x-pack/test/spaces_api_integration/deployment_agnostic/security_and_spaces/apis/index.ts index ef9a70fd961a1..c1911110409c7 100644 --- a/x-pack/test/spaces_api_integration/deployment_agnostic/security_and_spaces/apis/index.ts +++ b/x-pack/test/spaces_api_integration/deployment_agnostic/security_and_spaces/apis/index.ts @@ -21,10 +21,10 @@ export default function ({ loadTestFile, getService }: DeploymentAgnosticFtrProv } }); // loadTestFile(require.resolve('./resolve_copy_to_space_conflicts')); - loadTestFile(require.resolve('./create')); - loadTestFile(require.resolve('./delete')); - loadTestFile(require.resolve('./get_all')); + // loadTestFile(require.resolve('./create')); + // loadTestFile(require.resolve('./delete')); + // loadTestFile(require.resolve('./get_all')); loadTestFile(require.resolve('./get')); - loadTestFile(require.resolve('./update')); + // loadTestFile(require.resolve('./update')); }); } diff --git a/x-pack/test/spaces_api_integration/deployment_agnostic/stateful.common.config.ts b/x-pack/test/spaces_api_integration/deployment_agnostic/stateful.common.config.ts index 6f03cf33d2eaf..67bcdbdaea7ea 100644 --- a/x-pack/test/spaces_api_integration/deployment_agnostic/stateful.common.config.ts +++ b/x-pack/test/spaces_api_integration/deployment_agnostic/stateful.common.config.ts @@ -65,6 +65,13 @@ export function createTestConfig({ // `--plugin-path=${path.resolve(__dirname, '../common/plugins/spaces_test_plugin')}`, ], }, + esTestCluster: { + ...testConfig.esTestCluster, + serverArgs: [ + ...testConfig.esTestCluster.serverArgs, + `xpack.license.self_generated.type=${license}`, + ], + }, }; }; }