Skip to content

Commit

Permalink
[APM] Use apm_8.0.0 archive where possible (#77450)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar authored Sep 15, 2020
1 parent ba4d4a9 commit d190a2a
Show file tree
Hide file tree
Showing 22 changed files with 5,922 additions and 7,467 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

const archiveName = 'apm_8.0.0';

describe('Has data', () => {
describe('when data is not loaded', () => {
it('returns false when there is no data', async () => {
Expand All @@ -28,8 +30,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
});
});
describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('returns true when there is at least one document on transaction, error or metrics indices', async () => {
const response = await supertest.get('/api/apm/observability_overview/has_data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import archives_metadata from '../../../common/archives_metadata';
import { expectSnapshot } from '../../../common/match_snapshot';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

const archiveName = 'apm_8.0.0';
const metadata = archives_metadata[archiveName];

// url parameters
const start = encodeURIComponent('2020-06-29T06:00:00.000Z');
const end = encodeURIComponent('2020-06-29T10:00:00.000Z');
const start = encodeURIComponent(metadata.start);
const end = encodeURIComponent(metadata.end);
const bucketSize = '60s';

describe('Observability overview', () => {
Expand All @@ -23,37 +27,58 @@ export default function ApiTest({ getService }: FtrProviderContext) {
`/api/apm/observability_overview?start=${start}&end=${end}&bucketSize=${bucketSize}`
);
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatchInline(`
Object {
"serviceCount": 0,
"transactionCoordinates": Array [],
}
`);

expect(response.body.serviceCount).to.be(0);
expect(response.body.transactionCoordinates.length).to.be(0);
});
});
describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('returns the service count and transaction coordinates', async () => {
const response = await supertest.get(
`/api/apm/observability_overview?start=${start}&end=${end}&bucketSize=${bucketSize}`
);
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatchInline(`
Object {
"serviceCount": 3,
"transactionCoordinates": Array [
Object {
"x": 1593413220000,
"y": 0.016666666666666666,
},
Object {
"x": 1593413280000,
"y": 1.0458333333333334,
},
],
}

expect(response.body.serviceCount).to.be.greaterThan(0);
expect(response.body.transactionCoordinates.length).to.be.greaterThan(0);

expectSnapshot(response.body.serviceCount).toMatchInline(`7`);

expectSnapshot(response.body.transactionCoordinates.length).toMatchInline(`60`);

expectSnapshot(
response.body.transactionCoordinates
.slice(0, 5)
.map(({ x, y }: { x: number; y: number }) => ({
x: new Date(x).toISOString(),
y,
}))
).toMatchInline(`
Array [
Object {
"x": "2020-09-10T06:00:00.000Z",
"y": 1.2166666666666666,
},
Object {
"x": "2020-09-10T06:01:00.000Z",
"y": 0.5,
},
Object {
"x": "2020-09-10T06:02:00.000Z",
"y": 1.0333333333333334,
},
Object {
"x": "2020-09-10T06:03:00.000Z",
"y": 0.55,
},
Object {
"x": "2020-09-10T06:04:00.000Z",
"y": 1.15,
},
]
`);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
*/

import expect from '@kbn/expect';
import { expectSnapshot } from '../../../common/match_snapshot';
import archives_metadata from '../../../common/archives_metadata';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function serviceMapsApiTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

const archiveName = 'apm_8.0.0';
const metadata = archives_metadata[archiveName];

// url parameters
const start = encodeURIComponent('2020-06-29T06:45:00.000Z');
const end = encodeURIComponent('2020-06-29T06:49:00.000Z');
const start = encodeURIComponent(metadata.start);
const end = encodeURIComponent(metadata.end);

describe('Service Maps', () => {
it('is only be available to users with Platinum license (or higher)', async () => {
const response = await supertest.get(`/api/apm/service-map?start=${start}&end=${end}`);

expect(response.status).to.be(403);
expect(response.body.message).to.be(
"In order to access Service Maps, you must be subscribed to an Elastic Platinum license. With it, you'll have the ability to visualize your entire application stack along with your APM data."

expectSnapshot(response.body.message).toMatchInline(
`"In order to access Service Maps, you must be subscribed to an Elastic Platinum license. With it, you'll have the ability to visualize your entire application stack along with your APM data."`
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
);

expect(response.status).to.be(200);

expect(response.body).to.eql({ agentName: 'nodejs' });
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
);

expect(response.status).to.be(200);
expect(response.body).to.eql({ hasHistoricalData: false, hasLegacyData: false, items: [] });
expect(response.body.hasHistoricalData).to.be(false);
expect(response.body.hasLegacyData).to.be(false);
expect(response.body.items.length).to.be(0);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
*/

import expect from '@kbn/expect';
import archives_metadata from '../../../common/archives_metadata';
import { expectSnapshot } from '../../../common/match_snapshot';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

const archiveName = 'apm_8.0.0';
const metadata = archives_metadata[archiveName];

// url parameters
const start = encodeURIComponent('2020-06-29T06:45:00.000Z');
const end = encodeURIComponent('2020-06-29T06:49:00.000Z');
const start = encodeURIComponent(metadata.start);
const end = encodeURIComponent(metadata.end);

describe('Transaction types', () => {
describe('when data is not loaded ', () => {
Expand All @@ -30,20 +34,22 @@ export default function ApiTest({ getService }: FtrProviderContext) {
});

describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('handles empty state', async () => {
const response = await supertest.get(
`/api/apm/services/opbeans-node/transaction_types?start=${start}&end=${end}`
);

expect(response.status).to.be(200);
expect(response.body.transactionTypes.length).to.be.greaterThan(0);

expectSnapshot(response.body).toMatchInline(`
Object {
"transactionTypes": Array [
"request",
"Worker",
"request",
],
}
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import expect from '@kbn/expect';
import { omit, orderBy } from 'lodash';
import { expectSnapshot } from '../../../common/match_snapshot';
import { AgentConfigurationIntake } from '../../../../../plugins/apm/common/agent_configuration/configuration_types';
import { AgentConfigSearchParams } from '../../../../../plugins/apm/server/routes/settings/agent_configuration';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
Expand All @@ -16,6 +17,8 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte
const log = getService('log');
const esArchiver = getService('esArchiver');

const archiveName = 'apm_8.0.0';

function getServices() {
return supertestRead
.get(`/api/apm/settings/agent-configuration/services`)
Expand Down Expand Up @@ -125,31 +128,46 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte
});

describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('returns all services', async () => {
const { body } = await getServices();
expect(body).to.eql([
'ALL_OPTION_VALUE',
'client',
'opbeans-dotnet',
'opbeans-go',
'opbeans-java',
'opbeans-node',
'opbeans-python',
'opbeans-ruby',
'opbeans-rum',
]);
expectSnapshot(body).toMatchInline(`
Array [
"ALL_OPTION_VALUE",
"opbeans-dotnet",
"opbeans-go",
"opbeans-java",
"opbeans-node",
"opbeans-python",
"opbeans-ruby",
"opbeans-rum",
]
`);
});

it('returns the environments', async () => {
it('returns the environments, all unconfigured', async () => {
const { body } = await getEnvironments('opbeans-node');
expect(body).to.eql([
{ name: 'ALL_OPTION_VALUE', alreadyConfigured: false },
{ name: 'testing', alreadyConfigured: false },
{ name: 'production', alreadyConfigured: false },
]);

expect(body.map((item: { name: string }) => item.name)).to.contain('ALL_OPTION_VALUE');

expect(
body.every((item: { alreadyConfigured: boolean }) => item.alreadyConfigured === false)
).to.be(true);

expectSnapshot(body).toMatchInline(`
Array [
Object {
"alreadyConfigured": false,
"name": "ALL_OPTION_VALUE",
},
Object {
"alreadyConfigured": false,
"name": "testing",
},
]
`);
});

it('returns the agent names', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default function customLinksTests({ getService }: FtrProviderContext) {
const log = getService('log');
const esArchiver = getService('esArchiver');

const archiveName = 'apm_8.0.0';

function searchCustomLinks(filters?: any) {
const path = URL.format({
pathname: `/api/apm/settings/custom_links`,
Expand Down Expand Up @@ -142,8 +144,8 @@ export default function customLinksTests({ getService }: FtrProviderContext) {
});

describe('transaction', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));
before(() => esArchiver.load(archiveName));
after(() => esArchiver.unload(archiveName));

it('fetches a transaction sample', async () => {
const response = await supertestRead.get(
Expand Down
Loading

0 comments on commit d190a2a

Please sign in to comment.