Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FTR] Use new ES client instead of legacyEs service #88720

Merged
merged 3 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Public License, v 1.
*/

export default function ({ loadTestFile }) {
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('home apis', () => {
loadTestFile(require.resolve('./sample_data'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

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

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

Expand Down Expand Up @@ -43,7 +44,7 @@ export default function ({ getService }) {
});

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

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

const resp = await es.search({
const { body: resp } = await es.search({
index: 'kibana_sample_data_flights',
});

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

it('should remove elasticsearch index containing sample data', async () => {
const resp = await es.indices.exists({
const { body: resp } = await es.indices.exists({
index: 'kibana_sample_data_flights',
});
expect(resp).to.be(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Public License, v 1.
*/

export default function ({ loadTestFile }) {
import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('apis', () => {
loadTestFile(require.resolve('./core'));
loadTestFile(require.resolve('./general'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Public License, v 1.
*/

export default function ({ loadTestFile }) {
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('KQL', () => {
loadTestFile(require.resolve('./kql_telemetry'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import expect from '@kbn/expect';
import Bluebird from 'bluebird';
import { get } from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const es = getService('legacyEs');
const es = getService('es');

describe('telemetry API', () => {
before(() => esArchiver.load('saved_objects/basic'));
Expand All @@ -31,7 +32,7 @@ export default function ({ getService }) {
index: '.kibana',
q: 'type:kql-telemetry',
})
.then((response) => {
.then(({ body: response }) => {
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
expect(kqlTelemetryDoc.optInCount).to.be(1);
});
Expand All @@ -49,7 +50,7 @@ export default function ({ getService }) {
index: '.kibana',
q: 'type:kql-telemetry',
})
.then((response) => {
.then(({ body: response }) => {
const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry');
expect(kqlTelemetryDoc.optOutCount).to.be(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

const BULK_REQUESTS = [
Expand Down Expand Up @@ -74,11 +75,10 @@ export default function ({ getService }) {
it('should not return raw id when object id is unspecified', async () =>
await supertest
.post(`/api/saved_objects/_bulk_create`)
// eslint-disable-next-line no-unused-vars
.send(BULK_REQUESTS.map(({ id, ...rest }) => rest))
.expect(200)
.then((resp) => {
resp.body.saved_objects.map(({ id }) =>
resp.body.saved_objects.map(({ id }: { id: string }) =>
expect(id).not.match(/visualization|dashboard/)
);
}));
Expand All @@ -88,10 +88,7 @@ export default function ({ getService }) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

it('should return 200 with individual responses', async () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

const BULK_REQUESTS = [
Expand Down Expand Up @@ -98,10 +99,7 @@ export default function ({ getService }) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

it('should return 200 with individual responses', async () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import expect from '@kbn/expect';
import _ from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

describe('bulkUpdate', () => {
Expand Down Expand Up @@ -234,10 +235,7 @@ export default function ({ getService }) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

it('should return generic 404', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

describe('create', () => {
Expand Down Expand Up @@ -58,10 +59,7 @@ export default function ({ getService }) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

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

expect(await es.indices.exists({ index: '.kibana' })).to.be(true);
expect((await es.indices.exists({ index: '.kibana' })).body).to.be(true);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }) {
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

describe('delete', () => {
Expand Down Expand Up @@ -43,10 +44,7 @@ export default function ({ getService }) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

it('returns generic 404 when kibana index is missing', async () =>
Expand Down
7 changes: 2 additions & 5 deletions test/api_integration/apis/saved_objects/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ndjsonToObject(input: string) {
}
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');

describe('export', () => {
Expand Down Expand Up @@ -524,10 +524,7 @@ export default function ({ getService }: FtrProviderContext) {
before(
async () =>
// just in case the kibana server has recreated it
await es.indices.delete({
index: '.kibana',
ignore: [404],
})
await es.indices.delete({ index: '.kibana' }, { ignore: [404] })
);

it('should return empty response', async () => {
Expand Down
Loading