mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Security Solution] Fix integration test (#211278)
## Summary Reenable a couple of entity store integration tests. - [x] REMOVE THE `.only` BEFORE MERGING IT - [wip] Flaky test runner
This commit is contained in:
parent
00d07af37f
commit
46c8c17728
2 changed files with 31 additions and 8 deletions
|
@ -14,6 +14,7 @@ import { dataViewRouteHelpersFactory } from '../../utils/data_view';
|
|||
export default ({ getService }: FtrProviderContext) => {
|
||||
const api = getService('securitySolutionApi');
|
||||
const supertest = getService('supertest');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
|
||||
const utils = EntityStoreUtils(getService);
|
||||
describe('@ess @skipInServerlessMKI Entity Store APIs', () => {
|
||||
|
@ -65,7 +66,9 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
});
|
||||
|
||||
it('should enable the entity store, creating both user and host engines', async () => {
|
||||
await utils.enableEntityStore();
|
||||
await utils.enableEntityStore({
|
||||
entityTypes: ['host', 'user'],
|
||||
});
|
||||
await utils.expectEngineAssetsExist('user');
|
||||
await utils.expectEngineAssetsExist('host');
|
||||
});
|
||||
|
@ -203,8 +206,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
});
|
||||
});
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/200758
|
||||
describe.skip('status', () => {
|
||||
describe('status', () => {
|
||||
afterEach(async () => {
|
||||
await utils.cleanEngines();
|
||||
});
|
||||
|
@ -219,7 +221,9 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
});
|
||||
|
||||
it('should return "installing" when at least one engine is being initialized', async () => {
|
||||
await utils.enableEntityStore();
|
||||
await utils.enableEntityStore({
|
||||
entityTypes: ['host', 'user'],
|
||||
});
|
||||
|
||||
const { body } = await api.getEntityStoreStatus({ query: {} }).expect(200);
|
||||
|
||||
|
@ -227,6 +231,12 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
expect(body.engines.length).toEqual(2);
|
||||
expect(body.engines[0].status).toEqual('installing');
|
||||
expect(body.engines[1].status).toEqual('installing');
|
||||
|
||||
// Make sure all engines have started before the test finishes to prevent flakiness
|
||||
await Promise.all([
|
||||
utils.waitForEngineStatus('host', 'started'),
|
||||
utils.waitForEngineStatus('user', 'started'),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return "started" when all engines are started', async () => {
|
||||
|
@ -265,6 +275,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
expect.objectContaining({ resource: 'ingest_pipeline' }),
|
||||
expect.objectContaining({ resource: 'index_template' }),
|
||||
expect.objectContaining({ resource: 'task' }),
|
||||
expect.objectContaining({ resource: 'task' }),
|
||||
expect.objectContaining({ resource: 'ingest_pipeline' }),
|
||||
expect.objectContaining({ resource: 'enrich_policy' }),
|
||||
expect.objectContaining({ resource: 'index' }),
|
||||
|
@ -274,10 +285,15 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
});
|
||||
});
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/209010
|
||||
describe.skip('apply_dataview_indices', () => {
|
||||
describe('apply_dataview_indices', () => {
|
||||
before(async () => {
|
||||
await utils.initEntityEngineForEntityTypesAndWait(['host']);
|
||||
|
||||
// Delete the data view refresh task so it doesn't interfere with the tests
|
||||
await kibanaServer.savedObjects.delete({
|
||||
type: 'task',
|
||||
id: 'entity_store:data_view:refresh:default:1.0.0',
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { EntityType } from '@kbn/security-solution-plugin/common/api/entity_analytics/entity_store/common.gen';
|
||||
import expect from '@kbn/expect';
|
||||
import { InitEntityStoreRequestBodyInput } from '@kbn/security-solution-plugin/common/api/entity_analytics/entity_store/enable.gen';
|
||||
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
|
||||
import { elasticAssetCheckerFactory } from './elastic_asset_checker';
|
||||
|
||||
|
@ -99,13 +100,19 @@ export const EntityStoreUtils = (
|
|||
.getEntityEngine({ params: { entityType } }, namespace)
|
||||
.expect(200);
|
||||
log.debug(`Engine status for ${entityType}: ${body.status}`);
|
||||
|
||||
if (status !== 'error' && body.status === 'error') {
|
||||
// If we are not expecting an error, throw the error to improve logging
|
||||
throw new Error(`Engine not started: ${JSON.stringify(body)}`);
|
||||
}
|
||||
|
||||
return body.status === status;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const enableEntityStore = async () => {
|
||||
const res = await api.initEntityStore({ body: {} }, namespace);
|
||||
const enableEntityStore = async (body: InitEntityStoreRequestBodyInput = {}) => {
|
||||
const res = await api.initEntityStore({ body }, namespace);
|
||||
if (res.status !== 200) {
|
||||
log.error(`Failed to enable entity store`);
|
||||
log.error(JSON.stringify(res.body));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue