Skip to content

Commit c77c8ab

Browse files
committed
[Upgrade Assistant] Added reindexing progress in % to the reindex flyout and es deprecations table
1 parent bbaec75 commit c77c8ab

9 files changed

Lines changed: 323 additions & 123 deletions

File tree

x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/reindex_deprecation_flyout.test.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { act } from 'react-dom/test-utils';
1010
import { setupEnvironment } from '../helpers';
1111
import { ElasticsearchTestBed, setupElasticsearchPage } from './es_deprecations.helpers';
1212
import { esDeprecationsMockResponse, MOCK_SNAPSHOT_ID, MOCK_JOB_ID } from './mocked_responses';
13+
import { ReindexStatus, ReindexStep } from '../../../common/types';
1314

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

9495
expect(exists('reindexDetails.fetchFailedCallout')).toBe(true);
9596
});
97+
98+
describe('reindexing progress', () => {
99+
it('has not started yet', async () => {
100+
const { actions, find, exists } = testBed;
101+
102+
await actions.table.clickDeprecationRowAt('reindex', 0);
103+
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing process');
104+
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
105+
});
106+
107+
it('has started but not yet reindexing documents', async () => {
108+
httpRequestsMockHelpers.setReindexStatusResponse({
109+
reindexOp: {
110+
status: ReindexStatus.inProgress,
111+
lastCompletedStep: ReindexStep.readonly,
112+
reindexTaskPercComplete: null,
113+
},
114+
warnings: [],
115+
hasRequiredPrivileges: true,
116+
});
117+
118+
await act(async () => {
119+
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
120+
});
121+
122+
testBed.component.update();
123+
const { actions, find, exists } = testBed;
124+
125+
await actions.table.clickDeprecationRowAt('reindex', 0);
126+
127+
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 5%');
128+
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
129+
});
130+
131+
it('has started reindexing documents', async () => {
132+
httpRequestsMockHelpers.setReindexStatusResponse({
133+
reindexOp: {
134+
status: ReindexStatus.inProgress,
135+
lastCompletedStep: ReindexStep.reindexStarted,
136+
reindexTaskPercComplete: 0.25,
137+
},
138+
warnings: [],
139+
hasRequiredPrivileges: true,
140+
});
141+
142+
await act(async () => {
143+
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
144+
});
145+
146+
testBed.component.update();
147+
const { actions, find, exists } = testBed;
148+
149+
await actions.table.clickDeprecationRowAt('reindex', 0);
150+
151+
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 31%');
152+
expect(exists('cancelReindexingDocumentsButton')).toBe(true);
153+
});
154+
155+
it('has completed reindexing documents', async () => {
156+
httpRequestsMockHelpers.setReindexStatusResponse({
157+
reindexOp: {
158+
status: ReindexStatus.inProgress,
159+
lastCompletedStep: ReindexStep.reindexCompleted,
160+
reindexTaskPercComplete: 1,
161+
},
162+
warnings: [],
163+
hasRequiredPrivileges: true,
164+
});
165+
166+
await act(async () => {
167+
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
168+
});
169+
170+
testBed.component.update();
171+
const { actions, find, exists } = testBed;
172+
173+
await actions.table.clickDeprecationRowAt('reindex', 0);
174+
175+
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing in progress… 95%');
176+
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
177+
});
178+
179+
it('has completed', async () => {
180+
httpRequestsMockHelpers.setReindexStatusResponse({
181+
reindexOp: {
182+
status: ReindexStatus.completed,
183+
lastCompletedStep: ReindexStep.aliasCreated,
184+
reindexTaskPercComplete: 1,
185+
},
186+
warnings: [],
187+
hasRequiredPrivileges: true,
188+
});
189+
190+
await act(async () => {
191+
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
192+
});
193+
194+
testBed.component.update();
195+
const { actions, find, exists } = testBed;
196+
197+
await actions.table.clickDeprecationRowAt('reindex', 0);
198+
199+
expect(find('reindexChecklistTitle').text()).toEqual('Reindexing process');
200+
expect(exists('cancelReindexingDocumentsButton')).toBe(false);
201+
});
202+
});
96203
});

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/__snapshots__/checklist_step.test.tsx.snap

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/checklist_step.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
EuiFlyoutBody,
1717
EuiFlyoutFooter,
1818
EuiSpacer,
19-
EuiTitle,
2019
} from '@elastic/eui';
2120
import { FormattedMessage } from '@kbn/i18n/react';
2221

