mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Search] Session server side functional tests (#86152)
* OSS search functional tests * x-pack tests * Session tests * Update search.ts * Update session.ts * Update test/api_integration/apis/search/search.ts Co-authored-by: Lukas Olson <olson.lukas@gmail.com> * reportServerError * Improve response error codes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
This commit is contained in:
parent
084d43320e
commit
3eaf86b944
16 changed files with 656 additions and 121 deletions
|
@ -22,5 +22,6 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('search', () => {
|
||||
loadTestFile(require.resolve('./search'));
|
||||
loadTestFile(require.resolve('./msearch'));
|
||||
});
|
||||
}
|
||||
|
|
88
test/api_integration/apis/search/msearch.ts
Normal file
88
test/api_integration/apis/search/msearch.ts
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('msearch', () => {
|
||||
describe('post', () => {
|
||||
it('should return 200 when correctly formatted searches are provided', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
searches: [
|
||||
{
|
||||
header: { index: 'foo' },
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
.expect(200));
|
||||
|
||||
it('should return 400 if you provide malformed content', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
foo: false,
|
||||
})
|
||||
.expect(400));
|
||||
|
||||
it('should require you to provide an index for each request', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
searches: [
|
||||
{ header: { index: 'foo' }, body: {} },
|
||||
{ header: {}, body: {} },
|
||||
],
|
||||
})
|
||||
.expect(400));
|
||||
|
||||
it('should not require optional params', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo' }, body: {} }],
|
||||
})
|
||||
.expect(200));
|
||||
|
||||
it('should allow passing preference as a string', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo', preference: '_custom' }, body: {} }],
|
||||
})
|
||||
.expect(200));
|
||||
|
||||
it('should allow passing preference as a number', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo', preference: 123 }, body: {} }],
|
||||
})
|
||||
.expect(200));
|
||||
});
|
||||
});
|
||||
}
|
|
@ -17,72 +17,101 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('msearch', () => {
|
||||
describe('search', () => {
|
||||
describe('post', () => {
|
||||
it('should return 200 when correctly formatted searches are provided', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
it('should return 200 when correctly formatted searches are provided', async () => {
|
||||
const resp = await supertest
|
||||
.post(`/internal/search/es`)
|
||||
.send({
|
||||
searches: [
|
||||
{
|
||||
header: { index: 'foo' },
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
params: {
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.expect(200));
|
||||
.expect(200);
|
||||
|
||||
it('should return 400 if you provide malformed content', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.send({
|
||||
foo: false,
|
||||
})
|
||||
.expect(400));
|
||||
expect(resp.body.isPartial).to.be(false);
|
||||
expect(resp.body.isRunning).to.be(false);
|
||||
expect(resp.body).to.have.property('rawResponse');
|
||||
});
|
||||
|
||||
it('should require you to provide an index for each request', async () =>
|
||||
it('should return 404 when if no strategy is provided', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.post(`/internal/search`)
|
||||
.send({
|
||||
searches: [
|
||||
{ header: { index: 'foo' }, body: {} },
|
||||
{ header: {}, body: {} },
|
||||
],
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect(400));
|
||||
.expect(404));
|
||||
|
||||
it('should not require optional params', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
it('should return 404 when if unknown strategy is provided', async () => {
|
||||
const resp = await supertest
|
||||
.post(`/internal/search/banana`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo' }, body: {} }],
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect(200));
|
||||
.expect(404);
|
||||
expect(resp.body.message).to.contain('banana not found');
|
||||
});
|
||||
|
||||
it('should allow passing preference as a string', async () =>
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
it('should return 400 when index type is provided in OSS', async () => {
|
||||
const resp = await supertest
|
||||
.post(`/internal/search/es`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo', preference: '_custom' }, body: {} }],
|
||||
indexType: 'baad',
|
||||
params: {
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect(200));
|
||||
.expect(400);
|
||||
|
||||
it('should allow passing preference as a number', async () =>
|
||||
expect(resp.body.message).to.contain('Unsupported index pattern');
|
||||
});
|
||||
|
||||
it('should return 400 with a bad body', async () => {
|
||||
await supertest
|
||||
.post(`/internal/_msearch`)
|
||||
.post(`/internal/search/es`)
|
||||
.send({
|
||||
searches: [{ header: { index: 'foo', preference: 123 }, body: {} }],
|
||||
params: {
|
||||
body: {
|
||||
index: 'nope nope',
|
||||
bad_query: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect(200));
|
||||
.expect(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
it('should return 404 when no search id provided', async () => {
|
||||
await supertest.delete(`/internal/search/es`).send().expect(404);
|
||||
});
|
||||
|
||||
it('should return 400 when trying a delete on a non supporting strategy', async () => {
|
||||
const resp = await supertest.delete(`/internal/search/es/123`).send().expect(400);
|
||||
expect(resp.body.message).to.contain("Search strategy es doesn't support cancellations");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue