-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Adding api test for transaction_groups /breakdown and /avg_duration_by_browser #72623
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
Merged
cauemarcondes
merged 7 commits into
elastic:master
from
cauemarcondes:apm-transaction-breakdown-api-test
Jul 22, 2020
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
103f722
adding api test for transaction_groups /breakdown and /avg_duration_b…
cauemarcondes 148b827
adding filter by transaction name
cauemarcondes c15287b
adding filter by transaction name
cauemarcondes 4341be8
Merge branch 'master' into apm-transaction-breakdown-api-test
elasticmachine 4fcaf04
addressing pr comments
cauemarcondes 784b661
Merge branch 'apm-transaction-breakdown-api-test' of github.com:cauem…
cauemarcondes 2be9b50
fixing TS issue
cauemarcondes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/test/apm_api_integration/basic/tests/transaction_groups/avg_duration_by_browser.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * 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 expectedAvgDurationByBrowser from './expectation/avg_duration_by_browser.json'; | ||
| import expectedAvgDurationByBrowserWithTransactionName from './expectation/avg_duration_by_browser_transaction_name.json'; | ||
|
|
||
| export default function ApiTest({ getService }: FtrProviderContext) { | ||
| const supertest = getService('supertest'); | ||
| const esArchiver = getService('esArchiver'); | ||
|
|
||
| const start = encodeURIComponent('2020-06-29T06:45:00.000Z'); | ||
| const end = encodeURIComponent('2020-06-29T06:49:00.000Z'); | ||
| const transactionName = '/products'; | ||
| const uiFilters = encodeURIComponent(JSON.stringify({})); | ||
|
|
||
| describe('Average duration by browser', () => { | ||
| describe('when data is not loaded', () => { | ||
| it('handles the empty state', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/client/transaction_groups/avg_duration_by_browser?start=${start}&end=${end}&uiFilters=${uiFilters}` | ||
| ); | ||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql([]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('when data is loaded', () => { | ||
| before(() => esArchiver.load('8.0.0')); | ||
| after(() => esArchiver.unload('8.0.0')); | ||
|
|
||
| it('returns the average duration by browser', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/client/transaction_groups/avg_duration_by_browser?start=${start}&end=${end}&uiFilters=${uiFilters}` | ||
| ); | ||
|
|
||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql(expectedAvgDurationByBrowser); | ||
| }); | ||
| it('returns the average duration by browser filtering by transaction name', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/client/transaction_groups/avg_duration_by_browser?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionName=${transactionName}` | ||
| ); | ||
|
|
||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql(expectedAvgDurationByBrowserWithTransactionName); | ||
| }); | ||
| }); | ||
| }); | ||
| } |
67 changes: 67 additions & 0 deletions
67
x-pack/test/apm_api_integration/basic/tests/transaction_groups/breakdown.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * 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 expectedBreakdown from './expectation/breakdown.json'; | ||
| import expectedBreakdownWithTransactionName from './expectation/breakdown_transaction_name.json'; | ||
|
|
||
| export default function ApiTest({ getService }: FtrProviderContext) { | ||
| const supertest = getService('supertest'); | ||
| const esArchiver = getService('esArchiver'); | ||
|
|
||
| const start = encodeURIComponent('2020-06-29T06:45:00.000Z'); | ||
| const end = encodeURIComponent('2020-06-29T06:49:00.000Z'); | ||
| const transactionType = 'request'; | ||
| const transactionName = 'GET /api'; | ||
| const uiFilters = encodeURIComponent(JSON.stringify({})); | ||
|
|
||
| describe('Breakdown', () => { | ||
| describe('when data is not loaded', () => { | ||
| it('handles the empty state', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/opbeans-node/transaction_groups/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` | ||
| ); | ||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql({ kpis: [], timeseries: [] }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('when data is loaded', () => { | ||
| before(() => esArchiver.load('8.0.0')); | ||
| after(() => esArchiver.unload('8.0.0')); | ||
|
|
||
| it('returns the transaction breakdown for a service', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/opbeans-node/transaction_groups/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` | ||
| ); | ||
|
|
||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql(expectedBreakdown); | ||
| }); | ||
| it('returns the transaction breakdown for a transaction group', async () => { | ||
| const response = await supertest.get( | ||
| `/api/apm/services/opbeans-node/transaction_groups/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}&transactionName=${transactionName}` | ||
| ); | ||
|
|
||
| expect(response.status).to.be(200); | ||
| expect(response.body).to.eql(expectedBreakdownWithTransactionName); | ||
| }); | ||
| it('returns the kpis sorted by percentage and name', async () => { | ||
cauemarcondes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const response = await supertest.get( | ||
| `/api/apm/services/opbeans-node/transaction_groups/breakdown?start=${start}&end=${end}&uiFilters=${uiFilters}&transactionType=${transactionType}` | ||
| ); | ||
|
|
||
| expect(response.status).to.be(200); | ||
| expect(response.body.kpis).to.eql([ | ||
| { name: 'app', percentage: 0.16700861715223636, color: '#54b399' }, | ||
| { name: 'http', percentage: 0.7702092736971686, color: '#6092c0' }, | ||
| { name: 'postgresql', percentage: 0.0508822322527698, color: '#d36086' }, | ||
| { name: 'redis', percentage: 0.011899876897825195, color: '#9170b8' }, | ||
| ]); | ||
cauemarcondes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
| }); | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.