diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/agent.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/agent.spec.ts new file mode 100644 index 0000000000000..8d96b00867e80 --- /dev/null +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/agent.spec.ts @@ -0,0 +1,65 @@ +/* + * 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 archives_metadata from '../../../../../../apm_api_integration/common/fixtures/es_archiver/archives_metadata'; +import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context'; +import { ARCHIVER_ROUTES } from '../constants/archiver'; + +export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) { + const apmApiClient = getService('apmApi'); + const esArchiver = getService('esArchiver'); + + const archiveName = '8.0.0'; + const { start, end } = archives_metadata[archiveName]; + + describe('Agent name', () => { + describe('when data is not loaded', () => { + it('handles the empty state', async () => { + const response = await apmApiClient.readUser({ + endpoint: 'GET /internal/apm/services/{serviceName}/agent', + params: { + path: { serviceName: 'opbeans-node' }, + query: { + start, + end, + }, + }, + }); + + expect(response.status).to.be(200); + expect(response.body).to.eql({}); + }); + }); + + describe('when data is loaded', () => { + before(async () => { + await esArchiver.load(ARCHIVER_ROUTES[archiveName]); + }); + after(async () => { + await esArchiver.unload(ARCHIVER_ROUTES[archiveName]); + }); + + it('returns the agent name', async () => { + const response = await apmApiClient.readUser({ + endpoint: 'GET /internal/apm/services/{serviceName}/agent', + params: { + path: { serviceName: 'opbeans-node' }, + query: { + start, + end, + }, + }, + }); + + expect(response.status).to.be(200); + + expect(response.body).to.eql({ agentName: 'nodejs', runtimeName: 'node' }); + }); + }); + }); +} diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/index.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/index.ts index 2beba223d9dc2..4993ec83c5eca 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/index.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/services/index.ts @@ -13,6 +13,7 @@ export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) loadTestFile(require.resolve('./error_groups/error_groups_main_statistics.spec.ts')); loadTestFile(require.resolve('./service_details/service_details.spec.ts')); loadTestFile(require.resolve('./service_icons/service_icons.spec.ts')); + loadTestFile(require.resolve('./agent.spec.ts')); loadTestFile(require.resolve('./archive_services_detailed_statistics.spec.ts')); loadTestFile(require.resolve('./derived_annotations.spec.ts')); loadTestFile(require.resolve('./get_service_node_metadata.spec.ts')); diff --git a/x-pack/test/apm_api_integration/common/fixtures/es_archiver/archives_metadata.ts b/x-pack/test/apm_api_integration/common/fixtures/es_archiver/archives_metadata.ts index ee5d1b20f2e15..9988657f13897 100644 --- a/x-pack/test/apm_api_integration/common/fixtures/es_archiver/archives_metadata.ts +++ b/x-pack/test/apm_api_integration/common/fixtures/es_archiver/archives_metadata.ts @@ -6,6 +6,10 @@ */ export default { + '8.0.0': { + start: '2020-08-26T11:00:43.849Z', + end: '2020-08-26T12:00:43.849Z', + }, 'apm_8.0.0': { start: '2021-08-03T06:50:15.910Z', end: '2021-08-03T07:20:15.910Z',