Skip to content

Commit

Permalink
[APM] Migrate /observability_overview to deployment agnostic test (e…
Browse files Browse the repository at this point in the history
…lastic#199817)

## Summary

Closes elastic#198981
Part of elastic#193245

This PR contains the changes to migrate `observability_overview` test
folder to Deployment-agnostic testing strategy.

### How to test

- Serverless

```
node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts
node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts --grep="APM"
```

It's recommended to be run against
[MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki)

- Stateful
```
node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts
node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts --grep="APM"
```

## Checks

- [x] (OPTIONAL, only if a test has been unskipped) Run flaky test suite
- [x] local run for serverless
- [x] local run for stateful
- [x] MKI run for serverless
  • Loading branch information
rmyz authored and CAWilson94 committed Nov 18, 2024
1 parent f3cc6ef commit 04239cb
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function apmApiIntegrationTests({
loadTestFile(require.resolve('./correlations'));
loadTestFile(require.resolve('./entities'));
loadTestFile(require.resolve('./cold_start'));
loadTestFile(require.resolve('./observability_overview'));
loadTestFile(require.resolve('./latency'));
loadTestFile(require.resolve('./infrastructure'));
});
Expand Down
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']);
});
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",
"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

0 comments on commit 04239cb

Please sign in to comment.