Skip to content

Commit 0b718b5

Browse files
Merge branch 'master' into alerts/index-threshold-non-array-index-param
2 parents 080063a + 342f9fb commit 0b718b5

File tree

6 files changed

+84
-12
lines changed

6 files changed

+84
-12
lines changed

x-pack/plugins/searchprofiler/server/routes/profile.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export const register = ({ router, getLicenseStatus, log }: RouteDependencies) =
2727
});
2828
}
2929

30-
const {
31-
core: { elasticsearch },
32-
} = ctx;
33-
3430
const {
3531
body: { query, index },
3632
} = request;
@@ -46,21 +42,25 @@ export const register = ({ router, getLicenseStatus, log }: RouteDependencies) =
4642
body: JSON.stringify(parsed, null, 2),
4743
};
4844
try {
49-
const resp = await elasticsearch.legacy.client.callAsCurrentUser('search', body);
45+
const client = ctx.core.elasticsearch.client.asCurrentUser;
46+
const resp = await client.search(body);
47+
5048
return response.ok({
5149
body: {
5250
ok: true,
53-
resp,
51+
resp: resp.body,
5452
},
5553
});
5654
} catch (err) {
5755
log.error(err);
56+
const { statusCode, body: errorBody } = err;
57+
5858
return response.customError({
59-
statusCode: err.status || 500,
60-
body: err.body
59+
statusCode: statusCode || 500,
60+
body: errorBody
6161
? {
62-
message: err.message,
63-
attributes: err.body,
62+
message: errorBody.error?.reason,
63+
attributes: errorBody,
6464
}
6565
: err,
6666
});

x-pack/test/api_integration/apis/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
3333
loadTestFile(require.resolve('./transform'));
3434
loadTestFile(require.resolve('./lists'));
3535
loadTestFile(require.resolve('./upgrade_assistant'));
36+
loadTestFile(require.resolve('./searchprofiler'));
3637
});
3738
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { FtrProviderContext } from '../../ftr_provider_context';
8+
9+
export default function ({ loadTestFile }: FtrProviderContext) {
10+
describe('Search Profiler', () => {
11+
loadTestFile(require.resolve('./searchprofiler'));
12+
});
13+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import expect from '@kbn/expect';
8+
import { FtrProviderContext } from '../../ftr_provider_context';
9+
10+
const API_BASE_PATH = '/api/searchprofiler';
11+
12+
export default function ({ getService }: FtrProviderContext) {
13+
const supertest = getService('supertest');
14+
15+
describe('Profile', () => {
16+
it('should return profile results for a valid index', async () => {
17+
const payload = {
18+
index: '_all',
19+
query: {
20+
query: {
21+
match_all: {},
22+
},
23+
},
24+
};
25+
26+
const { body } = await supertest
27+
.post(`${API_BASE_PATH}/profile`)
28+
.set('kbn-xsrf', 'xxx')
29+
.set('Content-Type', 'application/json;charset=UTF-8')
30+
.send(payload)
31+
.expect(200);
32+
33+
expect(body.ok).to.eql(true);
34+
});
35+
36+
it('should return error for invalid index', async () => {
37+
const payloadWithInvalidIndex = {
38+
index: 'index_does_not_exist',
39+
query: {
40+
query: {
41+
match_all: {},
42+
},
43+
},
44+
};
45+
46+
const { body } = await supertest
47+
.post(`${API_BASE_PATH}/execute`)
48+
.set('kbn-xsrf', 'xxx')
49+
.set('Content-Type', 'application/json;charset=UTF-8')
50+
.send(payloadWithInvalidIndex)
51+
.expect(404);
52+
53+
expect(body.error).to.eql('Not Found');
54+
});
55+
});
56+
}

x-pack/test/functional/apps/cross_cluster_replication/feature_controls/ccr_security.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
1313
const appsMenu = getService('appsMenu');
1414
const managementMenu = getService('managementMenu');
1515

16-
describe('security', () => {
16+
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/89180
17+
describe.skip('security', () => {
1718
before(async () => {
1819
await esArchiver.load('empty_kibana');
1920
await PageObjects.common.navigateToApp('home');

x-pack/test/functional/apps/remote_clusters/feature_controls/remote_clusters_security.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
1313
const appsMenu = getService('appsMenu');
1414
const managementMenu = getService('managementMenu');
1515

16-
describe('security', () => {
16+
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/89181
17+
describe.skip('security', () => {
1718
before(async () => {
1819
await esArchiver.load('empty_kibana');
1920
await PageObjects.common.navigateToApp('home');

0 commit comments

Comments
 (0)