Skip to content

Commit

Permalink
[8.x] [APM] Migrate `/observability_overview` to deployment…
Browse files Browse the repository at this point in the history
… agnostic test (#199817) (#200012)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[APM] Migrate `/observability_overview` to deployment
agnostic test (#199817)](#199817)

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

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

<!--BACKPORT [{"author":{"name":"Sergi
Romeu","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-13T14:21:54Z","message":"[APM]
Migrate `/observability_overview` to deployment agnostic test
(#199817)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/198981\nPart of
https://github.com/elastic/kibana/issues/193245\n\nThis PR contains the
changes to migrate `observability_overview` test\nfolder to
Deployment-agnostic testing strategy.\n\n### How to test\n\n-
Serverless\n\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\n```\n\nIt's recommended to be run
against\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\n\n-
Stateful\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\n```\n\n## Checks\n\n- [x] (OPTIONAL, only if a test has
been unskipped) Run flaky test suite\n- [x] local run for serverless\n-
[x] local run for stateful\n- [x] MKI run for
serverless","sha":"7a61d10eef804f3695071969116bbe64afd864b6","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","apm","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"title":"[APM]
Migrate `/observability_overview` to deployment agnostic
test","number":199817,"url":"https://github.com/elastic/kibana/pull/199817","mergeCommit":{"message":"[APM]
Migrate `/observability_overview` to deployment agnostic test
(#199817)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/198981\nPart of
https://github.com/elastic/kibana/issues/193245\n\nThis PR contains the
changes to migrate `observability_overview` test\nfolder to
Deployment-agnostic testing strategy.\n\n### How to test\n\n-
Serverless\n\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\n```\n\nIt's recommended to be run
against\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\n\n-
Stateful\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\n```\n\n## Checks\n\n- [x] (OPTIONAL, only if a test has
been unskipped) Run flaky test suite\n- [x] local run for serverless\n-
[x] local run for stateful\n- [x] MKI run for
serverless","sha":"7a61d10eef804f3695071969116bbe64afd864b6"}},"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/199817","number":199817,"mergeCommit":{"message":"[APM]
Migrate `/observability_overview` to deployment agnostic test
(#199817)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/198981\nPart of
https://github.com/elastic/kibana/issues/193245\n\nThis PR contains the
changes to migrate `observability_overview` test\nfolder to
Deployment-agnostic testing strategy.\n\n### How to test\n\n-
Serverless\n\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
--grep=\"APM\"\n```\n\nIt's recommended to be run
against\n[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)\n\n-
Stateful\n```\nnode scripts/functional_tests_server --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts\nnode
scripts/functional_test_runner --config
x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
--grep=\"APM\"\n```\n\n## Checks\n\n- [x] (OPTIONAL, only if a test has
been unskipped) Run flaky test suite\n- [x] local run for serverless\n-
[x] local run for stateful\n- [x] MKI run for
serverless","sha":"7a61d10eef804f3695071969116bbe64afd864b6"}}]}]
BACKPORT-->

Co-authored-by: Sergi Romeu <[email protected]>
  • Loading branch information
kibanamachine and rmyz authored Nov 13, 2024
1 parent e710d9e commit 55be3c7
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./correlations'));
loadTestFile(require.resolve('./entities'));
loadTestFile(require.resolve('./cold_start'));
loadTestFile(require.resolve('./observability_overview'));
loadTestFile(require.resolve('./latency'));
loadTestFile(require.resolve('./infrastructure'));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,57 @@

import expect from '@kbn/expect';

import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { ARCHIVER_ROUTES } from '../constants/archiver';

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

registry.when(
'Observability overview when data is not loaded',
{ config: 'basic', archives: [] },
() => {
describe('has data', () => {
describe('when no data is loaded', () => {
it('returns false when there is no data', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(false);
});
}
);
});

describe('when only onboarding data is loaded', () => {
before(async () => {
await esArchiver.load(ARCHIVER_ROUTES.observability_overview);
});

after(async () => {
await esArchiver.unload(ARCHIVER_ROUTES.observability_overview);
});

registry.when(
'Observability overview when only onboarding data is loaded',
{ config: 'basic', archives: ['observability_overview'] },
() => {
it('returns false when there is only onboarding data', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(false);
});
}
);
});

describe('when data is loaded', () => {
before(async () => {
await esArchiver.load(ARCHIVER_ROUTES['8.0.0']);
});
after(async () => {
await esArchiver.unload(ARCHIVER_ROUTES['8.0.0']);
});

registry.when(
'Observability overview when APM data is loaded',
{ config: 'basic', archives: ['apm_8.0.0'] },
() => {
it('returns true when there is at least one document on transaction, error or metrics indices', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(true);
});
}
);
});
});
}
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('observability_overview', () => {
loadTestFile(require.resolve('./has_data.spec.ts'));
loadTestFile(require.resolve('./observability_overview.spec.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import expect from '@kbn/expect';
import { meanBy, sumBy } from 'lodash';
import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type';
import { RollupInterval } from '@kbn/apm-plugin/common/rollup';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { roundNumber } from '../../utils';
import { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import { roundNumber } from '../../../../../../apm_api_integration/utils';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

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 @@ -62,35 +61,30 @@ export default function ApiTest({ getService }: FtrProviderContext) {
};
}

registry.when(
'Observability overview when data is not loaded',
{ config: 'basic', archives: [] },
() => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await apmApiClient.readUser({
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
start: new Date(start).toISOString(),
end: new Date(end).toISOString(),
bucketSize,
intervalString,
},
describe('Observability overview', () => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await apmApiClient.readUser({
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
start: new Date(start).toISOString(),
end: new Date(end).toISOString(),
bucketSize,
intervalString,
},
});
expect(response.status).to.be(200);

expect(response.body.serviceCount).to.be(0);
expect(response.body.transactionPerMinute.timeseries.length).to.be(0);
},
});
expect(response.status).to.be(200);

expect(response.body.serviceCount).to.be(0);
expect(response.body.transactionPerMinute.timeseries.length).to.be(0);
});
}
);
});

// FLAKY: https://github.com/elastic/kibana/issues/177497
registry.when('data is loaded', { config: 'basic', archives: [] }, () => {
describe('Observability overview api ', () => {
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

const GO_PROD_RATE = 50;
const GO_DEV_RATE = 5;
const JAVA_PROD_RATE = 45;
Expand All @@ -106,6 +100,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
.service({ name: 'synth-java', environment: 'production', agentName: 'java' })
.instance('instance-c');

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 @@ -6213,10 +6213,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-error"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -6225,8 +6221,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -11748,10 +11743,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-metric"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -11760,8 +11751,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -16847,10 +16837,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-span"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -16859,8 +16845,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -22037,10 +22022,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-transaction"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -22049,9 +22030,8 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4222,8 +4222,7 @@
"transaction.message.queue.name",
"fields.*"
]
},
"refresh_interval": "1ms"
}
}
}
}
Expand Down

0 comments on commit 55be3c7

Please sign in to comment.