Skip to content

Commit

Permalink
[8.x] Migrate /test/apm_api_integration/tests/suggestions to be dep…
Browse files Browse the repository at this point in the history
…loyment agnostic api tests (#200556) (#200678)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Migrate `/test/apm_api_integration/tests/suggestions` to be
deployment agnostic api tests
(#200556)](#200556)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Milosz
Marcinkowski","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-18T17:45:52Z","message":"Migrate
`/test/apm_api_integration/tests/suggestions` to be deployment agnostic
api tests (#200556)\n\ncloses #198992\r\ncloses #198993\r\npart of
https://github.com/elastic/kibana/issues/193245\r\n\r\n### How to
test\r\n\r\n- Serverless\r\n\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\n\r\n- Stateful\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\n\r\n-\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\n###
Checklist\r\n- [x] (OPTIONAL, only if a test has been unskipped) Run
flaky test suite\r\n- [x] serverless\r\n- [x] stateful\r\n- [x]
MKI\r\n\r\n---------\r\n\r\nCo-authored-by: Sergi Romeu
<[email protected]>","sha":"8664415750699bad6624b19ba3acab55fa54b9f9","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"],"number":200556,"url":"https://github.com/elastic/kibana/pull/200556","mergeCommit":{"message":"Migrate
`/test/apm_api_integration/tests/suggestions` to be deployment agnostic
api tests (#200556)\n\ncloses #198992\r\ncloses #198993\r\npart of
https://github.com/elastic/kibana/issues/193245\r\n\r\n### How to
test\r\n\r\n- Serverless\r\n\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\n\r\n- Stateful\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\n\r\n-\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\n###
Checklist\r\n- [x] (OPTIONAL, only if a test has been unskipped) Run
flaky test suite\r\n- [x] serverless\r\n- [x] stateful\r\n- [x]
MKI\r\n\r\n---------\r\n\r\nCo-authored-by: Sergi Romeu
<[email protected]>","sha":"8664415750699bad6624b19ba3acab55fa54b9f9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200556","number":200556,"mergeCommit":{"message":"Migrate
`/test/apm_api_integration/tests/suggestions` to be deployment agnostic
api tests (#200556)\n\ncloses #198992\r\ncloses #198993\r\npart of
https://github.com/elastic/kibana/issues/193245\r\n\r\n### How to
test\r\n\r\n- Serverless\r\n\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\n\r\n- Stateful\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\n\r\n-\r\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\r\n\r\n###
Checklist\r\n- [x] (OPTIONAL, only if a test has been unskipped) Run
flaky test suite\r\n- [x] serverless\r\n- [x] stateful\r\n- [x]
MKI\r\n\r\n---------\r\n\r\nCo-authored-by: Sergi Romeu
<[email protected]>","sha":"8664415750699bad6624b19ba3acab55fa54b9f9"}}]}]
BACKPORT-->
  • Loading branch information
miloszmarcinkowski authored Nov 19, 2024
1 parent 14d8575 commit e4939a8
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./diagnostics'));
loadTestFile(require.resolve('./service_nodes'));
loadTestFile(require.resolve('./span_links'));
loadTestFile(require.resolve('./suggestions'));
loadTestFile(require.resolve('./throughput'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) {
describe('Suggestions', () => {
loadTestFile(require.resolve('./suggestions.spec.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
TRANSACTION_TYPE,
} from '@kbn/apm-plugin/common/es_fields/apm';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { generateData } from './generate_data';

const startNumber = new Date('2021-01-01T00:00:00.000Z').getTime();
Expand All @@ -20,14 +21,16 @@ const endNumber = new Date('2021-01-01T00:05:00.000Z').getTime() - 1;
const start = new Date(startNumber).toISOString();
const end = new Date(endNumber).toISOString();

export default function suggestionsTests({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');
const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
export default function suggestionsTests({ getService }: DeploymentAgnosticFtrProviderContext) {
const apmApiClient = getService('apmApi');
const synthtrace = getService('synthtrace');

describe('suggestions when data is loaded', () => {
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

// FLAKY: https://github.com/elastic/kibana/issues/177538
registry.when('suggestions when data is loaded', { config: 'basic', archives: [] }, async () => {
before(async () => {
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await generateData({
apmSynthtraceEsClient,
start: startNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { apm, timerange } from '@kbn/apm-synthtrace-client';
import expect from '@kbn/expect';
import { meanBy, sumBy } from 'lodash';
import { DependencyNode, ServiceNode } from '@kbn/apm-plugin/common/connections';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { roundNumber } from '../../utils';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { roundNumber } from '../utils/common';

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

const start = new Date('2021-01-01T00:00:00.000Z').getTime();
const end = new Date('2021-01-01T00:15:00.000Z').getTime() - 1;
Expand Down Expand Up @@ -93,18 +93,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {

let throughputValues: Awaited<ReturnType<typeof getThroughputValues>>;

// FLAKY: https://github.com/elastic/kibana/issues/177536
registry.when.skip('Dependencies throughput value', { config: 'basic', archives: [] }, () => {
describe('Dependencies throughput value', () => {
describe('when data is loaded', () => {
const GO_PROD_RATE = 75;
const JAVA_PROD_RATE = 25;
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

before(async () => {
const serviceGoProdInstance = apm
.service({ name: 'synth-go', environment: 'production', agentName: 'go' })
.instance('instance-a');
const serviceJavaInstance = apm
.service({ name: 'synth-java', environment: 'development', agentName: 'java' })
.instance('instance-c');
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await apmSynthtraceEsClient.index([
timerange(start, end)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) {
describe('Throughput', () => {
loadTestFile(require.resolve('./dependencies_apis.spec.ts'));
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 @@ -11,13 +11,13 @@ import { apm, timerange } from '@kbn/apm-synthtrace-client';
import expect from '@kbn/expect';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { meanBy, sumBy } from 'lodash';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { roundNumber } from '../../utils';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { roundNumber } from '../utils/common';

export default function ApiTest({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');
const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
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 @@ -141,18 +141,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {
let throughputMetricValues: Awaited<ReturnType<typeof getThroughputValues>>;
let throughputTransactionValues: Awaited<ReturnType<typeof getThroughputValues>>;

// FLAKY: https://github.com/elastic/kibana/issues/177535
registry.when('Services APIs', { config: 'basic', archives: [] }, () => {
describe('Services APIs', () => {
describe('when data is loaded ', () => {
const GO_PROD_RATE = 80;
const GO_DEV_RATE = 20;
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

before(async () => {
const serviceGoProdInstance = apm
.service({ name: serviceName, environment: 'production', agentName: 'go' })
.instance('instance-a');
const serviceGoDevInstance = apm
.service({ name: serviceName, environment: 'development', agentName: 'go' })
.instance('instance-b');
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await apmSynthtraceEsClient.index([
timerange(start, end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import expect from '@kbn/expect';
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 { roundNumber } from '../../utils';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { roundNumber } from '../utils/common';

export default function ApiTest({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');
const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
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 @@ -83,17 +83,20 @@ export default function ApiTest({ getService }: FtrProviderContext) {
let throughputMetricValues: Awaited<ReturnType<typeof getThroughputValues>>;
let throughputTransactionValues: Awaited<ReturnType<typeof getThroughputValues>>;

registry.when('Service Maps APIs', { config: 'trial', archives: [] }, () => {
describe('Service Maps APIs', () => {
describe('when data is loaded ', () => {
const GO_PROD_RATE = 80;
const GO_DEV_RATE = 20;
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

before(async () => {
const serviceGoProdInstance = apm
.service({ name: serviceName, environment: 'production', agentName: 'go' })
.instance('instance-a');
const serviceGoDevInstance = apm
.service({ name: serviceName, environment: 'development', agentName: 'go' })
.instance('instance-b');
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await apmSynthtraceEsClient.index([
timerange(start, end)
Expand All @@ -119,7 +122,6 @@ export default function ApiTest({ getService }: FtrProviderContext) {

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

// FLAKY: https://github.com/elastic/kibana/issues/176984
describe('compare throughput value between service inventory and service maps', () => {
before(async () => {
[throughputTransactionValues, throughputMetricValues] = await Promise.all([
Expand All @@ -136,7 +138,6 @@ export default function ApiTest({ getService }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/176987
describe('when calling service maps transactions stats api', () => {
let serviceMapsNodeThroughput: number | null | undefined;
before(async () => {
Expand Down

0 comments on commit e4939a8

Please sign in to comment.