@@ -144,14 +143,6 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
144143
</p>
145144
</EuiCallOut>
146145
<EuiSpacer />
147-
<EuiTitle size="xs">
148-
<h3>
149-
<FormattedMessage
150-
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklistTitle"
151-
defaultMessage="Reindexing process"
152-
/>
153-
</h3>
154-
</EuiTitle>
155146
<ReindexProgress reindexState={reindexState} cancelReindex={cancelReindex} />
156147
</EuiFlyoutBody>
157148
<EuiFlyoutFooter>

x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/progress.test.tsx

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,69 @@ describe('ReindexProgress', () => {
2929
);
3030

3131
expect(wrapper).toMatchInlineSnapshot(`
32-
<StepProgress
33-
steps={
34-
Array [
35-
Object {
36-
"status": "inProgress",
37-
"title": <FormattedMessage
38-
defaultMessage="Setting old index to read-only"
39-
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
40-
values={Object {}}
41-
/>,
42-
},
43-
Object {
44-
"status": "incomplete",
45-
"title": <FormattedMessage
46-
defaultMessage="Creating new index"
47-
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle"
48-
values={Object {}}
49-
/>,
50-
},
51-
Object {
52-
"status": "incomplete",
53-
"title": <FormattedMessage
54-
defaultMessage="Reindexing documents"
55-
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle"
56-
values={Object {}}
57-
/>,
58-
},
59-
Object {
60-
"status": "incomplete",
61-
"title": <FormattedMessage
62-
defaultMessage="Swapping original index with alias"
63-
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.aliasSwapStepTitle"
64-
values={Object {}}
65-
/>,
66-
},
67-
]
68-
}
69-
/>
70-
`);
32+
<Fragment>
33+
<EuiTitle
34+
data-test-subj="reindexChecklistTitle"
35+
size="xs"
36+
>
37+
<h3>
38+
<FormattedMessage
39+
defaultMessage="Reindexing in progress… {percents}"
40+
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingInProgressTitle"
41+
values={
42+
Object {
43+
"percents": "0%",
44+
}
45+
}
46+
/>
47+
</h3>
48+
</EuiTitle>
49+
<StepProgress
50+
steps={
51+
Array [
52+
Object {
53+
"status": "inProgress",
54+
"title": <FormattedMessage
55+
defaultMessage="Setting old index to read-only"
56+
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.readonlyStepTitle"
57+
values={Object {}}
58+
/>,
59+
},
60+
Object {
61+
"status": "incomplete",
62+
"title": <FormattedMessage
63+
defaultMessage="Creating new index"
64+
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.createIndexStepTitle"
65+
values={Object {}}
66+
/>,
67+
},
68+
Object {
69+
"status": "incomplete",
70+
"title": <EuiFlexGroup
71+
alignItems="center"
72+
>
73+
<EuiFlexItem>
74+
<FormattedMessage
75+
defaultMessage="Reindexing documents"
76+
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.reindexingDocumentsStepTitle"
77+
values={Object {}}
78+
/>
79+
</EuiFlexItem>
80+
</EuiFlexGroup>,
81+
},
82+
Object {
83+
"status": "incomplete",
84+
"title": <FormattedMessage
85+
defaultMessage="Swapping original index with alias"
86+
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.checklistStep.reindexingChecklist.aliasSwapStepTitle"
87+
values={Object {}}
88+
/>,
89+
},
90+
]
91+
}
92+
/>
93+
</Fragment>
94+
`);
7195
});
7296

7397
it('displays errors in the step that failed', () => {
@@ -84,30 +108,9 @@ describe('ReindexProgress', () => {
84108
cancelReindex={jest.fn()}
85109
/>
86110
);
87-
88-
const aliasStep = wrapper.props().steps[3];
111+
const aliasStep = (wrapper.find('StepProgress').props() as any).steps[3];
89112
expect(aliasStep.children.props.errorMessage).toEqual(
90113
`This is an error that happened on alias switch`
91114
);
92115
});
93-
94-
it('shows reindexing document progress bar', () => {
95-
const wrapper = shallow(
96-
<ReindexProgress
97-
reindexState={
98-
{
99-
lastCompletedStep: ReindexStep.reindexStarted,
100-
status: ReindexStatus.inProgress,
101-
reindexTaskPercComplete: 0.25,
102-
errorMessage: null,
103-
} as ReindexState
104-
}
105-
cancelReindex={jest.fn()}
106-
/>
107-
);
108-
109-
const reindexStep = wrapper.props().steps[2];
110-
expect(reindexStep.children.type.name).toEqual('ReindexProgressBar');
111-
expect(reindexStep.children.props.reindexState.reindexTaskPercComplete).toEqual(0.25);
112-
});
113116
});

0 commit comments

Comments
 (0)