Skip to content

Commit

Permalink
migrate integration tests to the new es client (#107130)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
mshustov and kibanamachine committed Jul 30, 2021
1 parent 561b898 commit 7aef1be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
({
Expand Down Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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']);
});

Expand Down

0 comments on commit 7aef1be

Please sign in to comment.