Skip to content

Commit

Permalink
Completed the first part which is the backend tests to run less than …
Browse files Browse the repository at this point in the history
…600 megs (elastic#118734)

## Summary

This addresses parts of elastic#117255

By introducing top level mocks for:
* `core/server/index.ts`
* `task_manager/server/index.ts`
* `alerting/server/index.ts`
* `actions/server/index.ts`

These top level mocks add the few required functions we use sparingly and adds them from the "restricted zones" to avoid giant typescript imports from happening from the server side which also pulls in the memory leaks. 

```ts
moduleNameMapper: {
    'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
    'task_manager/server$':
      '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
    'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
    'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
  },
```

For testing this you can now run:
```sh
node --max-old-space-size=600 --expose-gc ./node_modules/.bin/jest --runInBand --logHeapUsage --detectOpenHandles --no-cache --config x-pack/plugins/security_solution/jest.config.dev.js x-pack/plugins/security_solution/server
```

And the server side tests will be able to complete in less than 600 megs of memory. The memory leaks and memory consumption issues are mitigated through the layers but this doesn't guarantee that in the future these won't show up again. The root of the issue(s) with the memory leaks from `core/server` aren't addressed here as those are separate concerns at this point but this at least mitigates the amount of leakage from our side for now.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
  • Loading branch information
FrankHassanabad authored and kibanamachine committed Nov 17, 2021
1 parent f537c11 commit 8f5b4c5
Show file tree
Hide file tree
Showing 31 changed files with 235 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ListId, NamespaceType } from '@kbn/securitysolution-io-ts-list-typ
import { getSavedObjectType } from '@kbn/securitysolution-list-utils';
import { asyncForEach } from '@kbn/std';

import { SavedObjectsClientContract } from '../../../../../../src/core/server/';
import { SavedObjectsClientContract } from '../../../../../../src/core/server';

import { findExceptionListItem } from './find_exception_list_item';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils';
import {
SavedObjectsClientContract,
SavedObjectsErrorHelpers,
} from '../../../../../../src/core/server/';
} from '../../../../../../src/core/server';
import { ExceptionListSoSchema } from '../../schemas/saved_objects';

import { transformSavedObjectToExceptionList } from './utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils';
import {
SavedObjectsClientContract,
SavedObjectsErrorHelpers,
} from '../../../../../../src/core/server/';
} from '../../../../../../src/core/server';
import { ExceptionListSoSchema } from '../../schemas/saved_objects';

import { transformSavedObjectToExceptionListItem } from './utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getSavedObjectType } from '@kbn/securitysolution-list-utils';
import {
SavedObjectsClientContract,
SavedObjectsErrorHelpers,
} from '../../../../../../src/core/server/';
} from '../../../../../../src/core/server';
import { ExceptionListSoSchema } from '../../schemas/saved_objects';

interface GetExceptionListSummaryOptions {
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/common/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/common',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/common/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/public/app/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/app',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/app/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/public/cases/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/cases',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/cases/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/public/common/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/common',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/common/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/security_solution/public/detections/**/*.{ts,tsx}',
],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/public/hosts/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/hosts',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/hosts/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/public/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/security_solution/public/management/**/*.{ts,tsx}',
],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/network',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/network/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/overview',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/overview/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/resolver',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/resolver/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/security_solution/public/timelines/**/*.{ts,tsx}',
],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/security_solution/public/transforms/**/*.{ts,tsx}',
],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core.
module.exports = {};
19 changes: 19 additions & 0 deletions x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core.

import { parseDuration } from '../../../alerting/common/parse_duration';
// We _must_ import from the restricted path or we pull in _everything_ including memory leaks from Kibana core
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ReadOperations, WriteOperations } from '../../../alerting/server/authorization';

module.exports = {
parseDuration,
ReadOperations,
WriteOperations,
};
15 changes: 15 additions & 0 deletions x-pack/plugins/security_solution/server/__mocks__/core.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core.

// We _must_ import from the restricted path or we pull in _everything_ including memory leaks from Kibana core
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObjectsUtils } from '../../../../../src/core/server/saved_objects/service/lib/utils';
module.exports = {
SavedObjectsUtils,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// See: https://github.com/elastic/kibana/issues/117255, this creates mocks to avoid memory leaks from kibana core.

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { TaskStatus } from '../../../task_manager/server/task';
module.exports = {
TaskStatus,
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/server/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/client',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/server/client/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/endpoint',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/server/endpoint/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/security_solution/server/fleet_integration/**/*.{ts,tsx}',
],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/server',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/server/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { coreMock } from 'src/core/server/mocks';
import { ActionsApiRequestHandlerContext } from '../../../../../../actions/server';
import { AlertingApiRequestHandlerContext } from '../../../../../../alerting/server';
import { rulesClientMock } from '../../../../../../alerting/server/mocks';
import { actionsClientMock } from '../../../../../../actions/server/mocks';

// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
// We cannot import from "../../../../../../actions/server" directly here or we have a really bad memory issue. We cannot add this to the existing mocks we created, this fix must be here.
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { actionsClientMock } from '../../../../../../actions/server/actions_client.mock';
import { licensingMock } from '../../../../../../licensing/server/mocks';
import { listMock } from '../../../../../../lists/server/mocks';
import { ruleRegistryMocks } from '../../../../../../rule_registry/server/mocks';
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/server/lib/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ module.exports = {
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/server/lib',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/server/lib/**/*.{ts,tsx}'],
// See: https://github.com/elastic/kibana/issues/117255, the moduleNameMapper creates mocks to avoid memory leaks from kibana core.
moduleNameMapper: {
'core/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/core.mock.ts',
'task_manager/server$':
'<rootDir>/x-pack/plugins/security_solution/server/__mocks__/task_manager.mock.ts',
'alerting/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/alert.mock.ts',
'actions/server$': '<rootDir>/x-pack/plugins/security_solution/server/__mocks__/action.mock.ts',
},
};
Loading

0 comments on commit 8f5b4c5

Please sign in to comment.