Revert "[APM] Adding api tests for error group (#116771)"
This reverts commit f2402cef37
.
This commit is contained in:
parent
4bfb35b43a
commit
2a95b16c02
|
@ -4,6 +4,7 @@
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
import { service, timerange } from '@elastic/apm-synthtrace';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import { first, last, sumBy } from 'lodash';
|
import { first, last, sumBy } from 'lodash';
|
||||||
import { isFiniteNumber } from '../../../../plugins/apm/common/utils/is_finite_number';
|
import { isFiniteNumber } from '../../../../plugins/apm/common/utils/is_finite_number';
|
||||||
|
@ -14,7 +15,6 @@ import {
|
||||||
import { RecursivePartial } from '../../../../plugins/apm/typings/common';
|
import { RecursivePartial } from '../../../../plugins/apm/typings/common';
|
||||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
||||||
import { registry } from '../../common/registry';
|
import { registry } from '../../common/registry';
|
||||||
import { config, generateData } from './generate_data';
|
|
||||||
|
|
||||||
type ErrorsDistribution =
|
type ErrorsDistribution =
|
||||||
APIReturnType<'GET /internal/apm/services/{serviceName}/errors/distribution'>;
|
APIReturnType<'GET /internal/apm/services/{serviceName}/errors/distribution'>;
|
||||||
|
@ -65,9 +65,59 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
||||||
{ config: 'basic', archives: ['apm_mappings_only_8.0.0'] },
|
{ config: 'basic', archives: ['apm_mappings_only_8.0.0'] },
|
||||||
() => {
|
() => {
|
||||||
describe('errors distribution', () => {
|
describe('errors distribution', () => {
|
||||||
const { appleTransaction, bananaTransaction } = config;
|
const appleTransaction = {
|
||||||
|
name: 'GET /apple 🍎 ',
|
||||||
|
successRate: 75,
|
||||||
|
failureRate: 25,
|
||||||
|
};
|
||||||
|
const bananaTransaction = {
|
||||||
|
name: 'GET /banana 🍌',
|
||||||
|
successRate: 50,
|
||||||
|
failureRate: 50,
|
||||||
|
};
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await generateData({ serviceName, start, end, synthtraceEsClient });
|
const serviceGoProdInstance = service(serviceName, 'production', 'go').instance(
|
||||||
|
'instance-a'
|
||||||
|
);
|
||||||
|
|
||||||
|
const interval = '1m';
|
||||||
|
|
||||||
|
const indices = [appleTransaction, bananaTransaction]
|
||||||
|
.map((transaction, index) => {
|
||||||
|
return [
|
||||||
|
...timerange(start, end)
|
||||||
|
.interval(interval)
|
||||||
|
.rate(transaction.successRate)
|
||||||
|
.flatMap((timestamp) =>
|
||||||
|
serviceGoProdInstance
|
||||||
|
.transaction(transaction.name)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.duration(1000)
|
||||||
|
.success()
|
||||||
|
.serialize()
|
||||||
|
),
|
||||||
|
...timerange(start, end)
|
||||||
|
.interval(interval)
|
||||||
|
.rate(transaction.failureRate)
|
||||||
|
.flatMap((timestamp) =>
|
||||||
|
serviceGoProdInstance
|
||||||
|
.transaction(transaction.name)
|
||||||
|
.errors(
|
||||||
|
serviceGoProdInstance
|
||||||
|
.error(`Error ${index}`, transaction.name)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
)
|
||||||
|
.duration(1000)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.failure()
|
||||||
|
.serialize()
|
||||||
|
),
|
||||||
|
];
|
||||||
|
})
|
||||||
|
.flatMap((_) => _);
|
||||||
|
|
||||||
|
await synthtraceEsClient.index(indices);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => synthtraceEsClient.clean());
|
after(() => synthtraceEsClient.clean());
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the Elastic License
|
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
||||||
* 2.0.
|
|
||||||
*/
|
|
||||||
import { service, timerange } from '@elastic/apm-synthtrace';
|
|
||||||
import type { SynthtraceEsClient } from '../../common/synthtrace_es_client';
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
appleTransaction: {
|
|
||||||
name: 'GET /apple 🍎 ',
|
|
||||||
successRate: 75,
|
|
||||||
failureRate: 25,
|
|
||||||
},
|
|
||||||
bananaTransaction: {
|
|
||||||
name: 'GET /banana 🍌',
|
|
||||||
successRate: 50,
|
|
||||||
failureRate: 50,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function generateData({
|
|
||||||
synthtraceEsClient,
|
|
||||||
serviceName,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
}: {
|
|
||||||
synthtraceEsClient: SynthtraceEsClient;
|
|
||||||
serviceName: string;
|
|
||||||
start: number;
|
|
||||||
end: number;
|
|
||||||
}) {
|
|
||||||
const serviceGoProdInstance = service(serviceName, 'production', 'go').instance('instance-a');
|
|
||||||
|
|
||||||
const interval = '1m';
|
|
||||||
|
|
||||||
const { bananaTransaction, appleTransaction } = config;
|
|
||||||
|
|
||||||
const documents = [appleTransaction, bananaTransaction]
|
|
||||||
.map((transaction, index) => {
|
|
||||||
return [
|
|
||||||
...timerange(start, end)
|
|
||||||
.interval(interval)
|
|
||||||
.rate(transaction.successRate)
|
|
||||||
.flatMap((timestamp) =>
|
|
||||||
serviceGoProdInstance
|
|
||||||
.transaction(transaction.name)
|
|
||||||
.timestamp(timestamp)
|
|
||||||
.duration(1000)
|
|
||||||
.success()
|
|
||||||
.serialize()
|
|
||||||
),
|
|
||||||
...timerange(start, end)
|
|
||||||
.interval(interval)
|
|
||||||
.rate(transaction.failureRate)
|
|
||||||
.flatMap((timestamp) =>
|
|
||||||
serviceGoProdInstance
|
|
||||||
.transaction(transaction.name)
|
|
||||||
.errors(
|
|
||||||
serviceGoProdInstance.error(`Error ${index}`, transaction.name).timestamp(timestamp)
|
|
||||||
)
|
|
||||||
.duration(1000)
|
|
||||||
.timestamp(timestamp)
|
|
||||||
.failure()
|
|
||||||
.serialize()
|
|
||||||
),
|
|
||||||
];
|
|
||||||
})
|
|
||||||
.flatMap((_) => _);
|
|
||||||
|
|
||||||
await synthtraceEsClient.index(documents);
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the Elastic License
|
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
||||||
* 2.0.
|
|
||||||
*/
|
|
||||||
import expect from '@kbn/expect';
|
|
||||||
import {
|
|
||||||
APIClientRequestParamsOf,
|
|
||||||
APIReturnType,
|
|
||||||
} from '../../../../plugins/apm/public/services/rest/createCallApmApi';
|
|
||||||
import { RecursivePartial } from '../../../../plugins/apm/typings/common';
|
|
||||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
|
||||||
import { registry } from '../../common/registry';
|
|
||||||
import { config, generateData } from './generate_data';
|
|
||||||
|
|
||||||
type ErrorsDistribution =
|
|
||||||
APIReturnType<'GET /internal/apm/services/{serviceName}/errors/{groupId}'>;
|
|
||||||
|
|
||||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
|
||||||
const apmApiClient = getService('apmApiClient');
|
|
||||||
const synthtraceEsClient = getService('synthtraceEsClient');
|
|
||||||
|
|
||||||
const serviceName = 'synth-go';
|
|
||||||
const start = new Date('2021-01-01T00:00:00.000Z').getTime();
|
|
||||||
const end = new Date('2021-01-01T00:15:00.000Z').getTime() - 1;
|
|
||||||
|
|
||||||
async function callApi(
|
|
||||||
overrides?: RecursivePartial<
|
|
||||||
APIClientRequestParamsOf<'GET /internal/apm/services/{serviceName}/errors/{groupId}'>['params']
|
|
||||||
>
|
|
||||||
) {
|
|
||||||
const response = await apmApiClient.readUser({
|
|
||||||
endpoint: 'GET /internal/apm/services/{serviceName}/errors/{groupId}',
|
|
||||||
params: {
|
|
||||||
path: {
|
|
||||||
serviceName,
|
|
||||||
groupId: 'foo',
|
|
||||||
...overrides?.path,
|
|
||||||
},
|
|
||||||
query: {
|
|
||||||
start: new Date(start).toISOString(),
|
|
||||||
end: new Date(end).toISOString(),
|
|
||||||
environment: 'ENVIRONMENT_ALL',
|
|
||||||
kuery: '',
|
|
||||||
...overrides?.query,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
registry.when('when data is not loaded', { config: 'basic', archives: [] }, () => {
|
|
||||||
it('handles the empty state', async () => {
|
|
||||||
const response = await callApi();
|
|
||||||
expect(response.status).to.be(200);
|
|
||||||
expect(response.body.occurrencesCount).to.be(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
registry.when(
|
|
||||||
'when data is loaded',
|
|
||||||
{ config: 'basic', archives: ['apm_mappings_only_8.0.0'] },
|
|
||||||
() => {
|
|
||||||
const { bananaTransaction } = config;
|
|
||||||
describe('error group id', () => {
|
|
||||||
before(async () => {
|
|
||||||
await generateData({ serviceName, start, end, synthtraceEsClient });
|
|
||||||
});
|
|
||||||
|
|
||||||
after(() => synthtraceEsClient.clean());
|
|
||||||
|
|
||||||
describe('return correct data', () => {
|
|
||||||
let errorsDistribution: ErrorsDistribution;
|
|
||||||
before(async () => {
|
|
||||||
const response = await callApi({
|
|
||||||
path: { groupId: '0000000000000000000000000Error 1' },
|
|
||||||
});
|
|
||||||
errorsDistribution = response.body;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('displays correct number of occurrences', () => {
|
|
||||||
const numberOfBuckets = 15;
|
|
||||||
expect(errorsDistribution.occurrencesCount).to.equal(
|
|
||||||
bananaTransaction.failureRate * numberOfBuckets
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -241,10 +241,6 @@ export default function apmApiIntegrationTests(providerContext: FtrProviderConte
|
||||||
loadTestFile(require.resolve('./latency/service_apis'));
|
loadTestFile(require.resolve('./latency/service_apis'));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('errors/group_id', function () {
|
|
||||||
loadTestFile(require.resolve('./errors/group_id'));
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('errors/distribution', function () {
|
describe('errors/distribution', function () {
|
||||||
loadTestFile(require.resolve('./errors/distribution'));
|
loadTestFile(require.resolve('./errors/distribution'));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue