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

[ILM] Update the ILM tab on the index details page #170726

Merged
merged 14 commits into from
Nov 15, 2023
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { init as initHttp } from '../public/application/services/http';
import { init as initUiMetric } from '../public/application/services/ui_metric';
import { indexLifecycleTab } from '../public/extend_index_management/components/index_lifecycle_summary';
import { Index } from '@kbn/index-management-plugin/common';
import { findTestSubject } from '@elastic/eui/lib/test';

const { httpSetup } = init();

Expand Down Expand Up @@ -111,6 +112,33 @@ const indexWithLifecycleError: Index = {
type: 'illegal_argument_exception',
reason: 'setting [index.lifecycle.rollover_alias] for index [testy3] is empty or not defined',
},
},
};
const indexWithLifecyclePhaseDefinition: Index = {
health: 'yellow',
status: 'open',
name: 'testy3',
uuid: 'XL11TLa3Tvq298_dMUzLHQ',
primary: 1,
replica: 1,
documents: 2,
documents_deleted: 0,
size: '6.5kb',
primary_size: '6.5kb',
aliases: 'none',
isFrozen: false,
hidden: false,
ilm: {
index: 'testy3',
managed: true,
policy: 'testy',
lifecycle_date_millis: 1544020872361,
phase: 'hot',
phase_time_millis: 1544187775891,
action: 'rollover',
action_time_millis: 1544187775891,
step: 'test',
step_time_millis: 1544187776208,
phase_execution: {
policy: 'testy',
// @ts-expect-error ILM type is incorrect https://github.com/elastic/elasticsearch-specification/issues/2326
Expand All @@ -120,6 +148,39 @@ const indexWithLifecycleError: Index = {
},
},
};
const indexWithLifecycleWaitingStep: Index = {
health: 'yellow',
status: 'open',
name: 'testy3',
uuid: 'XL11TLa3Tvq298_dMUzLHQ',
primary: 1,
replica: 1,
documents: 2,
documents_deleted: 0,
size: '6.5kb',
primary_size: '6.5kb',
aliases: 'none',
isFrozen: false,
hidden: false,
ilm: {
index: 'testy3',
managed: true,
policy: 'testy',
lifecycle_date_millis: 1544020872361,
phase: 'hot',
phase_time_millis: 1544187775891,
action: 'rollover',
action_time_millis: 1544187775891,
step: 'test',
step_time_millis: 1544187776208,
step_info: {
message: 'Waiting for all shard copies to be active',
shards_left_to_allocate: -1,
all_shards_active: false,
number_of_replicas: 2,
},
},
};

moment.tz.setDefault('utc');

Expand Down Expand Up @@ -245,6 +306,11 @@ describe('extend index management', () => {

describe('ilm summary extension', () => {
const IlmComponent = indexLifecycleTab.renderTabContent;
const policyPropertiesPanel = 'policyPropertiesPanel';
const policyStepPanel = 'policyStepPanel';
const policyErrorPanel = 'policyErrorPanel';
const phaseDefinitionPanel = 'phaseDefinitionPanel';

test('should not render the tab when index has no index lifecycle policy', () => {
const shouldRenderTab =
indexLifecycleTab.shouldRenderTab &&
Expand All @@ -254,22 +320,58 @@ describe('extend index management', () => {
expect(shouldRenderTab).toBeFalsy();
});

test('should return extension when index has lifecycle policy', () => {
test('should render the tab when index has lifecycle policy', () => {
const shouldRenderTab =
indexLifecycleTab.shouldRenderTab &&
indexLifecycleTab.shouldRenderTab({
index: indexWithLifecyclePolicy,
});
expect(shouldRenderTab).toBeTruthy();
const ilmContent = (
<IlmComponent index={indexWithLifecyclePolicy} getUrlForApp={getUrlForApp} />
);
expect(ilmContent).toBeDefined();
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});

test('should return extension when index has lifecycle error', () => {
test('should render an error panel when index has lifecycle error', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecycleError} getUrlForApp={getUrlForApp} />
);
expect(ilmContent).toBeDefined();
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeTruthy();
});

test('should render a phase definition panel when lifecycle has phase definition', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecyclePhaseDefinition} getUrlForApp={getUrlForApp} />
);
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});

test('should render a step info panel when lifecycle is waiting for a step completion', () => {
const ilmContent = (
<IlmComponent index={indexWithLifecycleWaitingStep} getUrlForApp={getUrlForApp} />
);
const rendered = mountWithIntl(ilmContent);
expect(rendered.render()).toMatchSnapshot();
expect(findTestSubject(rendered, policyPropertiesPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, phaseDefinitionPanel).exists()).toBeFalsy();
expect(findTestSubject(rendered, policyStepPanel).exists()).toBeTruthy();
expect(findTestSubject(rendered, policyErrorPanel).exists()).toBeFalsy();
});
});

Expand Down
Loading