From 7aef1be90dfa94d6327676e55f47749e95dbe69b Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Fri, 30 Jul 2021 20:45:09 +0300 Subject: [PATCH] migrate integration tests to the new es client (#107130) * migrate integration tests to the new es client * error field does not exist on result Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../apis/metrics_ui/metrics_alerting.ts | 18 +++++++++--------- .../apis/monitoring/common/mappings_exist.js | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts b/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts index 6f9c0f5fc708f0..31d4bd147f5261 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts @@ -12,7 +12,7 @@ import { MetricExpressionParams } from '../../../../plugins/infra/server/lib/ale import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService }: FtrProviderContext) { - const client = getService('legacyEs'); + const client = getService('es'); const index = 'test-index'; const getSearchParams = (aggType: string) => ({ @@ -42,11 +42,11 @@ export default function ({ getService }: FtrProviderContext) { '@timestamp', timeframe ); - const result = await client.search({ + const { body: result } = await client.search({ index, body: searchBody, }); - expect(result.error).to.not.be.ok(); + expect(result.hits).to.be.ok(); expect(result.aggregations).to.be.ok(); }); @@ -63,11 +63,11 @@ export default function ({ getService }: FtrProviderContext) { undefined, '{"bool":{"should":[{"match_phrase":{"agent.hostname":"foo"}}],"minimum_should_match":1}}' ); - const result = await client.search({ + const { body: result } = await client.search({ index, body: searchBody, }); - expect(result.error).to.not.be.ok(); + expect(result.hits).to.be.ok(); expect(result.aggregations).to.be.ok(); }); @@ -85,11 +85,11 @@ export default function ({ getService }: FtrProviderContext) { timeframe, 'agent.id' ); - const result = await client.search({ + const { body: result } = await client.search({ index, body: searchBody, }); - expect(result.error).to.not.be.ok(); + expect(result.hits).to.be.ok(); expect(result.aggregations).to.be.ok(); }); @@ -106,11 +106,11 @@ export default function ({ getService }: FtrProviderContext) { 'agent.id', '{"bool":{"should":[{"match_phrase":{"agent.hostname":"foo"}}],"minimum_should_match":1}}' ); - const result = await client.search({ + const { body: result } = await client.search({ index, body: searchBody, }); - expect(result.error).to.not.be.ok(); + expect(result.hits).to.be.ok(); expect(result.aggregations).to.be.ok(); }); diff --git a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js index 1f1151010cefbc..f193e0dbe091a7 100644 --- a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js +++ b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js @@ -14,7 +14,7 @@ import * as beatsMetrics from '../../../../../plugins/monitoring/server/lib/metr import * as apmMetrics from '../../../../../plugins/monitoring/server/lib/metrics/apm/metrics'; export default function ({ getService }) { - const es = getService('legacyEs'); + const es = getService('es'); const metricSets = [ { @@ -49,7 +49,7 @@ export default function ({ getService }) { let mappings; before('load mappings', async () => { - const template = await es.indices.getTemplate({ name: indexTemplate }); + const { body: template } = await es.indices.getTemplate({ name: indexTemplate }); mappings = get(template, [indexTemplate, 'mappings', 'properties']); });