Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 27, 2020
1 parent f475d02 commit 28dffcf
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ export const DEFAULT_POLICY: PolicyFromES = {
name: 'my_policy',
};

export const POLICY_WITH_MIGRATE_OFF: PolicyFromES = {
version: 1,
modified_date: Date.now().toString(),
policy: {
name: 'my_policy',
phases: {
hot: {
min_age: '0ms',
actions: {
rollover: {
max_age: '30d',
max_size: '50gb',
},
},
},
warm: {
actions: {
migrate: { enabled: false },
},
},
},
},
name: 'my_policy',
};

export const POLICY_WITH_INCLUDE_EXCLUDE: PolicyFromES = {
version: 1,
modified_date: Date.now().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
NEW_SNAPSHOT_POLICY_NAME,
SNAPSHOT_POLICY_NAME,
DEFAULT_POLICY,
POLICY_WITH_MIGRATE_OFF,
POLICY_WITH_INCLUDE_EXCLUDE,
POLICY_WITH_NODE_ATTR_AND_OFF_ALLOCATION,
POLICY_WITH_NODE_ROLE_ALLOCATION,
Expand Down Expand Up @@ -457,6 +458,33 @@ describe('<EditPolicy />', () => {
});

describe('data allocation', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([POLICY_WITH_MIGRATE_OFF]);
httpRequestsMockHelpers.setListNodes({
nodesByRoles: {},
nodesByAttributes: { test: ['123'] },
isUsingDeprecatedDataRoleConfig: false,
});
httpRequestsMockHelpers.setLoadSnapshotPolicies([]);

await act(async () => {
testBed = await setup();
});

const { component } = testBed;
component.update();
});

test('setting node_attr based allocation, but not selecting node attribute', async () => {
const { actions } = testBed;
await actions.warm.setDataAllocation('node_attrs');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
const warmPhase = JSON.parse(JSON.parse(latestRequest.requestBody).body).phases.warm;

expect(warmPhase.actions.migrate).toEqual({ enabled: false });
});

describe('node roles', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPolicies([POLICY_WITH_NODE_ROLE_ALLOCATION]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const serializeAllocateAction = (
[name]: value,
},
};
} else {
// The form has been configured to use node attribute based allocation but no node attribute
// was selected. We fall back to what was originally selected in this case. This might be
// migrate.enabled: "false"
actions.migrate = originalActions.migrate;
}

// copy over the original include and exclude values until we can set them in the form.
Expand Down

0 comments on commit 28dffcf

Please sign in to comment.