Skip to content

Commit

Permalink
[ObsUX][APM] Migrate error_rate tests to agnostic deployment tests (#…
Browse files Browse the repository at this point in the history
…199672)

### Summary
Closes #198970
Part of #193245

This PR contains the changes to migrate error_rate test folder to
Deployment-agnostic testing strategy.

#### How to test
Serverless
```
node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts --grep="APM"
```
It's recommended to be run against
[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)

Stateful
```
node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts --grep="APM"
```
Checks

- [ ] (OPTIONAL, only if a test has been unskipped) Run flaky test suite
- [x]  local run for serverless
- [x]  local run for stateful
- [x]  MKI run for serverless
  • Loading branch information
MiriamAparicio authored Nov 12, 2024
1 parent 627692c commit c4e97c6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
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 @@ -16,6 +16,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./mobile'));
loadTestFile(require.resolve('./custom_dashboards'));
loadTestFile(require.resolve('./dependencies'));
loadTestFile(require.resolve('./error_rate'));
loadTestFile(require.resolve('./data_view'));
loadTestFile(require.resolve('./correlations'));
loadTestFile(require.resolve('./entities'));
Expand Down

0 comments on commit c4e97c6

Please sign in to comment.