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

[ObsUX][APM] Migrate error_rate tests to agnostic deployment tests #199672

Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,15 @@
/*
* 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 { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) {
describe('error_rate', () => {
loadTestFile(require.resolve('./service_apis.spec.ts'));
loadTestFile(require.resolve('./service_maps.spec.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@
* 2.0.
*/
import { apm, timerange } from '@kbn/apm-synthtrace-client';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import expect from '@kbn/expect';
import { mean, meanBy, sumBy } from 'lodash';
import { LatencyAggregationType } from '@kbn/apm-plugin/common/latency_aggregation_types';
import { isFiniteNumber } from '@kbn/apm-plugin/common/utils/is_finite_number';
import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type';
import { RollupInterval } from '@kbn/apm-plugin/common/rollup';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ApiTest({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');
const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
const GO_PROD_LIST_RATE = 75;
const GO_PROD_LIST_ERROR_RATE = 25;
const GO_PROD_ID_RATE = 50;
const GO_PROD_ID_ERROR_RATE = 50;

export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) {
const apmApiClient = getService('apmApi');
const synthtrace = getService('synthtrace');

const serviceName = 'synth-go';
const start = new Date('2021-01-01T00:00:00.000Z').getTime();
Expand Down Expand Up @@ -151,13 +156,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
let errorRateMetricValues: Awaited<ReturnType<typeof getErrorRateValues>>;
let errorTransactionValues: Awaited<ReturnType<typeof getErrorRateValues>>;

// FLAKY: https://github.com/elastic/kibana/issues/177321
registry.when('Services APIs', { config: 'basic', archives: [] }, () => {
describe('Services APIs', () => {
describe('when data is loaded ', () => {
const GO_PROD_LIST_RATE = 75;
const GO_PROD_LIST_ERROR_RATE = 25;
const GO_PROD_ID_RATE = 50;
const GO_PROD_ID_ERROR_RATE = 50;
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

before(async () => {
const serviceGoProdInstance = apm
.service({ name: serviceName, environment: 'production', agentName: 'go' })
Expand All @@ -166,6 +168,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const transactionNameProductList = 'GET /api/product/list';
const transactionNameProductId = 'GET /api/product/:id';

apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await apmSynthtraceEsClient.index([
timerange(start, end)
.interval('1m')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
* 2.0.
*/
import { apm, timerange } from '@kbn/apm-synthtrace-client';
import { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import expect from '@kbn/expect';
import { meanBy } from 'lodash';
import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type';
import { RollupInterval } from '@kbn/apm-plugin/common/rollup';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ApiTest({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');
const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
const GO_PROD_LIST_RATE = 75;
const GO_PROD_LIST_ERROR_RATE = 25;
const GO_PROD_ID_RATE = 50;
const GO_PROD_ID_ERROR_RATE = 50;

export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) {
const apmApiClient = getService('apmApi');
const synthtrace = getService('synthtrace');

const serviceName = 'synth-go';
const start = new Date('2021-01-01T00:00:00.000Z').getTime();
Expand Down Expand Up @@ -74,20 +79,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {

let errorRateMetricValues: Awaited<ReturnType<typeof getErrorRateValues>>;
let errorTransactionValues: Awaited<ReturnType<typeof getErrorRateValues>>;
registry.when('Service Maps APIs', { config: 'trial', archives: [] }, () => {

describe('Service Maps APIs', () => {
describe('when data is loaded ', () => {
const GO_PROD_LIST_RATE = 75;
const GO_PROD_LIST_ERROR_RATE = 25;
const GO_PROD_ID_RATE = 50;
const GO_PROD_ID_ERROR_RATE = 50;
before(() => {
let apmSynthtraceEsClient: ApmSynthtraceEsClient;
before(async () => {
const serviceGoProdInstance = apm
.service({ name: serviceName, environment: 'production', agentName: 'go' })
.instance('instance-a');

const transactionNameProductList = 'GET /api/product/list';
const transactionNameProductId = 'GET /api/product/:id';

apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

return apmSynthtraceEsClient.index([
timerange(start, end)
.interval('1m')
Expand Down Expand Up @@ -140,7 +145,6 @@ export default function ApiTest({ getService }: FtrProviderContext) {

after(() => apmSynthtraceEsClient.clean());

// FLAKY: https://github.com/elastic/kibana/issues/172772
describe('compare latency value between service inventory and service maps', () => {
before(async () => {
[errorTransactionValues, errorRateMetricValues] = await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./agent_explorer'));
loadTestFile(require.resolve('./custom_dashboards'));
loadTestFile(require.resolve('./dependencies'));
loadTestFile(require.resolve('./error_rate'));
});
}