Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Migrate /observability_overview to deployment agnostic test #199817

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./correlations'));
loadTestFile(require.resolve('./entities'));
loadTestFile(require.resolve('./cold_start'));
loadTestFile(require.resolve('./observability_overview'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,57 @@

import expect from '@kbn/expect';

import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';
import { ARCHIVER_ROUTES } from '../constants/archiver';

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

registry.when(
'Observability overview when data is not loaded',
{ config: 'basic', archives: [] },
() => {
describe('has data', () => {
describe('when no data is loaded', () => {
it('returns false when there is no data', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(false);
});
}
);
});

describe('when only onboarding data is loaded', () => {
before(async () => {
await esArchiver.load(ARCHIVER_ROUTES.observability_overview);
});

after(async () => {
await esArchiver.unload(ARCHIVER_ROUTES.observability_overview);
});

registry.when(
'Observability overview when only onboarding data is loaded',
{ config: 'basic', archives: ['observability_overview'] },
() => {
it('returns false when there is only onboarding data', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(false);
});
}
);
});

describe('when data is loaded', () => {
before(async () => {
await esArchiver.load(ARCHIVER_ROUTES['8.0.0']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 8.0.0 as apm_8.0.0 contains .ml-config indices which make MKI unable to pass. The logic stills the same as this endpoint only checks if there is any apm data, and there is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for mentioning this! I’ll double-check a few migration issues I previously discarded for similar reasons to see if that change might allow them to work without the ML index on the mappings.

});
after(async () => {
await esArchiver.unload(ARCHIVER_ROUTES['8.0.0']);
});

registry.when(
'Observability overview when APM data is loaded',
{ config: 'basic', archives: ['apm_8.0.0'] },
() => {
it('returns true when there is at least one document on transaction, error or metrics indices', async () => {
const response = await apmApiClient.readUser({
endpoint: 'GET /internal/apm/observability_overview/has_data',
});
expect(response.status).to.be(200);
expect(response.body.hasData).to.eql(true);
});
}
);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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('observability_overview', () => {
loadTestFile(require.resolve('./has_data.spec.ts'));
loadTestFile(require.resolve('./observability_overview.spec.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import expect from '@kbn/expect';
import { meanBy, sumBy } from 'lodash';
import { ApmDocumentType } from '@kbn/apm-plugin/common/document_type';
import { RollupInterval } from '@kbn/apm-plugin/common/rollup';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { roundNumber } from '../../utils';
import { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
import { roundNumber } from '../../../../../../apm_api_integration/utils';
import type { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context';

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

const apmSynthtraceEsClient = getService('apmSynthtraceEsClient');
export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) {
const apmApiClient = getService('apmApi');
const synthtrace = getService('synthtrace');

const start = new Date('2021-01-01T00:00:00.000Z').getTime();
const end = new Date('2021-01-01T00:15:00.000Z').getTime() - 1;
Expand Down Expand Up @@ -62,35 +61,30 @@ export default function ApiTest({ getService }: FtrProviderContext) {
};
}

registry.when(
'Observability overview when data is not loaded',
{ config: 'basic', archives: [] },
() => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await apmApiClient.readUser({
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
start: new Date(start).toISOString(),
end: new Date(end).toISOString(),
bucketSize,
intervalString,
},
describe('Observability overview', () => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await apmApiClient.readUser({
endpoint: `GET /internal/apm/observability_overview`,
params: {
query: {
start: new Date(start).toISOString(),
end: new Date(end).toISOString(),
bucketSize,
intervalString,
},
});
expect(response.status).to.be(200);

expect(response.body.serviceCount).to.be(0);
expect(response.body.transactionPerMinute.timeseries.length).to.be(0);
},
});
expect(response.status).to.be(200);

expect(response.body.serviceCount).to.be(0);
expect(response.body.transactionPerMinute.timeseries.length).to.be(0);
});
}
);
});

// FLAKY: https://github.com/elastic/kibana/issues/177497
registry.when('data is loaded', { config: 'basic', archives: [] }, () => {
describe('Observability overview api ', () => {
let apmSynthtraceEsClient: ApmSynthtraceEsClient;

const GO_PROD_RATE = 50;
const GO_DEV_RATE = 5;
const JAVA_PROD_RATE = 45;
Expand All @@ -106,6 +100,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
.service({ name: 'synth-java', environment: 'production', agentName: 'java' })
.instance('instance-c');

apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient();

await apmSynthtraceEsClient.index([
timerange(start, end)
.interval('1m')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6213,10 +6213,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
Copy link
Contributor Author

@rmyz rmyz Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed lifecycle and refresh_interval on both archives as they crash for serverless & MKI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know that removing the refresh_interval won’t affect any other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @crespocarlos said, it should pick up the default value and not give any problems, at least, I did that before and nothing happened

"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-error"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -6225,8 +6221,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -11748,10 +11743,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-metric"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -11760,8 +11751,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -16847,10 +16837,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-span"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -16859,8 +16845,7 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
Expand Down Expand Up @@ -22037,10 +22022,6 @@
"read_only_allow_delete": "false"
},
"codec": "best_compression",
"lifecycle": {
"name": "apm-rollover-30-days",
"rollover_alias": "apm-7.14.0-transaction"
},
"mapping": {
"total_fields": {
"limit": "2000"
Expand All @@ -22049,9 +22030,8 @@
"max_docvalue_fields_search": "200",
"number_of_replicas": "1",
"number_of_shards": "1",
"priority": "100",
"refresh_interval": "5s"
"priority": "100"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4222,8 +4222,7 @@
"transaction.message.queue.name",
"fields.*"
]
},
"refresh_interval": "1ms"
}
}
}
}
Expand Down