From a03d54de41f9e504fb61b985bcc76b8ec4fd0632 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Mon, 14 Dec 2020 22:33:29 -0600 Subject: [PATCH] Move outdated integration test In the case of a successful migration, application of the cleanup policy is done by the deletion endpoint. In the interest of data preservation, we do not delete a sourceIndex unless it is explicitly deleted. --- .../tests/delete_signals_migrations.ts | 16 +++++++++++++ .../tests/finalize_signals_migrations.ts | 24 ------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts index 2f07dc00c2e14..040c83c458eb3 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts @@ -7,6 +7,7 @@ import expect from '@kbn/expect'; import { + DEFAULT_SIGNALS_INDEX, DETECTION_ENGINE_SIGNALS_FINALIZE_MIGRATION_URL, DETECTION_ENGINE_SIGNALS_MIGRATION_URL, } from '../../../../plugins/security_solution/common/constants'; @@ -28,6 +29,7 @@ interface FinalizeResponse extends CreateResponse { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { + const es = getService('es'); const esArchiver = getService('esArchiver'); const security = getService('security'); const supertest = getService('supertest'); @@ -86,6 +88,20 @@ export default ({ getService }: FtrProviderContext): void => { expect(deletedMigration.sourceIndex).to.eql(outdatedSignalsIndexName); }); + it('marks the original index for deletion by applying our cleanup policy', async () => { + await supertest + .delete(DETECTION_ENGINE_SIGNALS_MIGRATION_URL) + .set('kbn-xsrf', 'true') + .send({ migration_ids: [createdMigration.migration_id] }) + .expect(200); + + const { body } = await es.indices.getSettings({ index: createdMigration.index }); + const indexSettings = body[createdMigration.index].settings.index; + expect(indexSettings.lifecycle.name).to.eql( + `${DEFAULT_SIGNALS_INDEX}-default-migration-cleanup` + ); + }); + it('rejects the request if the user does not have sufficient privileges', async () => { await createUserAndRole(security, ROLES.t1_analyst); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts index 43fffd63b39f7..a754966cf18a9 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts @@ -7,7 +7,6 @@ import expect from '@kbn/expect'; import { - DEFAULT_SIGNALS_INDEX, DETECTION_ENGINE_SIGNALS_FINALIZE_MIGRATION_URL, DETECTION_ENGINE_SIGNALS_MIGRATION_STATUS_URL, DETECTION_ENGINE_SIGNALS_MIGRATION_URL, @@ -42,7 +41,6 @@ interface FinalizeResponse { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { - const es = getService('es'); const esArchiver = getService('esArchiver'); const kbnClient = getService('kibanaServer'); const security = getService('security'); @@ -165,28 +163,6 @@ export default ({ getService }: FtrProviderContext): void => { expect(statusAfter.map((s) => s.is_outdated)).to.eql([false, false]); }); - it('marks the original index for deletion by applying our cleanup policy', async () => { - await waitFor(async () => { - const { - body: { - migrations: [{ completed }], - }, - } = await supertest - .post(DETECTION_ENGINE_SIGNALS_FINALIZE_MIGRATION_URL) - .set('kbn-xsrf', 'true') - .send({ migration_ids: [createdMigration.migration_id] }) - .expect(200); - - return completed; - }, `polling finalize_migration until complete`); - - const { body } = await es.indices.getSettings({ index: createdMigration.index }); - const indexSettings = body[createdMigration.index].settings.index; - expect(indexSettings.lifecycle.name).to.eql( - `${DEFAULT_SIGNALS_INDEX}-default-migration-cleanup` - ); - }); - it.skip('deletes the underlying migration task', async () => { await waitFor(async () => { const {