Skip to content

Commit ee5b6d2

Browse files
authored
[7.x] [FTR] Use new ES client instead of legacyEs service (#88720) (#88845)
1 parent 0099504 commit ee5b6d2

File tree

26 files changed

+165
-158
lines changed

26 files changed

+165
-158
lines changed

test/api_integration/apis/home/index.js renamed to test/api_integration/apis/home/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* Public License, v 1.
77
*/
88

9-
export default function ({ loadTestFile }) {
9+
import { FtrProviderContext } from '../../ftr_provider_context';
10+
11+
export default function ({ loadTestFile }: FtrProviderContext) {
1012
describe('home apis', () => {
1113
loadTestFile(require.resolve('./sample_data'));
1214
});

test/api_integration/apis/home/sample_data.js renamed to test/api_integration/apis/home/sample_data.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*/
88

99
import expect from '@kbn/expect';
10+
import { FtrProviderContext } from '../../ftr_provider_context';
1011

11-
export default function ({ getService }) {
12+
export default function ({ getService }: FtrProviderContext) {
1213
const supertest = getService('supertest');
13-
const es = getService('legacyEs');
14+
const es = getService('es');
1415

1516
const MILLISECOND_IN_WEEK = 1000 * 60 * 60 * 24 * 7;
1617

@@ -43,7 +44,7 @@ export default function ({ getService }) {
4344
});
4445

4546
it('should load elasticsearch index containing sample data with dates relative to current time', async () => {
46-
const resp = await es.search({
47+
const { body: resp } = await es.search({
4748
index: 'kibana_sample_data_flights',
4849
});
4950

@@ -61,7 +62,7 @@ export default function ({ getService }) {
6162
.post(`/api/sample_data/flights?now=${nowString}`)
6263
.set('kbn-xsrf', 'kibana');
6364

64-
const resp = await es.search({
65+
const { body: resp } = await es.search({
6566
index: 'kibana_sample_data_flights',
6667
});
6768

@@ -80,7 +81,7 @@ export default function ({ getService }) {
8081
});
8182

8283
it('should remove elasticsearch index containing sample data', async () => {
83-
const resp = await es.indices.exists({
84+
const { body: resp } = await es.indices.exists({
8485
index: 'kibana_sample_data_flights',
8586
});
8687
expect(resp).to.be(false);

test/api_integration/apis/index.js renamed to test/api_integration/apis/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* Public License, v 1.
77
*/
88

9-
export default function ({ loadTestFile }) {
9+
import { FtrProviderContext } from '../ftr_provider_context';
10+
11+
export default function ({ loadTestFile }: FtrProviderContext) {
1012
describe('apis', () => {
1113
loadTestFile(require.resolve('./core'));
1214
loadTestFile(require.resolve('./general'));

test/api_integration/apis/kql_telemetry/index.js renamed to test/api_integration/apis/kql_telemetry/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* Public License, v 1.
77
*/
88

9-
export default function ({ loadTestFile }) {
9+
import { FtrProviderContext } from '../../ftr_provider_context';
10+
11+
export default function ({ loadTestFile }: FtrProviderContext) {
1012
describe('KQL', () => {
1113
loadTestFile(require.resolve('./kql_telemetry'));
1214
});

test/api_integration/apis/kql_telemetry/kql_telemetry.js renamed to test/api_integration/apis/kql_telemetry/kql_telemetry.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
import expect from '@kbn/expect';
1010
import Bluebird from 'bluebird';
1111
import { get } from 'lodash';
12+
import { FtrProviderContext } from '../../ftr_provider_context';
1213

13-
export default function ({ getService }) {
14+
export default function ({ getService }: FtrProviderContext) {
1415
const supertest = getService('supertest');
1516
const esArchiver = getService('esArchiver');
16-
const es = getService('legacyEs');
17+
const es = getService('es');
1718

1819
describe('telemetry API', () => {
1920
before(() => esArchiver.load('saved_objects/basic'));
@@ -31,7 +32,7 @@ export default function ({ getService }) {
3132
index: '.kibana',
3233
q: 'type:kql-telemetry',
3334
})
34-
.then((response) => {
35+
.then(({ body: response }) => {
3536
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
3637
expect(kqlTelemetryDoc.optInCount).to.be(1);
3738
});
@@ -49,7 +50,7 @@ export default function ({ getService }) {
4950
index: '.kibana',
5051
q: 'type:kql-telemetry',
5152
})
52-
.then((response) => {
53+
.then(({ body: response }) => {
5354
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
5455
expect(kqlTelemetryDoc.optOutCount).to.be(1);
5556
});

test/api_integration/apis/saved_objects/bulk_create.js renamed to test/api_integration/apis/saved_objects/bulk_create.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*/
88

99
import expect from '@kbn/expect';
10+
import { FtrProviderContext } from '../../ftr_provider_context';
1011

11-
export default function ({ getService }) {
12+
export default function ({ getService }: FtrProviderContext) {
1213
const supertest = getService('supertest');
13-
const es = getService('legacyEs');
14+
const es = getService('es');
1415
const esArchiver = getService('esArchiver');
1516

1617
const BULK_REQUESTS = [
@@ -74,11 +75,10 @@ export default function ({ getService }) {
7475
it('should not return raw id when object id is unspecified', async () =>
7576
await supertest
7677
.post(`/api/saved_objects/_bulk_create`)
77-
// eslint-disable-next-line no-unused-vars
7878
.send(BULK_REQUESTS.map(({ id, ...rest }) => rest))
7979
.expect(200)
8080
.then((resp) => {
81-
resp.body.saved_objects.map(({ id }) =>
81+
resp.body.saved_objects.map(({ id }: { id: string }) =>
8282
expect(id).not.match(/visualization|dashboard/)
8383
);
8484
}));
@@ -88,10 +88,7 @@ export default function ({ getService }) {
8888
before(
8989
async () =>
9090
// just in case the kibana server has recreated it
91-
await es.indices.delete({
92-
index: '.kibana',
93-
ignore: [404],
94-
})
91+
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
9592
);
9693

9794
it('should return 200 with individual responses', async () =>

test/api_integration/apis/saved_objects/bulk_get.js renamed to test/api_integration/apis/saved_objects/bulk_get.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*/
88

99
import expect from '@kbn/expect';
10+
import { FtrProviderContext } from '../../ftr_provider_context';
1011

11-
export default function ({ getService }) {
12+
export default function ({ getService }: FtrProviderContext) {
1213
const supertest = getService('supertest');
13-
const es = getService('legacyEs');
14+
const es = getService('es');
1415
const esArchiver = getService('esArchiver');
1516

1617
const BULK_REQUESTS = [
@@ -98,10 +99,7 @@ export default function ({ getService }) {
9899
before(
99100
async () =>
100101
// just in case the kibana server has recreated it
101-
await es.indices.delete({
102-
index: '.kibana',
103-
ignore: [404],
104-
})
102+
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
105103
);
106104

107105
it('should return 200 with individual responses', async () =>

test/api_integration/apis/saved_objects/bulk_update.js renamed to test/api_integration/apis/saved_objects/bulk_update.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
import expect from '@kbn/expect';
1010
import _ from 'lodash';
11+
import { FtrProviderContext } from '../../ftr_provider_context';
1112

12-
export default function ({ getService }) {
13+
export default function ({ getService }: FtrProviderContext) {
1314
const supertest = getService('supertest');
14-
const es = getService('legacyEs');
15+
const es = getService('es');
1516
const esArchiver = getService('esArchiver');
1617

1718
describe('bulkUpdate', () => {
@@ -234,10 +235,7 @@ export default function ({ getService }) {
234235
before(
235236
async () =>
236237
// just in case the kibana server has recreated it
237-
await es.indices.delete({
238-
index: '.kibana',
239-
ignore: [404],
240-
})
238+
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
241239
);
242240

243241
it('should return generic 404', async () => {

test/api_integration/apis/saved_objects/create.js renamed to test/api_integration/apis/saved_objects/create.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*/
88

99
import expect from '@kbn/expect';
10+
import { FtrProviderContext } from '../../ftr_provider_context';
1011

11-
export default function ({ getService }) {
12+
export default function ({ getService }: FtrProviderContext) {
1213
const supertest = getService('supertest');
13-
const es = getService('legacyEs');
14+
const es = getService('es');
1415
const esArchiver = getService('esArchiver');
1516

1617
describe('create', () => {
@@ -58,10 +59,7 @@ export default function ({ getService }) {
5859
before(
5960
async () =>
6061
// just in case the kibana server has recreated it
61-
await es.indices.delete({
62-
index: '.kibana',
63-
ignore: [404],
64-
})
62+
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
6563
);
6664

6765
it('should return 200 and create kibana index', async () => {
@@ -99,7 +97,7 @@ export default function ({ getService }) {
9997
expect(resp.body.migrationVersion).to.be.ok();
10098
});
10199

102-
expect(await es.indices.exists({ index: '.kibana' })).to.be(true);
100+
expect((await es.indices.exists({ index: '.kibana' })).body).to.be(true);
103101
});
104102
});
105103
});

test/api_integration/apis/saved_objects/delete.js renamed to test/api_integration/apis/saved_objects/delete.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*/
88

99
import expect from '@kbn/expect';
10+
import { FtrProviderContext } from '../../ftr_provider_context';
1011

11-
export default function ({ getService }) {
12+
export default function ({ getService }: FtrProviderContext) {
1213
const supertest = getService('supertest');
13-
const es = getService('legacyEs');
14+
const es = getService('es');
1415
const esArchiver = getService('esArchiver');
1516

1617
describe('delete', () => {
@@ -43,10 +44,7 @@ export default function ({ getService }) {
4344
before(
4445
async () =>
4546
// just in case the kibana server has recreated it
46-
await es.indices.delete({
47-
index: '.kibana',
48-
ignore: [404],
49-
})
47+
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
5048
);
5149

5250
it('returns generic 404 when kibana index is missing', async () =>

0 commit comments

Comments
 (0)