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

Run ILM jest tests as integration tests allowing them to run beyond 5s timeout #141750

Merged
merged 7 commits into from
Sep 28, 2022
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
6 changes: 5 additions & 1 deletion x-pack/plugins/index_lifecycle_management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ this by running:

```bash
yarn es snapshot --license=trial
```
```

## Integration tests

See `./integration_tests/README.md`
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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/
```
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { HttpSetup } from '@kbn/core/public';
import { AppServicesContext } from '../../../../public/types';
import { AppServicesContext } from '../../../public/types';
import {
createColdPhaseActions,
createDeletePhaseActions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading