Skip to content

Commit

Permalink
[Search profiler] Add serverless api tests (elastic#172157)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba authored Dec 4, 2023
1 parent d541cfc commit 142a34b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { FtrProviderContext } from '../../ftr_provider_context';

const API_BASE_PATH = '/api/searchprofiler';

// Flaky https://github.com/elastic/kibana/issues/97954
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

describe.skip('Profile', () => {
describe('Profile', () => {
it('should return profile results for a valid index', async () => {
const payload = {
index: '_all',
Expand Down Expand Up @@ -46,7 +45,7 @@ export default function ({ getService }: FtrProviderContext) {
};

const { body } = await supertest
.post(`${API_BASE_PATH}/execute`)
.post(`${API_BASE_PATH}/profile`)
.set('kbn-xsrf', 'xxx')
.set('Content-Type', 'application/json;charset=UTF-8')
.send(payloadWithInvalidIndex)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Search profiler APIs', function () {
this.tags(['esGate']);

loadTestFile(require.resolve('./search_profiler'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';

import { FtrProviderContext } from '../../../ftr_provider_context';

const API_BASE_PATH = '/api/searchprofiler';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const svlCommonApi = getService('svlCommonApi');

describe('Profile', () => {
it('should return profile results for a valid index', async () => {
const payload = {
index: '_all',
query: {
query: {
match_all: {},
},
},
};

const { body } = await supertest
.post(`${API_BASE_PATH}/profile`)
.set(svlCommonApi.getInternalRequestHeader())
.set('Content-Type', 'application/json;charset=UTF-8')
.send(payload)
.expect(200);

expect(body.ok).to.eql(true);
});

it('should return error for invalid index', async () => {
const payloadWithInvalidIndex = {
index: 'index_does_not_exist',
query: {
query: {
match_all: {},
},
},
};

const { body } = await supertest
.post(`${API_BASE_PATH}/profile`)
.set(svlCommonApi.getInternalRequestHeader())
.set('Content-Type', 'application/json;charset=UTF-8')
.send(payloadWithInvalidIndex)
.expect(404);

expect(body.error).to.eql('Not Found');
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
require.resolve('../../common/platform_security'),
require.resolve('../../common/scripts_tests'),
require.resolve('../../common/search_oss'),
require.resolve('../../common/search_profiler'),
require.resolve('../../common/search_xpack'),
require.resolve('../../common/core'),
require.resolve('../../common/reporting'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
require.resolve('../../common/platform_security'),
require.resolve('../../common/scripts_tests'),
require.resolve('../../common/search_oss'),
require.resolve('../../common/search_profiler'),
require.resolve('../../common/search_xpack'),
require.resolve('../../common/core'),
require.resolve('../../common/reporting'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
require.resolve('../../common/platform_security'),
require.resolve('../../common/scripts_tests'),
require.resolve('../../common/search_oss'),
require.resolve('../../common/search_profiler'),
require.resolve('../../common/search_xpack'),
require.resolve('../../common/core'),
require.resolve('../../common/reporting'),
Expand Down

0 comments on commit 142a34b

Please sign in to comment.