Skip to content

Commit

Permalink
[Upgrade Assistant] Reindexing progress (elastic#114275)
Browse files Browse the repository at this point in the history
* [Upgrade Assistant] Added reindexing progress in % to the reindex flyout and es deprecations table

* [Upgrade Assistant] Renamed first argument in `getReindexProgressLabel` to `reindexTaskPercComplete` for consistency

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
2 people authored and sabarasaba committed Oct 20, 2021
1 parent 6514ad1 commit 8f97cd0
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { act } from 'react-dom/test-utils';
import { setupEnvironment } from '../helpers';
import { ElasticsearchTestBed, setupElasticsearchPage } from './es_deprecations.helpers';
import { esDeprecationsMockResponse, MOCK_SNAPSHOT_ID, MOCK_JOB_ID } from './mocked_responses';
import { ReindexStatus, ReindexStep } from '../../../common/types';

// Note: The reindexing flyout UX is subject to change; more tests should be added here once functionality is built out
describe('Reindex deprecation flyout', () => {
Expand Down Expand Up @@ -93,4 +94,110 @@ describe('Reindex deprecation flyout', () => {

expect(exists('reindexDetails.fetchFailedCallout')).toBe(true);
});

describe('reindexing progress', () => {
it('has not started yet', async () => {
const { actions, find, exists } = testBed;

await actions.table.clickDeprecationRowAt('reindex', 0);
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing process');
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
});

it('has started but not yet reindexing documents', async () => {
httpRequestsMockHelpers.setReindexStatusResponse({
reindexOp: {
status: ReindexStatus.inProgress,
lastCompletedStep: ReindexStep.readonly,
reindexTaskPercComplete: null,
},
warnings: [],
hasRequiredPrivileges: true,
});

await act(async () => {
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
});

testBed.component.update();
const { actions, find, exists } = testBed;

await actions.table.clickDeprecationRowAt('reindex', 0);

expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 5%');
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
});

it('has started reindexing documents', async () => {
httpRequestsMockHelpers.setReindexStatusResponse({
reindexOp: {
status: ReindexStatus.inProgress,
lastCompletedStep: ReindexStep.reindexStarted,
reindexTaskPercComplete: 0.25,
},
warnings: [],
hasRequiredPrivileges: true,
});

await act(async () => {
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
});

testBed.component.update();
const { actions, find, exists } = testBed;

await actions.table.clickDeprecationRowAt('reindex', 0);

expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 31%');
expect(exists('cancelReindexingDocumentsButton')).toBe(true);
});

it('has completed reindexing documents', async () => {
httpRequestsMockHelpers.setReindexStatusResponse({
reindexOp: {
status: ReindexStatus.inProgress,
lastCompletedStep: ReindexStep.reindexCompleted,
reindexTaskPercComplete: 1,
},
warnings: [],
hasRequiredPrivileges: true,
});

await act(async () => {
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
});

testBed.component.update();
const { actions, find, exists } = testBed;

await actions.table.clickDeprecationRowAt('reindex', 0);

expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 95%');
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
});

it('has completed', async () => {
httpRequestsMockHelpers.setReindexStatusResponse({
reindexOp: {
status: ReindexStatus.completed,
lastCompletedStep: ReindexStep.aliasCreated,
reindexTaskPercComplete: 1,
},
warnings: [],
hasRequiredPrivileges: true,
});

await act(async () => {
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
});

testBed.component.update();
const { actions, find, exists } = testBed;

await actions.table.clickDeprecationRowAt('reindex', 0);

expect(find('reindexChecklistTitle').text()).toEqual('Reindexing process');
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
});
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
EuiFlyoutBody,
EuiFlyoutFooter,
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

Expand Down Expand Up @@ -144,14 +143,6 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
</p>
</EuiCallOut>
<EuiSpacer />
<EuiTitle size="xs">
<h3>
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklistTitle"
defaultMessage="Reindexing process"
/>
</h3>
</EuiTitle>
<ReindexProgress reindexState={reindexState} cancelReindex={cancelReindex} />
</EuiFlyoutBody>
<EuiFlyoutFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,69 @@ describe('ReindexProgress', () => {
);

expect(wrapper).toMatchInlineSnapshot(`
<StepProgress
steps={
Array [
Object {
"status": "inProgress",
"title": <FormattedMessage
defaultMessage="Setting old index to read-only"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Creating new index"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Reindexing documents"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Swapping original index with alias"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.aliasSwapStepTitle"
values={Object {}}
/>,
},
]
}
/>
`);
<Fragment>
<EuiTitle
data-test-subj="reindexChecklistTitle"
size="xs"
>
<h3>
<FormattedMessage
defaultMessage="Reindexing in progress… {percents}"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingInProgressTitle"
values={
Object {
"percents": "0%",
}
}
/>
</h3>
</EuiTitle>
<StepProgress
steps={
Array [
Object {
"status": "inProgress",
"title": <FormattedMessage
defaultMessage="Setting old index to read-only"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Creating new index"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle"
values={Object {}}
/>,
},
Object {
"status": "incomplete",
"title": <EuiFlexGroup
alignItems="center"
>
<EuiFlexItem>
<FormattedMessage
defaultMessage="Reindexing documents"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle"
values={Object {}}
/>
</EuiFlexItem>
</EuiFlexGroup>,
},
Object {
"status": "incomplete",
"title": <FormattedMessage
defaultMessage="Swapping original index with alias"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.aliasSwapStepTitle"
values={Object {}}
/>,
},
]
}
/>
</Fragment>
`);
});

it('displays errors in the step that failed', () => {
Expand All @@ -84,30 +108,9 @@ describe('ReindexProgress', () => {
cancelReindex={jest.fn()}
/>
);

const aliasStep = wrapper.props().steps[3];
const aliasStep = (wrapper.find('StepProgress').props() as any).steps[3];
expect(aliasStep.children.props.errorMessage).toEqual(
`This is an error that happened on alias switch`
);
});

it('shows reindexing document progress bar', () => {
const wrapper = shallow(
<ReindexProgress
reindexState={
{
lastCompletedStep: ReindexStep.reindexStarted,
status: ReindexStatus.inProgress,
reindexTaskPercComplete: 0.25,
errorMessage: null,
} as ReindexState
}
cancelReindex={jest.fn()}
/>
);

const reindexStep = wrapper.props().steps[2];
expect(reindexStep.children.type.name).toEqual('ReindexProgressBar');
expect(reindexStep.children.props.reindexState.reindexTaskPercComplete).toEqual(0.25);
});
});
Loading

0 comments on commit 8f97cd0

Please sign in to comment.