[APM] Don't show deprecation notice in Kibana Upgrade Assistant for non-apm users (#120945) (#121121)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2021-12-21 09:18:16 -05:00 committed by GitHub
parent 32af1dd0a9
commit 3653d70904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 7 deletions

View file

@ -27,8 +27,8 @@ describe('getDeprecations', () => {
});
});
describe('when running on cloud with legacy apm-server', () => {
it('returns deprecations', async () => {
describe('when running on cloud without cloud agent policy', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
@ -39,6 +39,28 @@ describe('getDeprecations', () => {
} as unknown as APMRouteHandlerResources['plugins']['fleet'],
});
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).toEqual([]);
});
});
describe('when running on cloud with cloud agent policy and without apm integration', () => {
it('returns deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
agentPolicyService: {
get: () =>
({
id: 'foo',
package_policies: [''],
} as AgentPolicy),
},
}),
} as unknown as APMRouteHandlerResources['plugins']['fleet'],
});
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).not.toEqual([]);
// TODO: remove when docs support "main"
if (kibanaPackageJson.branch === 'main') {
@ -50,7 +72,7 @@ describe('getDeprecations', () => {
});
});
describe('when running on cloud with fleet', () => {
describe('when running on cloud with cloud agent policy and apm integration', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'main',

View file

@ -31,6 +31,8 @@ export function getDeprecations({
if (!fleet) {
return deprecations;
}
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;
const fleetPluginStart = await fleet.start();
const cloudAgentPolicy = await getCloudAgentPolicy({
@ -39,12 +41,10 @@ export function getDeprecations({
});
const isCloudEnabled = !!cloudSetup?.isCloudEnabled;
const hasCloudAgentPolicy = !isEmpty(cloudAgentPolicy);
const hasAPMPackagePolicy = !isEmpty(getApmPackagePolicy(cloudAgentPolicy));
// TODO: remove when docs support "main"
const docBranch = branch === 'main' ? 'master' : branch;
if (isCloudEnabled && !hasAPMPackagePolicy) {
if (isCloudEnabled && hasCloudAgentPolicy && !hasAPMPackagePolicy) {
deprecations.push({
title: i18n.translate('xpack.apm.deprecations.legacyModeTitle', {
defaultMessage: 'APM Server running in legacy mode',