Skip to content

Commit

Permalink
[8.x] [APM] Migrate inspect API tests to be deployment-agnostic (#199963
Browse files Browse the repository at this point in the history
) (#200179)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[APM] Migrate inspect API tests to be deployment-agnostic
(#199963)](#199963)

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

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

<!--BACKPORT [{"author":{"name":"Irene
Blanco","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-14T13:33:32Z","message":"[APM]
Migrate inspect API tests to be deployment-agnostic (#199963)\n\n### How
to test\r\nCloses
https://github.com/elastic/kibana/issues/198977\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate `inspect` test folder to\r\ndeployment-agnostic
testing strategy.\r\n\r\n### How to test\r\n\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\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\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## Checks\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":"bb68f92ec02ad4f9da2f15c978842685159012e1","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","v8.17.0"],"title":"[APM]
Migrate inspect API tests to be
deployment-agnostic","number":199963,"url":"https://github.com/elastic/kibana/pull/199963","mergeCommit":{"message":"[APM]
Migrate inspect API tests to be deployment-agnostic (#199963)\n\n### How
to test\r\nCloses
https://github.com/elastic/kibana/issues/198977\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate `inspect` test folder to\r\ndeployment-agnostic
testing strategy.\r\n\r\n### How to test\r\n\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\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\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## Checks\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":"bb68f92ec02ad4f9da2f15c978842685159012e1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199963","number":199963,"mergeCommit":{"message":"[APM]
Migrate inspect API tests to be deployment-agnostic (#199963)\n\n### How
to test\r\nCloses
https://github.com/elastic/kibana/issues/198977\r\nPart of
https://github.com/elastic/kibana/issues/193245\r\n\r\nThis PR contains
the changes to migrate `inspect` test folder to\r\ndeployment-agnostic
testing strategy.\r\n\r\n### How to test\r\n\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\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\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## Checks\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":"bb68f92ec02ad4f9da2f15c978842685159012e1"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Irene Blanco <[email protected]>
  • Loading branch information
kibanamachine and iblancof authored Nov 14, 2024
1 parent b990477 commit 469fcba
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 archivesMetadata from '../../../../../../apm_api_integration/common/fixtures/es_archiver/archives_metadata';

export default archivesMetadata;
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./observability_overview'));
loadTestFile(require.resolve('./latency'));
loadTestFile(require.resolve('./infrastructure'));
loadTestFile(require.resolve('./inspect'));
loadTestFile(require.resolve('./service_groups'));
});
}
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('inspect', () => {
loadTestFile(require.resolve('./inspect.spec.ts'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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 expect from '@kbn/expect';

import { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { ARCHIVER_ROUTES } from '../constants/archiver';
import archives_metadata from '../constants/archives_metadata';

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

const archiveName = '8.0.0';
const metadata = archives_metadata['apm_8.0.0'];

describe('Inspect feature', () => {
before(async () => {
await esArchiver.load(ARCHIVER_ROUTES[archiveName]);
});
after(async () => {
await esArchiver.unload(ARCHIVER_ROUTES[archiveName]);
});

describe('when omitting `_inspect` query param', () => {
it('returns response without `_inspect`', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/environments',
params: {
query: {
start: metadata.start,
end: metadata.end,
},
},
});

expect(status).to.be(200);
expect(body._inspect).to.be(undefined);
});
});

describe('when passing `_inspect` as query param', () => {
describe('elasticsearch calls made with end-user auth are returned', () => {
it('for environments', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/environments',
params: {
query: {
start: metadata.start,
end: metadata.end,
_inspect: true,
},
},
});
expect(status).to.be(200);
expect(body._inspect).not.to.be.empty();

// @ts-expect-error
expect(Object.keys(body._inspect[0])).to.eql([
'id',
'json',
'name',
'response',
'startTime',
'stats',
'status',
]);
});
});

describe('elasticsearch calls made with internal user should not leak internal queries', () => {
it('for custom links', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/settings/custom_links',
params: {
query: {
'service.name': 'opbeans-node',
'transaction.type': 'request',
_inspect: true,
},
},
});

expect(status).to.be(200);
expect(body._inspect).to.eql([]);
});
});
});
});
}
64 changes: 0 additions & 64 deletions x-pack/test/apm_api_integration/tests/inspect/inspect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,15 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../common/ftr_provider_context';

import archives_metadata from '../../common/fixtures/es_archiver/archives_metadata';

export default function inspectFlagTests({ getService }: FtrProviderContext) {
const registry = getService('registry');
const apmApiClient = getService('apmApiClient');

const archiveName = 'apm_8.0.0';
const metadata = archives_metadata[archiveName];

registry.when('Inspect feature', { config: 'trial', archives: [archiveName] }, () => {
describe('when omitting `_inspect` query param', () => {
it('returns response without `_inspect`', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/environments',
params: {
query: {
start: metadata.start,
end: metadata.end,
},
},
});

expect(status).to.be(200);
expect(body._inspect).to.be(undefined);
});
});

describe('when passing `_inspect` as query param', () => {
describe('elasticsearch calls made with end-user auth are returned', () => {
it('for environments', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/environments',
params: {
query: {
start: metadata.start,
end: metadata.end,
_inspect: true,
},
},
});
expect(status).to.be(200);
expect(body._inspect).not.to.be.empty();

// @ts-expect-error
expect(Object.keys(body._inspect[0])).to.eql([
'id',
'json',
'name',
'response',
'startTime',
'stats',
'status',
]);
});
});

describe('elasticsearch calls made with internal user should not leak internal queries', () => {
it('for custom links', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/settings/custom_links',
params: {
query: {
'service.name': 'opbeans-node',
'transaction.type': 'request',
_inspect: true,
},
},
});

expect(status).to.be(200);
expect(body._inspect).to.eql([]);
});

it('for agent configs', async () => {
const { status, body } = await apmApiClient.readUser({
endpoint: 'GET /api/apm/settings/agent-configuration 2023-10-31',
Expand Down

0 comments on commit 469fcba

Please sign in to comment.