kibana/x-pack/test/profiling_api_integration/tests/functions.spec.ts
Cauê Marcondes 98d2766de8
[Profiling-APM] Removing Profiling dependency from APM (#166253)
This PR removes the Profiling dependency from APM, introduced on `8.10`.

- Exposes a new service in profiling-data-access plugin
- Create a new APM API that calls the new service and checks if
Profiling is initialized
- Move Locators from the Profiling plugin to the Observability-shared
plugin
- Move logic to check Profiling status (has_setup/has_data...) from
Profiling server to profiling-data-access plugin
- Create API tests, testing the status services based on different
scenarios:
  - When profiling hasn't been initialized and there's no data
  - When profiling is initialized but has no data
  - When collector integration is not installed
  - When symbolized integration is not installed
  - When APM server integration is not found

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-09-22 09:16:48 +01:00

63 lines
2.2 KiB
TypeScript

/*
* 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 { getRoutePaths } from '@kbn/profiling-plugin/common';
import { TopNFunctions } from '@kbn/profiling-utils';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../common/ftr_provider_context';
import { loadProfilingData, setupProfiling } from '../utils/profiling_data';
import { getBettertest } from '../common/bettertest';
const profilingRoutePaths = getRoutePaths();
export default function featureControlsTests({ getService }: FtrProviderContext) {
const registry = getService('registry');
const profilingApiClient = getService('profilingApiClient');
const log = getService('log');
const supertest = getService('supertest');
const bettertest = getBettertest(supertest);
const es = getService('es');
const start = new Date('2023-03-17T01:00:00.000Z').getTime();
const end = new Date('2023-03-17T01:05:00.000Z').getTime();
registry.when('Functions api', { config: 'cloud' }, () => {
before(async () => {
await setupProfiling(bettertest, log);
await loadProfilingData(es, log);
});
describe('With data', () => {
let functions: TopNFunctions;
before(async () => {
await setupProfiling(bettertest, log);
await loadProfilingData(es, log);
const response = await profilingApiClient.adminUser({
endpoint: `GET ${profilingRoutePaths.TopNFunctions}`,
params: {
query: {
timeFrom: start,
timeTo: end,
kuery: '',
startIndex: 0,
endIndex: 5,
},
},
});
functions = response.body as TopNFunctions;
});
it(`returns correct result`, async () => {
expect(functions.TopN.length).to.equal(5);
expect(functions.TotalCount).to.equal(3599);
expect(functions.selfCPU).to.equal(397);
expect(functions.totalCPU).to.equal(399);
expectSnapshot(functions).toMatch();
});
});
});
}