Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solutions][Detection Engine] Changes the loading of indexes in tests from beforeEach() to before() #110340

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('creating rules', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should create a single rule with a rule_id', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ export default ({ getService }: FtrProviderContext): void => {
});

describe('creating rules in bulk', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should create a single rule with a rule_id', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ export default ({ getService }: FtrProviderContext): void => {
const es = getService('es');

describe('find_statuses', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await deleteAllRulesStatuses(es);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should return an empty find statuses body correctly if no statuses are loaded', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,22 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('tests with auditbeat data', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await deleteAllAlerts(supertest);
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should be able to execute and get 10 signals', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ export default ({ getService }: FtrProviderContext) => {

describe('add_actions', () => {
describe('adding actions', () => {
beforeEach(async () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should be able to create a new webhook action and attach it to a rule', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@ export default ({ getService }: FtrProviderContext) => {
}

describe('Tests involving aliases of source indexes and the signals index', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/security_solution/alias');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/alias');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/security_solution/alias');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/security_solution/alias');
});

it('should keep the original alias value such as "host_alias" from a source index when the value is indexed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,30 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');

describe('Rule exception operators for endpoints', () => {
beforeEach(async () => {
await createSignalsIndex(supertest);
await createListsIndex(supertest);
before(async () => {
await esArchiver.load(
'x-pack/test/functional/es_archives/rule_exceptions/endpoint_without_host_type'
);
await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/agent');
});

after(async () => {
await esArchiver.unload(
'x-pack/test/functional/es_archives/rule_exceptions/endpoint_without_host_type'
);
await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/agent');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await createListsIndex(supertest);
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await deleteAllExceptions(es);
await deleteListsIndex(supertest);
await esArchiver.unload(
'x-pack/test/functional/es_archives/rule_exceptions/endpoint_without_host_type'
);
await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/agent');
});

describe('no exceptions set', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,23 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');

describe('create_rules_with_exceptions', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

describe('creating rules with exceptions', () => {
beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await deleteAllExceptions(es);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

describe('elastic admin', () => {
Expand Down Expand Up @@ -529,16 +535,22 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('tests with auditbeat data', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await deleteAllExceptions(es);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should be able to execute against an exception list that does not include valid entries and get back 10 signals', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('creating rules', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

describe('elastic admin', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ export default ({ getService }: FtrProviderContext): void => {
});

describe('creating rules in bulk', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should create a single rule with a rule_id', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,21 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('creating threat match rule', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should create a single rule with a rule_id', async () => {
Expand Down Expand Up @@ -106,16 +112,22 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('tests with auditbeat data', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

beforeEach(async () => {
await deleteAllAlerts(supertest);
await createSignalsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/auditbeat/hosts');
});

it('should be able to execute and get 10 signals when doing a specific query', async () => {
Expand Down Expand Up @@ -399,11 +411,11 @@ export default ({ getService }: FtrProviderContext) => {
});

describe('indicator enrichment', () => {
beforeEach(async () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/threat_intel');
});

afterEach(async () => {
after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/filebeat/threat_intel');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@ export default ({ getService }: FtrProviderContext) => {
const es = getService('es');

describe('Rule exception operators for data type date', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/date');
});

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/date');
});

beforeEach(async () => {
await createSignalsIndex(supertest);
await createListsIndex(supertest);
await esArchiver.load('x-pack/test/functional/es_archives/rule_exceptions/date');
});

afterEach(async () => {
await deleteSignalsIndex(supertest);
await deleteAllAlerts(supertest);
await deleteAllExceptions(es);
await deleteListsIndex(supertest);
await esArchiver.unload('x-pack/test/functional/es_archives/rule_exceptions/date');
});

describe('"is" operator', () => {
Expand Down
Loading