Skip to content

Commit

Permalink
- Fix botched conflict resolution!
Browse files Browse the repository at this point in the history
- Addressed PR feedback, updated data allocation field for readability; added comments and refactored default allocation notice and warning
- Added one more test case for on cloud; when to show the call to migrate to node roles
  • Loading branch information
jloleysens committed Feb 22, 2021
1 parent b4d6ef5 commit b6bfe49
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 960 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,43 +183,20 @@ export const setup = async (arg?: {

const enable = (phase: Phases) => createFormToggleAction(`enablePhaseSwitch-${phase}`);

<<<<<<< HEAD
const setMinAgeValue = (phase: Phases) => createFormSetValueAction(`${phase}-selectedMinimumAge`);

const setMinAgeUnits = (phase: Phases) =>
createFormSetValueAction(`${phase}-selectedMinimumAgeUnits`);

const showDataAllocationOptions = (phase: Phases) => () => {
act(() => {
find(`${phase}-dataTierAllocationControls.dataTierSelect`).simulate('click');
});
component.update();
};

const setDataAllocation = (phase: Phases) => async (value: DataTierAllocationType) => {
showDataAllocationOptions(phase)();
await act(async () => {
switch (value) {
case 'node_roles':
find(`${phase}-dataTierAllocationControls.defaultDataAllocationOption`).simulate('click');
break;
case 'node_attrs':
find(`${phase}-dataTierAllocationControls.customDataAllocationOption`).simulate('click');
break;
default:
find(`${phase}-dataTierAllocationControls.noneDataAllocationOption`).simulate('click');
}
});
component.update();
=======
const createMinAgeActions = (phase: Phases) => {
return {
hasMinAgeInput: () => exists(`${phase}-selectedMinimumAge`),
setMinAgeValue: createFormSetValueAction(`${phase}-selectedMinimumAge`),
setMinAgeUnits: createFormSetValueAction(`${phase}-selectedMinimumAgeUnits`),
hasRolloverTipOnMinAge: () => exists(`${phase}-rolloverMinAgeInputIconTip`),
};
>>>>>>> 556a882a24a32e1be6c8364e5d1251d647ceaec7
};

const setReplicas = (phase: Phases) => async (value: string) => {
Expand Down Expand Up @@ -409,15 +386,8 @@ export const setup = async (arg?: {
},
warm: {
enable: enable('warm'),
<<<<<<< HEAD
setMinAgeValue: setMinAgeValue('warm'),
setMinAgeUnits: setMinAgeUnits('warm'),
showDataAllocationOptions: showDataAllocationOptions('warm'),
setDataAllocation: setDataAllocation('warm'),
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'),
=======
...createMinAgeActions('warm'),
>>>>>>> 556a882a24a32e1be6c8364e5d1251d647ceaec7
setReplicas: setReplicas('warm'),
hasErrorIndicator: () => exists('phaseErrorIndicator-warm'),
...createShrinkActions('warm'),
Expand All @@ -428,15 +398,8 @@ export const setup = async (arg?: {
},
cold: {
enable: enable('cold'),
<<<<<<< HEAD
setMinAgeValue: setMinAgeValue('cold'),
setMinAgeUnits: setMinAgeUnits('cold'),
showDataAllocationOptions: showDataAllocationOptions('cold'),
setDataAllocation: setDataAllocation('cold'),
setSelectedNodeAttribute: setSelectedNodeAttribute('cold'),
=======
...createMinAgeActions('cold'),
>>>>>>> 556a882a24a32e1be6c8364e5d1251d647ceaec7
setReplicas: setReplicas('cold'),
setFreeze,
freezeExists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('<EditPolicy /> node allocation', () => {
expect(actions.warm.hasDefaultAllocationWarning()).toBeTruthy();
});

test('shows default allocation notice when hot tier exists, but not warm tier', async () => {
test('when configuring warm phase shows default allocation notice when hot tier exists, but not warm tier', async () => {
httpRequestsMockHelpers.setListNodes({
nodesByAttributes: {},
nodesByRoles: { data_hot: ['test'], data_cold: ['test'] },
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('<EditPolicy /> node allocation', () => {

describe('on cloud', () => {
describe('with deprecated data role config', () => {
test('should hide data tier option on cloud using legacy node role configuration', async () => {
test('should hide data tier option on cloud', async () => {
httpRequestsMockHelpers.setListNodes({
nodesByAttributes: { test: ['123'] },
// On cloud, if using legacy config there will not be any "data_*" roles set.
Expand All @@ -331,10 +331,29 @@ describe('<EditPolicy /> node allocation', () => {
expect(exists('customDataAllocationOption')).toBeTruthy();
expect(exists('noneDataAllocationOption')).toBeTruthy();
});

test('should ask users to migrate to node roles when on cloud using legacy data role', async () => {
httpRequestsMockHelpers.setListNodes({
nodesByAttributes: { test: ['123'] },
// On cloud, if using legacy config there will not be any "data_*" roles set.
nodesByRoles: { data: ['test'] },
isUsingDeprecatedDataRoleConfig: true,
});
await act(async () => {
testBed = await setup({ appServicesContext: { cloud: { isCloudEnabled: true } } });
});
const { actions, component, exists } = testBed;

component.update();
await actions.warm.enable(true);
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();

expect(exists('cloudDataTierCallout')).toBeTruthy();
});
});

describe('with node role config', () => {
test('shows off, custom and data role options on cloud with data roles', async () => {
test('shows data role, custom and "off" options on cloud with data roles', async () => {
httpRequestsMockHelpers.setListNodes({
nodesByAttributes: { test: ['123'] },
nodesByRoles: { data: ['test'], data_hot: ['test'], data_warm: ['test'] },
Expand Down Expand Up @@ -372,7 +391,7 @@ describe('<EditPolicy /> node allocation', () => {
await actions.cold.enable(true);
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();

expect(exists('cloudDataTierCallout')).toBeTruthy();
expect(exists('cloudMissingColdTierCallout')).toBeTruthy();
// Assert that other notices are not showing
expect(actions.cold.hasDefaultAllocationNotice()).toBeFalsy();
expect(actions.cold.hasNoNodeAttrsWarning()).toBeFalsy();
Expand Down
Loading

0 comments on commit b6bfe49

Please sign in to comment.