forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search profiler] Add serverless api tests (elastic#172157)
- Loading branch information
1 parent
d541cfc
commit 142a34b
Showing
6 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
x-pack/test_serverless/api_integration/test_suites/common/search_profiler/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
}); | ||
} |
59 changes: 59 additions & 0 deletions
59
x-pack/test_serverless/api_integration/test_suites/common/search_profiler/search_profiler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters