-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding api test for transaction_groups /breakdown and /avg_duration_b…
…y_browser (#72623) * adding api test for transaction_groups /breakdown and /avg_duration_by_browser * adding filter by transaction name * adding filter by transaction name * addressing pr comments * fixing TS issue Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
e389968
commit 5d261ee
Showing
10 changed files
with
1,855 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 top 4 by percentage and sorts them by name', 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.kpis.map((kpi: { name: string }) => kpi.name)).to.eql([ | ||
'app', | ||
'http', | ||
'postgresql', | ||
'redis', | ||
]); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.