Skip to content

Commit

Permalink
Revert "Fix API integration tests by removing tests for deleted rollu…
Browse files Browse the repository at this point in the history
…p search endpoint."

This reverts commit 9e190e6.
  • Loading branch information
cjcenizal committed Apr 24, 2020
1 parent 93d013f commit 4b3295c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default function({ loadTestFile }) {
describe('rollup', () => {
loadTestFile(require.resolve('./rollup'));
loadTestFile(require.resolve('./index_patterns_extensions'));
loadTestFile(require.resolve('./rollup_search'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';

import { registerHelpers } from './rollup.test_helpers';
import { API_BASE_PATH } from './constants';
import { getRandomString } from './lib';

export default function({ getService }) {
const supertest = getService('supertest');
const es = getService('legacyEs');

const { createIndexWithMappings, getJobPayload, createJob, cleanUp } = registerHelpers({
supertest,
es,
});

describe('search', () => {
const URI = `${API_BASE_PATH}/search`;

it('return a 404 if the rollup index does not exist', async () => {
const { body } = await supertest
.post(URI)
.set('kbn-xsrf', 'xxx')
.send([{ index: 'unknown', query: {} }])
.expect(404);

expect(body.message).to.contain('no such index [unknown]');
});

it('should return a 200 when searching on existing rollup index', async () => {
// Create a Rollup job on an index with the INDEX_TO_ROLLUP_MAPPINGS
const indexName = await createIndexWithMappings();
const rollupIndex = getRandomString();
await createJob(getJobPayload(indexName, undefined, rollupIndex));

const { body } = await supertest
.post(URI)
.set('kbn-xsrf', 'xxx')
.send([{ index: rollupIndex, query: { size: 0 } }])
.expect(200);

// make sure total hits is an integer and not an object
expect(body[0].hits.total).to.equal(0);

await cleanUp();
});
});
}

0 comments on commit 4b3295c

Please sign in to comment.