Skip to content

Commit

Permalink
added test for removing shrink field in serialization and re-ordered …
Browse files Browse the repository at this point in the history
…fields in hot phase advanced
  • Loading branch information
jloleysens committed Dec 9, 2020
1 parent 1f28720 commit 3b09eb1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
await createFormSetValueAction(`${phase}-selectedPrimaryShardCount`)(value);
};

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

const setFreeze = createFormToggleAction('freezeSwitch');
const freezeExists = () => exists('freezeSwitch');
Expand Down Expand Up @@ -238,6 +238,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
...createForceMergeActions('hot'),
setIndexPriority: setIndexPriority('hot'),
setShrink: setShrink('hot'),
shrinkExists: shrinkExists('hot'),
...createSearchableSnapshotActions('hot'),
},
warm: {
Expand All @@ -249,7 +250,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'),
setReplicas: setReplicas('warm'),
setShrink: setShrink('warm'),
shrinkExists,
shrinkExists: shrinkExists('warm'),
...createForceMergeActions('warm'),
setIndexPriority: setIndexPriority('warm'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ export const HotPhase: FunctionComponent = () => {
{isRolloverEnabled && (
<>
{<ForcemergeField phase="hot" />}
{license.canUseSearchableSnapshot() && <SearchableSnapshotField phase="hot" />}
<ShrinkField phase="hot" />
{license.canUseSearchableSnapshot() && <SearchableSnapshotField phase="hot" />}
</>
)}
<SetPriorityInputField phase={hotProperty} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,14 @@ describe('deserializer and serializer', () => {
enabled: false,
});
});

it('removes shrink from hot and warm when unset', () => {
delete formInternal.phases.hot!.actions!.shrink;
delete formInternal.phases.warm!.actions!.shrink;

const result = serializer(formInternal);

expect(result.phases.hot!.actions.shrink).toBeUndefined();
expect(result.phases.warm!.actions.shrink).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export const createSerializer = (originalPolicy?: SerializedPolicy) => (
delete hotPhaseActions.set_priority;
}

if (!updatedPolicy.phases.hot?.actions?.shrink) {
delete hotPhaseActions.shrink;
}

if (!updatedPolicy.phases.hot!.actions?.searchable_snapshot) {
delete hotPhaseActions.searchable_snapshot;
}
Expand Down

0 comments on commit 3b09eb1

Please sign in to comment.