Skip to content

Commit

Permalink
Move outdated integration test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rylnd committed Dec 15, 2020
1 parent 728122d commit a03d54d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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');
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a03d54d

Please sign in to comment.