Skip to content

Commit 3b09eb1

Browse files
committed
added test for removing shrink field in serialization and re-ordered fields in hot phase advanced
1 parent 1f28720 commit 3b09eb1

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
192192
await createFormSetValueAction(`${phase}-selectedPrimaryShardCount`)(value);
193193
};
194194

195-
const shrinkExists = () => exists('shrinkSwitch');
195+
const shrinkExists = (phase: Phases) => () => exists(`${phase}-shrinkSwitch`);
196196

197197
const setFreeze = createFormToggleAction('freezeSwitch');
198198
const freezeExists = () => exists('freezeSwitch');
@@ -238,6 +238,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
238238
...createForceMergeActions('hot'),
239239
setIndexPriority: setIndexPriority('hot'),
240240
setShrink: setShrink('hot'),
241+
shrinkExists: shrinkExists('hot'),
241242
...createSearchableSnapshotActions('hot'),
242243
},
243244
warm: {
@@ -249,7 +250,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
249250
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'),
250251
setReplicas: setReplicas('warm'),
251252
setShrink: setShrink('warm'),
252-
shrinkExists,
253+
shrinkExists: shrinkExists('warm'),
253254
...createForceMergeActions('warm'),
254255
setIndexPriority: setIndexPriority('warm'),
255256
},

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ export const HotPhase: FunctionComponent = () => {
236236
{isRolloverEnabled && (
237237
<>
238238
{<ForcemergeField phase="hot" />}
239-
{license.canUseSearchableSnapshot() && <SearchableSnapshotField phase="hot" />}
240239
<ShrinkField phase="hot" />
240+
{license.canUseSearchableSnapshot() && <SearchableSnapshotField phase="hot" />}
241241
</>
242242
)}
243243
<SetPriorityInputField phase={hotProperty} />

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/deserializer_and_serializer.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,14 @@ describe('deserializer and serializer', () => {
290290
enabled: false,
291291
});
292292
});
293+
294+
it('removes shrink from hot and warm when unset', () => {
295+
delete formInternal.phases.hot!.actions!.shrink;
296+
delete formInternal.phases.warm!.actions!.shrink;
297+
298+
const result = serializer(formInternal);
299+
300+
expect(result.phases.hot!.actions.shrink).toBeUndefined();
301+
expect(result.phases.warm!.actions.shrink).toBeUndefined();
302+
});
293303
});

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/serializer/serializer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export const createSerializer = (originalPolicy?: SerializedPolicy) => (
6969
delete hotPhaseActions.set_priority;
7070
}
7171

72+
if (!updatedPolicy.phases.hot?.actions?.shrink) {
73+
delete hotPhaseActions.shrink;
74+
}
75+
7276
if (!updatedPolicy.phases.hot!.actions?.searchable_snapshot) {
7377
delete hotPhaseActions.searchable_snapshot;
7478
}

0 commit comments

Comments
 (0)