Skip to content

Commit

Permalink
Adjust and reenable tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed Feb 3, 2021
1 parent 535450c commit 1138547
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion x-pack/test/fleet_api_integration/apis/epm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function loadTests({ loadTestFile }) {
loadTestFile(require.resolve('./setup'));
loadTestFile(require.resolve('./get'));
loadTestFile(require.resolve('./file'));
//loadTestFile(require.resolve('./template'));
loadTestFile(require.resolve('./template'));
loadTestFile(require.resolve('./ilm'));
loadTestFile(require.resolve('./install_by_upload'));
loadTestFile(require.resolve('./install_overrides'));
Expand Down
17 changes: 12 additions & 5 deletions x-pack/test/fleet_api_integration/apis/epm/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { FtrProviderContext } from '../../../api_integration/ftr_provider_contex
import { getTemplate } from '../../../../plugins/fleet/server/services/epm/elasticsearch/template/template';

export default function ({ getService }: FtrProviderContext) {
const indexPattern = 'foo';
const templateName = 'bar';
const indexPatternName = 'bar-*';
const es = getService('es');
const mappings = {
properties: {
Expand All @@ -25,6 +25,7 @@ export default function ({ getService }: FtrProviderContext) {
const template = getTemplate({
type: 'logs',
templateName,
indexPatternName,
mappings,
packageName: 'system',
composedOfTemplates: [],
Expand All @@ -33,18 +34,24 @@ export default function ({ getService }: FtrProviderContext) {
// This test is not an API integration test with Kibana
// We want to test here if the template is valid and for this we need a running ES instance.
// If the ES instance takes the template, we assume it is a valid template.
const { body: response1 } = await es.indices.putTemplate({
name: templateName,
const { body: response1 } = await es.transport.request({
method: 'PUT',
path: `/_index_template/${templateName}`,
body: template,
});

// Checks if template loading worked as expected
expect(response1).to.eql({ acknowledged: true });

const { body: response2 } = await es.indices.getTemplate({ name: templateName });
const { body: response2 } = await es.transport.request({
method: 'GET',
path: `/_index_template/${templateName}`,
});

// Checks if the content of the template that was loaded is as expected
// We already know based on the above test that the template was valid
// but we check here also if we wrote the index pattern inside the template as expected
expect(response2[templateName].index_patterns).to.eql([`${indexPattern}-*`]);
expect(response2.index_templates[0].index_template.index_patterns).to.eql([indexPatternName]);
});
});
}

0 comments on commit 1138547

Please sign in to comment.