Skip to content

Commit

Permalink
Merge branch 'main' into fix-node-roles-list
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyghiani committed Oct 2, 2023
2 parents 378765a + 06502b9 commit 4942585
Show file tree
Hide file tree
Showing 417 changed files with 16,900 additions and 3,651 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -274,6 +274,7 @@ packages/core/status/core-status-server-mocks @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-deprecations-getters @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-http-setup-browser @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-kbn-server @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-model-versions @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-so-type-serializer @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-test-utils @elastic/kibana-core
packages/core/theme/core-theme-browser @elastic/kibana-core
Expand Down Expand Up @@ -1239,6 +1240,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/plugins/security_solution/public/common/components/ml_popover @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/public/common/components/popover_items @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/public/detection_engine/fleet_integrations @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/public/detection_engine/endpoint_exceptions @elastic/security-defend-workflows
/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/public/detection_engine/rule_management @elastic/security-detection-rule-management
/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui @elastic/security-detection-rule-management
Expand Down Expand Up @@ -1336,6 +1338,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test/security_solution_endpoint_api_int/ @elastic/security-defend-workflows
/x-pack/test_serverless/shared/lib/security/kibana_roles/ @elastic/security-defend-workflows
/x-pack/plugins/security_solution_serverless/public/upselling/sections/endpoint_management @elastic/security-defend-workflows
/x-pack/plugins/security_solution_serverless/public/upselling/pages/endpoint_management @elastic/security-defend-workflows
/x-pack/plugins/security_solution_serverless/server/endpoint @elastic/security-defend-workflows

## Security Solution sub teams - security-telemetry (Data Engineering)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -936,8 +936,8 @@
"jsts": "^1.6.2",
"kea": "^2.4.2",
"langchain": "^0.0.151",
"launchdarkly-js-client-sdk": "^2.22.1",
"launchdarkly-node-server-sdk": "^6.4.2",
"launchdarkly-js-client-sdk": "^3.1.4",
"launchdarkly-node-server-sdk": "^7.0.3",
"load-json-file": "^6.2.0",
"lodash": "^4.17.21",
"lru-cache": "^4.1.5",
Expand Down Expand Up @@ -1180,6 +1180,7 @@
"@kbn/core-saved-objects-server-mocks": "link:packages/core/saved-objects/core-saved-objects-server-mocks",
"@kbn/core-status-server-mocks": "link:packages/core/status/core-status-server-mocks",
"@kbn/core-test-helpers-kbn-server": "link:packages/core/test-helpers/core-test-helpers-kbn-server",
"@kbn/core-test-helpers-model-versions": "link:packages/core/test-helpers/core-test-helpers-model-versions",
"@kbn/core-theme-browser-mocks": "link:packages/core/theme/core-theme-browser-mocks",
"@kbn/core-ui-settings-browser-mocks": "link:packages/core/ui-settings/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-server-mocks": "link:packages/core/ui-settings/core-ui-settings-server-mocks",
Expand Down
@@ -0,0 +1,19 @@
# @kbn/core-test-helpers-model-versions

Package exposing utilities for model version integration testing.

This package exposes a `createModelVersionTestBed` utility which allow simulating
a testbed environment where we're in the cohabitation period between two versions, to test the interactions
between two model versions of a set of SO types.

### Limitations:

Because the test bed is only creating the parts of Core required to create the two SO
repositories, and because we're not loading all plugins (for proper isolation), the integration
test bed has some limitations:

- no extensions are enabled
- no security
- no encryption
- no spaces
- all SO types will be using the same SO index
@@ -0,0 +1,16 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { createModelVersionTestBed } from './src/test_bed';

export type {
ModelVersionTestBed,
ModelVersionTestKit,
ModelVersionTestkitOptions,
SavedObjectTestkitDefinition,
} from './src/types';
@@ -0,0 +1,13 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/test-helpers/core-test-helpers-model-versions'],
};
@@ -0,0 +1,6 @@
{
"type": "shared-common",
"id": "@kbn/core-test-helpers-model-versions",
"owner": "@elastic/kibana-core",
"devOnly": true
}
@@ -0,0 +1,6 @@
{
"name": "@kbn/core-test-helpers-model-versions",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
@@ -0,0 +1,34 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { createTestServers, type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';

/**
* Start the traditional ES cluster and return the instance.
*/
export const startElasticsearch = async ({
basePath,
dataArchive,
timeout,
}: {
basePath?: string;
dataArchive?: string;
timeout?: number;
} = {}): Promise<TestElasticsearchUtils> => {
const { startES } = createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t + (timeout ?? 0)),
settings: {
es: {
license: 'basic',
basePath,
dataArchive,
},
},
});
return await startES();
};
@@ -0,0 +1,89 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { startElasticsearch } from './elasticsearch';
import { prepareModelVersionTestKit } from './test_kit';
import type { ModelVersionTestBed } from './types';

/**
* Create a {@link ModelVersionTestBed} that can be used for model version integration testing.
*
* @example
* ```ts
* describe('myIntegrationTest', () => {
* const testbed = createModelVersionTestBed();
* let testkit: ModelVersionTestKit;
*
* beforeAll(async () => {
* await testbed.startES();
* });
*
* afterAll(async () => {
* await testbed.stopES();
* });
*
* beforeEach(async () => {
* testkit = await testbed.prepareTestKit({
* savedObjectDefinitions: [{
* definition: mySoTypeDefinition,
* modelVersionBefore: 1,
* modelVersionAfter: 2,
* }]
* })
* });
*
* afterEach(async () => {
* if(testkit) {
* await testkit.tearsDown();
* }
* });
*
* it('can be used to test model version cohabitation', async () => {
* // last registered version is `1`
* const repositoryV1 = testkit.repositoryBefore;
* // last registered version is `2`
* const repositoryV2 = testkit.repositoryAfter;
*
* // do something with the two repositories, e.g
* await repositoryV1.create(someAttrs, { id });
* const v2docReadFromV1 = await repositoryV2.get('my-type', id);
* expect(v2docReadFromV1.attributes).toEqual(something);
* })
* })
* ```
*
* @public
*/
export const createModelVersionTestBed = (): ModelVersionTestBed => {
let elasticsearch: TestElasticsearchUtils | undefined;

const startES = async () => {
if (elasticsearch) {
throw new Error('Elasticsearch already started');
}
elasticsearch = await startElasticsearch();
};

const stopES = async () => {
if (!elasticsearch) {
throw new Error('Elasticsearch not started');
}
await elasticsearch.stop();
await delay(10);
elasticsearch = undefined;
};

return {
startES,
stopES,
prepareTestKit: prepareModelVersionTestKit,
};
};

const delay = (seconds: number) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));

0 comments on commit 4942585

Please sign in to comment.