mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Run ILM jest tests as integration tests allowing them to run beyond 5s timeout (#141750)
This commit is contained in:
parent
042c76687c
commit
0471095d7d
67 changed files with 91 additions and 60 deletions
|
@ -115,4 +115,8 @@ this by running:
|
|||
|
||||
```bash
|
||||
yarn es snapshot --license=trial
|
||||
```
|
||||
```
|
||||
|
||||
## Integration tests
|
||||
|
||||
See `./integration_tests/README.md`
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
import { init } from './client_integration/helpers/http_requests';
|
||||
import { init } from '../integration_tests/helpers/http_requests';
|
||||
import { mountWithIntl } from '@kbn/test-jest-helpers';
|
||||
import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/public/mocks';
|
||||
import { Index } from '../common/types';
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
Most plugins of the deployment management team follow
|
||||
the similar testing infrastructure where integration tests are located in `__jest__` and run as unit tests.
|
||||
|
||||
The `index_lifecycle_management` tests [were refactored](https://github.com/elastic/kibana/pull/141750) to be run as integration tests because they [became flaky hitting the 5 seconds timeout](https://github.com/elastic/kibana/issues/115307#issuecomment-1238417474) for a jest unit test.
|
||||
|
||||
Jest integration tests are just sit in a different directory and have two main differences:
|
||||
- They never use parallelism, this allows them to access file system resources, launch services, etc. without needing to worry about conflicts with other tests
|
||||
- They are allowed to take their sweet time, the default timeout is currently 10 minutes.
|
||||
|
||||
To run these tests use:
|
||||
|
||||
```
|
||||
node scripts/jest_integration x-pack/plugins/index_lifecycle_management/
|
||||
```
|
|
@ -8,7 +8,7 @@
|
|||
import { act } from 'react-dom/test-utils';
|
||||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test-jest-helpers';
|
||||
import { App } from '../../../public/application/app';
|
||||
import { App } from '../../public/application/app';
|
||||
import { WithAppDependencies } from '../helpers';
|
||||
|
||||
const getTestBedConfig = (initialEntries: string[]): TestBedConfig => ({
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
import { PolicyFromES } from '../../../common/types';
|
||||
import { PolicyFromES } from '../../common/types';
|
||||
|
||||
import { defaultRolloverAction } from '../../../public/application/constants';
|
||||
import { defaultRolloverAction } from '../../public/application/constants';
|
||||
|
||||
export const POLICY_NAME = 'my_policy';
|
||||
export const SNAPSHOT_POLICY_NAME = 'my_snapshot_policy';
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { API_BASE_PATH } from '../../../../common/constants';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import {
|
||||
DELETE_PHASE_POLICY,
|
|
@ -14,7 +14,7 @@ import {
|
|||
createTogglePhaseAction,
|
||||
} from '../../helpers';
|
||||
import { initTestBed } from '../init_test_bed';
|
||||
import { AppServicesContext } from '../../../../public/types';
|
||||
import { AppServicesContext } from '../../../public/types';
|
||||
|
||||
type SetupReturn = ReturnType<typeof setupDownsampleTestBed>;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { TestBedConfig } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { AppServicesContext } from '../../../../../public/types';
|
||||
import { AppServicesContext } from '../../../../public/types';
|
||||
import { createTogglePhaseAction, createNodeAllocationActions } from '../../../helpers';
|
||||
import { initTestBed } from '../../init_test_bed';
|
||||
|
|
@ -17,7 +17,7 @@ import {
|
|||
POLICY_WITH_NODE_ATTR_AND_OFF_ALLOCATION,
|
||||
POLICY_WITH_NODE_ROLE_ALLOCATION,
|
||||
} from '../../constants';
|
||||
import { API_BASE_PATH } from '../../../../../common/constants';
|
||||
import { API_BASE_PATH } from '../../../../common/constants';
|
||||
|
||||
describe('<EditPolicy /> node allocation general behavior', () => {
|
||||
let testBed: GeneralNodeAllocationTestBed;
|
|
@ -18,7 +18,7 @@ import {
|
|||
createTogglePhaseAction,
|
||||
} from '../../helpers';
|
||||
import { initTestBed } from '../init_test_bed';
|
||||
import { AppServicesContext } from '../../../../public/types';
|
||||
import { AppServicesContext } from '../../../public/types';
|
||||
|
||||
type SetupReturn = ReturnType<typeof setupSearchableSnapshotsTestBed>;
|
||||
|
|
@ -10,7 +10,7 @@ import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
|
|||
import { HttpFetchOptionsWithPath } from '@kbn/core/public';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { getDefaultHotPhasePolicy } from '../constants';
|
||||
import { API_BASE_PATH } from '../../../../common/constants';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import {
|
||||
SearchableSnapshotsTestBed,
|
||||
setupSearchableSnapshotsTestBed,
|
|
@ -8,7 +8,7 @@
|
|||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { createTogglePhaseAction } from '../../helpers';
|
||||
import { initTestBed } from '../init_test_bed';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
|
||||
type SetupReturn = ReturnType<typeof setupTimelineTestBed>;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
import { act } from 'react-dom/test-utils';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupTimingTestBed, TimingTestBed } from './timing.helpers';
|
||||
import { PhaseWithTiming } from '../../../../common/types';
|
||||
import { PhaseWithTiming } from '../../../common/types';
|
||||
|
||||
describe('<EditPolicy /> timing', () => {
|
||||
let testBed: TimingTestBed;
|
|
@ -6,12 +6,11 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141645
|
||||
describe.skip('<EditPolicy /> cold phase validation', () => {
|
||||
describe('<EditPolicy /> cold phase validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
||||
|
|
@ -6,14 +6,13 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
|
||||
import { PhaseWithDownsample } from '../../../../common/types';
|
||||
import { PhaseWithDownsample } from '../../../common/types';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141160
|
||||
describe.skip('<EditPolicy /> downsample interval validation', () => {
|
||||
describe('<EditPolicy /> downsample interval validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
let actions: ValidationTestBed['actions'];
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
|
@ -9,8 +9,7 @@ import { act } from 'react-dom/test-utils';
|
|||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141645
|
||||
describe.skip('<EditPolicy /> error indicators', () => {
|
||||
describe('<EditPolicy /> error indicators', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
||||
|
|
@ -6,12 +6,11 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141645
|
||||
describe.skip('<EditPolicy /> hot phase validation', () => {
|
||||
describe('<EditPolicy /> hot phase validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
let actions: ValidationTestBed['actions'];
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
|
@ -6,13 +6,12 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { getGeneratedPolicies } from '../constants';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141645
|
||||
describe.skip('<EditPolicy /> policy name validation', () => {
|
||||
describe('<EditPolicy /> policy name validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
let actions: ValidationTestBed['actions'];
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
|
@ -6,14 +6,13 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
|
||||
import { PhaseWithTiming } from '../../../../common/types';
|
||||
import { PhaseWithTiming } from '../../../common/types';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/115307
|
||||
describe.skip('<EditPolicy /> timing validation', () => {
|
||||
describe('<EditPolicy /> timing validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
let actions: ValidationTestBed['actions'];
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
|
@ -6,12 +6,11 @@
|
|||
*/
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { i18nTexts } from '../../../public/application/sections/edit_policy/i18n_texts';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers';
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/141645
|
||||
describe.skip('<EditPolicy /> warm phase validation', () => {
|
||||
describe('<EditPolicy /> warm phase validation', () => {
|
||||
let testBed: ValidationTestBed;
|
||||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment();
|
||||
|
|
@ -5,12 +5,12 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { registerTestBed, TestBedConfig } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { WithAppDependencies } from '../helpers';
|
||||
import { EditPolicy } from '../../../public/application/sections/edit_policy';
|
||||
import { AppServicesContext } from '../../../public/types';
|
||||
import { EditPolicy } from '../../public/application/sections/edit_policy';
|
||||
import { AppServicesContext } from '../../public/types';
|
||||
import { POLICY_NAME } from './constants';
|
||||
|
||||
const getTestBedConfig = (testBedConfig?: Partial<TestBedConfig>): TestBedConfig => {
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { HttpSetup } from '@kbn/core/public';
|
||||
import { AppServicesContext } from '../../../../public/types';
|
||||
import { AppServicesContext } from '../../../public/types';
|
||||
import {
|
||||
createColdPhaseActions,
|
||||
createDeletePhaseActions,
|
|
@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
|
|||
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
|
||||
import { HttpFetchOptionsWithPath } from '@kbn/core/public';
|
||||
import { setupEnvironment } from '../../helpers';
|
||||
import { API_BASE_PATH } from '../../../../common/constants';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import {
|
||||
getDefaultHotPhasePolicy,
|
||||
POLICY_WITH_INCLUDE_EXCLUDE,
|
|
@ -5,9 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAction } from '..';
|
||||
|
||||
const createSetDownsampleIntervalAction =
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
|
||||
const createWaitForValidationAction = (testBed: TestBed) => () => {
|
||||
const { component } = testBed;
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAction } from './form_toggle_action';
|
||||
import { createFormSetValueAction } from './form_set_value_action';
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAction } from './form_toggle_action';
|
||||
import { createFormToggleAndSetValueAction } from './form_toggle_and_set_value_action';
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormSetValueAction } from './form_set_value_action';
|
||||
|
||||
export const createMinAgeActions = (testBed: TestBed, phase: Phase) => {
|
|
@ -8,8 +8,8 @@
|
|||
import { act } from 'react-dom/test-utils';
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { DataTierAllocationType } from '../../../../public/application/sections/edit_policy/types';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { DataTierAllocationType } from '../../../public/application/sections/edit_policy/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormSetValueAction } from './form_set_value_action';
|
||||
|
||||
export const createNodeAllocationActions = (testBed: TestBed, phase: Phase) => {
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAction } from './form_toggle_action';
|
||||
|
||||
export const createReadonlyActions = (testBed: TestBed, phase: Phase) => {
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAndSetValueAction } from './form_toggle_and_set_value_action';
|
||||
|
||||
export const createReplicasAction = (testBed: TestBed, phase: Phase) => {
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormToggleAction } from './form_toggle_action';
|
||||
|
||||
export const createSearchableSnapshotActions = (testBed: TestBed, phase: Phase) => {
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
import { createFormSetValueAction } from './form_set_value_action';
|
||||
|
||||
export const createShrinkActions = (testBed: TestBed, phase: Phase) => {
|
|
@ -8,7 +8,7 @@
|
|||
import { TestBed } from '@kbn/test-jest-helpers';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import { Phase } from '../../../../common/types';
|
||||
import { Phase } from '../../../common/types';
|
||||
|
||||
const toggleDeletePhase = async (testBed: TestBed) => {
|
||||
const { find, component } = testBed;
|
|
@ -6,12 +6,12 @@
|
|||
*/
|
||||
|
||||
import { httpServiceMock } from '@kbn/core/public/mocks';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import { API_BASE_PATH } from '../../common/constants';
|
||||
import {
|
||||
ListNodesRouteResponse,
|
||||
ListSnapshotReposResponse,
|
||||
NodesDetailsResponse,
|
||||
} from '../../../common/types';
|
||||
} from '../../common/types';
|
||||
import { getDefaultHotPhasePolicy } from '../edit_policy/constants';
|
||||
|
||||
type HttpMethod = 'GET' | 'PUT' | 'DELETE' | 'POST';
|
|
@ -19,12 +19,12 @@ import {
|
|||
executionContextServiceMock,
|
||||
} from '@kbn/core/public/mocks';
|
||||
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
|
||||
import { init as initHttp } from '../../../public/application/services/http';
|
||||
import { init as initHttp } from '../../public/application/services/http';
|
||||
import { init as initHttpRequests } from './http_requests';
|
||||
import { init as initUiMetric } from '../../../public/application/services/ui_metric';
|
||||
import { init as initNotification } from '../../../public/application/services/notification';
|
||||
import { KibanaContextProvider } from '../../../public/shared_imports';
|
||||
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';
|
||||
import { init as initUiMetric } from '../../public/application/services/ui_metric';
|
||||
import { init as initNotification } from '../../public/application/services/notification';
|
||||
import { KibanaContextProvider } from '../../public/shared_imports';
|
||||
import { createBreadcrumbsMock } from '../../public/application/services/breadcrumbs.mock';
|
||||
|
||||
const breadcrumbService = createBreadcrumbsMock();
|
||||
const appContextMock = {
|
|
@ -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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_integration',
|
||||
rootDir: '../../..',
|
||||
roots: ['<rootDir>/x-pack/plugins/index_lifecycle_management'],
|
||||
testMatch: ['/**/integration_tests/**/*.test.{js,mjs,ts,tsx}'],
|
||||
coverageDirectory:
|
||||
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/index_lifecycle_management',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/x-pack/plugins/index_lifecycle_management/{common,public,server}/**/*.{ts,tsx}',
|
||||
],
|
||||
};
|
|
@ -8,6 +8,7 @@
|
|||
},
|
||||
"include": [
|
||||
"__jest__/**/*",
|
||||
"integration_tests/**/*",
|
||||
"common/**/*",
|
||||
"public/**/*",
|
||||
"server/**/*",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue