Skip to content

Commit

Permalink
[8.x] [ObsUX][APM] Migrate APM infra tests to agnostic deployment tes…
Browse files Browse the repository at this point in the history
…ts (elastic#199775) (elastic#199830)

# Backport

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

<!--- 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-12T16:55:15Z","message":"[ObsUX][APM]
Migrate APM infra tests to agnostic deployment tests (elastic#199775)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198976\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate infrastructure 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":"7f2a324e0f3ca65cdbeaef021a948e828dbe60ec","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 APM infra tests to agnostic deployment
tests","number":199775,"url":"https://github.com/elastic/kibana/pull/199775","mergeCommit":{"message":"[ObsUX][APM]
Migrate APM infra tests to agnostic deployment tests (elastic#199775)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198976\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate infrastructure 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":"7f2a324e0f3ca65cdbeaef021a948e828dbe60ec"}},"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/199775","number":199775,"mergeCommit":{"message":"[ObsUX][APM]
Migrate APM infra tests to agnostic deployment tests (elastic#199775)\n\n###
Summary\r\nCloses
https://github.com/elastic/kibana/issues/198976\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate infrastructure 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":"7f2a324e0f3ca65cdbeaef021a948e828dbe60ec"}}]}]
BACKPORT-->

Co-authored-by: Miriam <[email protected]>
  • Loading branch information
kibanamachine and MiriamAparicio authored Nov 12, 2024
1 parent cbb4824 commit f3393e9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./correlations'));
loadTestFile(require.resolve('./entities'));
loadTestFile(require.resolve('./cold_start'));
loadTestFile(require.resolve('./infrastructure'));
});
}
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 { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) {
describe('infrastructure', () => {
loadTestFile(require.resolve('./infrastructure_attributes.spec.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import { generateData } from './generate_data';
import { 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 All @@ -34,28 +34,26 @@ export default function ApiTest({ getService }: FtrProviderContext) {
return response;
}

registry.when(
'Infrastructure attributes when data is not loaded',
{ config: 'basic', archives: [] },
() => {
describe('Infrastructure attributes', () => {
describe('Infrastructure attributes when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await callApi('synth-go');
expect(response.status).to.be(200);
expect(response.body.containerIds.length).to.be(0);
expect(response.body.hostNames.length).to.be(0);
expect(response.body.podNames.length).to.be(0);
});
}
);
});

// FLAKY: https://github.com/elastic/kibana/issues/177386
registry.when('Infrastructure attributes', { config: 'basic', archives: [] }, () => {
describe('when data is loaded', () => {
beforeEach(async () => {
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

before(async () => {
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();
await generateData({ start, end, apmSynthtraceEsClient });
});

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

describe('when service runs in container', () => {
it('returns arrays of container ids and pod names', async () => {
Expand Down

0 comments on commit f3393e9

Please sign in to comment.