Skip to content

Commit

Permalink
address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Dec 2, 2020
1 parent 5c8476b commit e8bcd96
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
Expand Up @@ -60,6 +60,13 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService'])
});
};

const getPolicy = (policyName: string) => {
return es.sr.policy({
name: policyName,
human: true,
});
};

const deletePolicy = (policyName: string) => es.sr.deletePolicy({ name: policyName });

const cleanupPolicies = () =>
Expand All @@ -77,5 +84,6 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService'])
createPolicy,
deletePolicy,
cleanupPolicies,
getPolicy,
};
};
Expand Up @@ -15,9 +15,13 @@ const REPO_NAME = 'test_repo';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

const { createRepository, createPolicy, deletePolicy, cleanupPolicies } = registerEsHelpers(
getService
);
const {
createRepository,
createPolicy,
deletePolicy,
cleanupPolicies,
getPolicy,
} = registerEsHelpers(getService);

describe('Snapshot Lifecycle Management', function () {
before(async () => {
Expand Down Expand Up @@ -79,6 +83,27 @@ export default function ({ getService }: FtrProviderContext) {
expect(body).to.eql({
acknowledged: true,
});

const policyFromEs = await getPolicy(POLICY_NAME);
expect(policyFromEs[POLICY_NAME]).to.be.ok();
expect(policyFromEs[POLICY_NAME].policy).to.eql({
name: 'my_snapshot',
schedule: '0 30 1 * * ?',
repository: REPO_NAME,
config: {
indices: ['my_index'],
ignore_unavailable: true,
partial: false,
metadata: {
meta: 'my_meta',
},
},
retention: {
expire_after: '1d',
max_count: 10,
min_count: 5,
},
});
});

it('should create a policy with only required fields', async () => {
Expand All @@ -98,6 +123,14 @@ export default function ({ getService }: FtrProviderContext) {
expect(body).to.eql({
acknowledged: true,
});

const policyFromEs = await getPolicy(REQUIRED_FIELDS_POLICY_NAME);
expect(policyFromEs[REQUIRED_FIELDS_POLICY_NAME]).to.be.ok();
expect(policyFromEs[REQUIRED_FIELDS_POLICY_NAME].policy).to.eql({
name: 'my_snapshot',
repository: REPO_NAME,
schedule: '0 30 1 * * ?',
});
});
});

Expand Down Expand Up @@ -151,6 +184,27 @@ export default function ({ getService }: FtrProviderContext) {
expect(body).to.eql({
acknowledged: true,
});

const policyFromEs = await getPolicy(POLICY_NAME);
expect(policyFromEs[POLICY_NAME]).to.be.ok();
expect(policyFromEs[POLICY_NAME].policy).to.eql({
name: 'my_snapshot',
schedule: '0 0 0 ? * 7',
repository: REPO_NAME,
config: {
indices: ['my_index'],
ignore_unavailable: true,
partial: false,
metadata: {
meta: 'my_meta',
},
},
retention: {
expire_after: '1d',
max_count: 10,
min_count: 5,
},
});
});

it('should allow optional fields to be removed', async () => {
Expand All @@ -166,6 +220,14 @@ export default function ({ getService }: FtrProviderContext) {
expect(body).to.eql({
acknowledged: true,
});

const policyFromEs = await getPolicy(POLICY_NAME);
expect(policyFromEs[POLICY_NAME]).to.be.ok();
expect(policyFromEs[POLICY_NAME].policy).to.eql({
name: 'my_snapshot',
schedule: '0 30 1 * * ?',
repository: REPO_NAME,
});
});
});
});
Expand Down

0 comments on commit e8bcd96

Please sign in to comment.