mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
The tests have been adapted to be less flaky, re-enabling with this PR.
(cherry picked from commit a567dc7505
)
Co-authored-by: Walter Rafelsberger <walter@elastic.co>
This commit is contained in:
parent
4f9f54c81b
commit
c8457fd1e9
1 changed files with 52 additions and 24 deletions
|
@ -5,10 +5,15 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { chunk } from 'lodash';
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
||||
import type { LatencyCorrelationsResponse } from '../../../../plugins/apm/common/correlations/latency_correlations/types';
|
||||
import type {
|
||||
LatencyCorrelation,
|
||||
LatencyCorrelationsResponse,
|
||||
} from '../../../../plugins/apm/common/correlations/latency_correlations/types';
|
||||
|
||||
// These tests go through the full sequence of queries required
|
||||
// to get the final results for a latency correlation analysis.
|
||||
|
@ -105,8 +110,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
{ config: 'trial', archives: ['8.0.0'] },
|
||||
() => {
|
||||
// putting this into a single `it` because the responses depend on each other
|
||||
// flaky: https://github.com/elastic/kibana/issues/118023
|
||||
it.skip('runs queries and returns results', async () => {
|
||||
it('runs queries and returns results', async () => {
|
||||
const overallDistributionResponse = await apmApiClient.readUser({
|
||||
endpoint: 'POST /internal/apm/latency/overall_distribution',
|
||||
params: {
|
||||
|
@ -161,30 +165,54 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
`Expected field value pairs length to be '379', got '${fieldValuePairsResponse.body?.fieldValuePairs.length}'`
|
||||
);
|
||||
|
||||
const significantCorrelationsResponse = await apmApiClient.readUser({
|
||||
endpoint: 'POST /internal/apm/correlations/significant_correlations',
|
||||
params: {
|
||||
body: {
|
||||
...getOptions(),
|
||||
fieldValuePairs: fieldValuePairsResponse.body?.fieldValuePairs,
|
||||
// This replicates the code used in the `useLatencyCorrelations` hook to chunk requests for correlation analysis.
|
||||
// Tests turned out to be flaky and occasionally overload ES with a `search_phase_execution_exception`
|
||||
// when all 379 field value pairs from above are queried in parallel.
|
||||
// The chunking sends 10 field value pairs with each request to the Kibana API endpoint.
|
||||
// Kibana itself will then run those 10 requests in parallel against ES.
|
||||
const latencyCorrelations: LatencyCorrelation[] = [];
|
||||
let ccsWarning = false;
|
||||
const chunkSize = 10;
|
||||
|
||||
const fieldValuePairChunks = chunk(
|
||||
fieldValuePairsResponse.body?.fieldValuePairs,
|
||||
chunkSize
|
||||
);
|
||||
|
||||
for (const fieldValuePairChunk of fieldValuePairChunks) {
|
||||
const significantCorrelations = await apmApiClient.readUser({
|
||||
endpoint: 'POST /internal/apm/correlations/significant_correlations',
|
||||
params: {
|
||||
body: {
|
||||
...getOptions(),
|
||||
fieldValuePairs: fieldValuePairChunk,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
expect(significantCorrelationsResponse.status).to.eql(
|
||||
200,
|
||||
`Expected status to be '200', got '${significantCorrelationsResponse.status}'`
|
||||
);
|
||||
expect(significantCorrelations.status).to.eql(
|
||||
200,
|
||||
`Expected status to be '200', got '${significantCorrelations.status}'`
|
||||
);
|
||||
|
||||
// Loaded fractions and totalDocCount of 1244.
|
||||
expect(significantCorrelationsResponse.body?.totalDocCount).to.eql(
|
||||
1244,
|
||||
`Expected 1244 total doc count, got ${significantCorrelationsResponse.body?.totalDocCount}.`
|
||||
);
|
||||
// Loaded fractions and totalDocCount of 1244.
|
||||
expect(significantCorrelations.body?.totalDocCount).to.eql(
|
||||
1244,
|
||||
`Expected 1244 total doc count, got ${significantCorrelations.body?.totalDocCount}.`
|
||||
);
|
||||
|
||||
if (significantCorrelations.body?.latencyCorrelations.length > 0) {
|
||||
latencyCorrelations.push(...significantCorrelations.body?.latencyCorrelations);
|
||||
}
|
||||
|
||||
if (significantCorrelations.body?.ccsWarning) {
|
||||
ccsWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
const fieldsToSample = new Set<string>();
|
||||
if (significantCorrelationsResponse.body?.latencyCorrelations.length > 0) {
|
||||
significantCorrelationsResponse.body?.latencyCorrelations.forEach((d) => {
|
||||
if (latencyCorrelations.length > 0) {
|
||||
latencyCorrelations.forEach((d) => {
|
||||
fieldsToSample.add(d.fieldName);
|
||||
});
|
||||
}
|
||||
|
@ -200,10 +228,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
const finalRawResponse: LatencyCorrelationsResponse = {
|
||||
ccsWarning: significantCorrelationsResponse.body?.ccsWarning,
|
||||
ccsWarning,
|
||||
percentileThresholdValue: overallDistributionResponse.body?.percentileThresholdValue,
|
||||
overallHistogram: overallDistributionResponse.body?.overallHistogram,
|
||||
latencyCorrelations: significantCorrelationsResponse.body?.latencyCorrelations,
|
||||
latencyCorrelations,
|
||||
fieldStats: failedtransactionsFieldStats.body?.stats,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue