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] Testing error rate API and restructuring folders #72257

Merged
merged 8 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
24 changes: 12 additions & 12 deletions x-pack/test/apm_api_integration/basic/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ export default function apmApiIntegrationTests({ loadTestFile }: FtrProviderCont
describe('APM specs (basic)', function () {
this.tags('ciGroup1');

loadTestFile(require.resolve('./annotations'));
// feature_controls
loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./agent_configuration'));
loadTestFile(require.resolve('./custom_link'));
loadTestFile(require.resolve('./service_maps'));

// traces
loadTestFile(require.resolve('./traces/top_traces'));
// service_maps
loadTestFile(require.resolve('./service_maps/service_maps'));

// services
loadTestFile(require.resolve('./services/top_services'));
loadTestFile(require.resolve('./services/'));

// settings
loadTestFile(require.resolve('./settings/'));

// traces
loadTestFile(require.resolve('./traces/'));

// services/transaction
loadTestFile(require.resolve('./services/transactions/top_transaction_groups'));
loadTestFile(require.resolve('./services/transactions/transaction_charts'));
loadTestFile(require.resolve('./services/transactions/agent_name'));
loadTestFile(require.resolve('./services/transactions/transaction_types'));
// transaction_group
loadTestFile(require.resolve('./transaction_groups/'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

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

export default function serviceMapsApiTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

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

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import expect from '@kbn/expect';
import { JsonObject } from 'src/plugins/kibana_utils/common';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function annotationApiTests({ getService }: FtrProviderContext) {
const supertestWrite = getService('supertestAsApmAnnotationsWriteUser');
Expand Down
15 changes: 15 additions & 0 deletions x-pack/test/apm_api_integration/basic/tests/services/index.ts
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;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function servicesIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('Services', function () {
loadTestFile(require.resolve('./annotations'));
loadTestFile(require.resolve('./top_services'));
loadTestFile(require.resolve('./agent_name'));
loadTestFile(require.resolve('./transaction_types'));
});
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

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

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import expect from '@kbn/expect';
import { omit, orderBy } from 'lodash';
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';
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';

export default function agentConfigurationTests({ getService }: FtrProviderContext) {
const supertestRead = getService('supertestAsApmReadUser');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
import URL from 'url';
import expect from '@kbn/expect';
import { CustomLink } from '../../../../plugins/apm/common/custom_link/custom_link_types';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { CustomLink } from '../../../../../plugins/apm/common/custom_link/custom_link_types';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function customLinksTests({ getService }: FtrProviderContext) {
const supertestRead = getService('supertestAsApmReadUser');
Expand Down
13 changes: 13 additions & 0 deletions x-pack/test/apm_api_integration/basic/tests/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function settingsIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('Settings', function () {
loadTestFile(require.resolve('./custom_link'));
loadTestFile(require.resolve('./agent_configuration'));
});
}
12 changes: 12 additions & 0 deletions x-pack/test/apm_api_integration/basic/tests/traces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function tracesIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('Traces', function () {
loadTestFile(require.resolve('./top_traces'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import expectTopTraces from './top_traces.expectation.json';
import expectTopTraces from './expectation/top_traces.expectation.json';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import expectedErrorRate from './expectation/error_rate.json';

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

// url parameters
const start = encodeURIComponent('2020-06-29T06:45:00.000Z');
const end = encodeURIComponent('2020-06-29T06:49:00.000Z');
const uiFilters = encodeURIComponent(JSON.stringify({}));

describe('Error rate', () => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await supertest.get(
`/api/apm/services/opbeans-node/transaction_groups/error_rate?start=${start}&end=${end}&uiFilters=${uiFilters}`
);
expect(response.status).to.be(200);
expect(response.body).to.eql({
noHits: true,
erroneousTransactionsRate: [],
average: null,
});
});
});
describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));

it('returns the transaction error rate', async () => {
const response = await supertest.get(
`/api/apm/services/opbeans-node/transaction_groups/error_rate?start=${start}&end=${end}&uiFilters=${uiFilters}`
);

expect(response.status).to.be(200);
expect(response.body).to.eql(expectedErrorRate);
});
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"noHits":false,
"erroneousTransactionsRate":[
{
"x":1593413100000,
"y":null
},
{
"x":1593413130000,
"y":null
},
{
"x":1593413160000,
"y":null
},
{
"x":1593413190000,
"y":null
},
{
"x":1593413220000,
"y":null
},
{
"x":1593413250000,
"y":0
},
{
"x":1593413280000,
"y":0.14102564102564102
},
{
"x":1593413310000,
"y":0.14634146341463414
},
{
"x":1593413340000,
"y":null
}
],
"average":0.09578903481342504
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function transactionGroupIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('Transaction Group', function () {
loadTestFile(require.resolve('./top_transaction_groups'));
loadTestFile(require.resolve('./transaction_charts'));
loadTestFile(require.resolve('./error_rate'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import expectedTransactionGroups from './expectations/top_transaction_groups.json';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import expectedTransactionGroups from './expectation/top_transaction_groups.json';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../../common/ftr_provider_context';
import expectedTransactionCharts from './expectations/transaction_charts.json';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import expectedTransactionCharts from './expectation/transaction_charts.json';

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
12 changes: 9 additions & 3 deletions x-pack/test/apm_api_integration/trial/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { FtrProviderContext } from '../../../api_integration/ftr_provider_contex
export default function observabilityApiIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('APM specs (trial)', function () {
this.tags('ciGroup1');
loadTestFile(require.resolve('./annotations'));
loadTestFile(require.resolve('./service_maps'));
loadTestFile(require.resolve('./rum_services'));

// services
loadTestFile(require.resolve('./services'));

// service_maps
loadTestFile(require.resolve('./service_maps/service_maps'));

// transaction_groups
loadTestFile(require.resolve('./transaction_groups'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import querystring from 'querystring';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function serviceMapsApiTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import expect from '@kbn/expect';
import { merge, cloneDeep, isPlainObject } from 'lodash';
import { JsonObject } from 'src/plugins/kibana_utils/common';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

const DEFAULT_INDEX_NAME = 'observability-annotations';

Expand Down
13 changes: 13 additions & 0 deletions x-pack/test/apm_api_integration/trial/tests/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../common/ftr_provider_context';

export default function servicesIntegrationTests({ loadTestFile }: FtrProviderContext) {
describe('Services', function () {
loadTestFile(require.resolve('./annotations'));
loadTestFile(require.resolve('./rum_services.ts'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

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

export default function rumServicesApiTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import expectedErrorRate from './expectation/error_rate.json';

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

// url parameters
const start = encodeURIComponent('2020-06-29T06:45:00.000Z');
const end = encodeURIComponent('2020-06-29T06:49:00.000Z');
const uiFilters = encodeURIComponent(JSON.stringify({}));

describe('Error rate', () => {
describe('when data is not loaded', () => {
it('handles the empty state', async () => {
const response = await supertestAsApmReadUser.get(
`/api/apm/services/opbeans-node/transaction_groups/error_rate?start=${start}&end=${end}&uiFilters=${uiFilters}`
);
expect(response.status).to.be(200);
expect(response.body).to.eql({
noHits: true,
erroneousTransactionsRate: [],
average: null,
});
});
});
describe('when data is loaded', () => {
before(() => esArchiver.load('8.0.0'));
after(() => esArchiver.unload('8.0.0'));

it('returns the transaction error rate', async () => {
const response = await supertestAsApmReadUser.get(
`/api/apm/services/opbeans-node/transaction_groups/error_rate?start=${start}&end=${end}&uiFilters=${uiFilters}`
);

expect(response.status).to.be(200);
expect(response.body).to.eql(expectedErrorRate);
});
});
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I thought I wrote this comment already but I can't find it so might have forgotten to submit: I don't think we should have duplicate basic and trial tests if they are exactly the same. As a rule of thumb we should test everything in basic, and only add trial tests if behaviour changes with the license.

Copy link
Member

Choose a reason for hiding this comment

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

It would be great if we could annotate tests with a license, thereby making it possible to run the same test for both licenses without duplicating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we should have duplicate basic and trial tests if they are exactly the same

Thanks for clarifying it, I thought it was useless duplicating the test too. Just removed it.

Loading