kibana/x-pack/test/profiling_api_integration/utils/fleet.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

38 lines
1.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 { PackagePolicy } from '@kbn/fleet-plugin/common';
import {
COLLECTOR_PACKAGE_POLICY_NAME,
SYMBOLIZER_PACKAGE_POLICY_NAME,
} from '@kbn/profiling-data-access-plugin/common';
import { BetterTest } from '../common/bettertest';
export async function deletePackagePolicy(bettertest: BetterTest, packagePolicyId: string) {
return bettertest({
pathname: `/api/fleet/package_policies/delete`,
method: 'post',
body: { packagePolicyIds: [packagePolicyId] },
});
}
export async function getProfilingPackagePolicyIds(bettertest: BetterTest) {
const response = await bettertest<{ items: PackagePolicy[] }>({
pathname: '/api/fleet/package_policies',
method: 'get',
});
const collector = response.body.items.find((item) => item.name === COLLECTOR_PACKAGE_POLICY_NAME);
const symbolizer = response.body.items.find(
(item) => item.name === SYMBOLIZER_PACKAGE_POLICY_NAME
);
return {
collectorId: collector?.id,
symbolizerId: symbolizer?.id,
};
}