Skip to content

Commit

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

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ObsUX][APM] Migrate error_rate tests to agnostic deployment tests
(#199672)](#199672)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Miriam","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-12T12:49:51Z","message":"[ObsUX][APM]
Migrate error_rate tests to agnostic deployment tests (#199672)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198970\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate error_rate test folder to\r\nDeployment-agnostic
testing strategy.\r\n\r\n#### How to test\r\nServerless\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\r\n```\r\nIt's recommended to be run
against\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\nStateful\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\r\n```\r\nChecks\r\n\r\n- [ ] (OPTIONAL, only if a test
has been unskipped) Run flaky test suite\r\n- [x] local run for
serverless\r\n- [x] local run for stateful\r\n- [x] MKI run for
serverless","sha":"c4e97c6b65868c76c5ce4c0f43ab01a44bb0c599","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:obs-ux-infra_services"],"title":"[ObsUX][APM]
Migrate error_rate tests to agnostic deployment
tests","number":199672,"url":"https://github.com/elastic/kibana/pull/199672","mergeCommit":{"message":"[ObsUX][APM]
Migrate error_rate tests to agnostic deployment tests (#199672)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198970\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate error_rate test folder to\r\nDeployment-agnostic
testing strategy.\r\n\r\n#### How to test\r\nServerless\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\r\n```\r\nIt's recommended to be run
against\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\nStateful\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\r\n```\r\nChecks\r\n\r\n- [ ] (OPTIONAL, only if a test
has been unskipped) Run flaky test suite\r\n- [x] local run for
serverless\r\n- [x] local run for stateful\r\n- [x] MKI run for
serverless","sha":"c4e97c6b65868c76c5ce4c0f43ab01a44bb0c599"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199672","number":199672,"mergeCommit":{"message":"[ObsUX][APM]
Migrate error_rate tests to agnostic deployment tests (#199672)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198970\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate error_rate test folder to\r\nDeployment-agnostic
testing strategy.\r\n\r\n#### How to test\r\nServerless\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\r\n```\r\nIt's recommended to be run
against\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\nStateful\r\n```\r\nnode
scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\r\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\r\n```\r\nChecks\r\n\r\n- [ ] (OPTIONAL, only if a test
has been unskipped) Run flaky test suite\r\n- [x] local run for
serverless\r\n- [x] local run for stateful\r\n- [x] MKI run for
serverless","sha":"c4e97c6b65868c76c5ce4c0f43ab01a44bb0c599"}}]}]
BACKPORT-->

Co-authored-by: Miriam <[email protected]>
  • Loading branch information
kibanamachine and MiriamAparicio authored Nov 12, 2024
1 parent f3393e9 commit 09bd5da
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 @@ -14,6 +14,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./agent_explorer'));
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 09bd5da

Please sign in to comment.