[Index Patterns] Migrate tests to the new es client (#100760)

This commit is contained in:
Anton Dosov 2021-05-27 15:47:30 +02:00 committed by GitHub
parent 1c4d338668
commit 806566c62e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 20 deletions

View file

@ -7,7 +7,7 @@
*/
import expect from '@kbn/expect';
import { errors as esErrors } from 'elasticsearch';
import { errors as esErrors } from '@elastic/elasticsearch';
import Boom from '@hapi/boom';
import {
@ -20,7 +20,7 @@ import {
import { getIndexNotFoundError, getDocNotFoundError } from './lib';
export default function ({ getService }) {
const es = getService('legacyEs');
const es = getService('es');
const esArchiver = getService('esArchiver');
describe('index_patterns/* error handler', () => {
@ -98,8 +98,8 @@ export default function ({ getService }) {
});
it('wraps other errors in Boom', async () => {
const error = new esErrors.AuthenticationException(
{
const error = new esErrors.ResponseError({
body: {
root_cause: [
{
type: 'security_exception',
@ -109,10 +109,8 @@ export default function ({ getService }) {
type: 'security_exception',
reason: 'action [indices:data/read/field_caps] is unauthorized for user [standard]',
},
{
statusCode: 403,
}
);
statusCode: 403,
});
expect(error).to.not.have.property('isBoom');
const converted = convertEsError(indices, error);

View file

@ -14,7 +14,7 @@ export async function getIndexNotFoundError(es) {
index: 'SHOULD NOT EXIST',
});
} catch (err) {
expect(err).to.have.property('status', 404); // sanity check
expect(err).to.have.property('statusCode', 404); // sanity check
return err;
}
@ -28,7 +28,7 @@ export async function getDocNotFoundError(es) {
id: '1234',
});
} catch (err) {
expect(err).to.have.property('status', 404); // sanity check
expect(err).to.have.property('statusCode', 404); // sanity check
return err;
}

View file

@ -11,7 +11,7 @@ import expect from '@kbn/expect';
export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const es = getService('legacyEs');
const es = getService('es');
const PageObjects = getPageObjects(['settings', 'common', 'header']);
const security = getService('security');

View file

@ -10,7 +10,7 @@ import expect from '@kbn/expect';
export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const es = getService('legacyEs');
const es = getService('es');
const retry = getService('retry');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']);

View file

@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const es = getService('legacyEs');
const es = getService('es');
const retry = getService('retry');
const scriptedFiledName = 'versionConflictScript';
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'header']);
@ -49,7 +49,7 @@ export default function ({ getService, getPageObjects }) {
},
});
log.debug(JSON.stringify(response));
expect(response.result).to.be('updated');
expect(response.body.result).to.be('updated');
await PageObjects.settings.setFieldFormat('url');
await PageObjects.settings.clickSaveScriptedField();
await retry.try(async function () {
@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }) {
},
});
log.debug(JSON.stringify(response));
expect(response.result).to.be('updated');
expect(response.body.result).to.be('updated');
await PageObjects.settings.controlChangeSave();
await retry.try(async function () {
//await PageObjects.common.sleep(2000);

View file

@ -15,7 +15,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'settings']);
const testSubjects = getService('testSubjects');
const globalNav = getService('globalNav');
const es = getService('legacyEs');
const es = getService('es');
describe('index pattern empty view', () => {
before(async () => {
@ -28,7 +28,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
after(async () => {
await esArchiver.loadIfNeeded('makelogs');
// @ts-expect-error
await es.transport.request({
path: '/logstash-a',
method: 'DELETE',
@ -42,14 +41,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
`\n\nNOTE: If this test fails make sure there aren't any non-system indices in the _cat/indices output (use esArchiver.unload on them)`
);
log.debug(
// @ts-expect-error
await es.transport.request({
path: '/_cat/indices',
method: 'GET',
})
);
await testSubjects.existOrFail('createAnyway');
// @ts-expect-error
await es.transport.request({
path: '/logstash-a/_doc',
method: 'POST',

View file

@ -7,7 +7,7 @@
export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const es = getService('legacyEs');
const es = getService('es');
const PageObjects = getPageObjects(['settings', 'common']);
describe('"Create Index Pattern" wizard', function () {