-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Migrate /mobile
API tests to deployment agnostic folder
#199021
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
eee7cd3
Add foundation to run apm tests
crespocarlos 5857da2
Force Git to recognize latest_agent_versions.spec.ts as moved
crespocarlos c45c662
Updated latest_agent_versions.spec.ts after moving
crespocarlos 66f5e4c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 17fb5e2
Simplify apmApi
crespocarlos 4d684c6
Symplify createApmSynthtraceEsClient
crespocarlos 06e7f74
Merge branch 'main' into 193245-apm-deployment-agnostic-tests-part-1
elasticmachine 4870a81
[APM] Migrate `/mobile` API tests to deployment agnostic folder
kpatticha 4671875
Merge branch 'main' of github.com:elastic/kibana into migrate-mobile-…
kpatticha 9a19a9b
Remove registry service
kpatticha a1db7f1
fix
kpatticha 1d64be8
Remove registry service
kpatticha 0906fa1
remove service once and for all
kpatticha 14105cb
Unskip mobile tests
kpatticha c9bccbf
Fix synthrace dropped document due to wrong type
kpatticha 0f511a1
Unskip tests
kpatticha 6b4ddc0
Merge branch 'main' of github.com:elastic/kibana into migrate-mobile-…
kpatticha 995aaa9
Can't pass grouping_name
kpatticha 2633eab
Merge branch 'main' into migrate-mobile-api-tests
kpatticha 06403c2
Clean up code
kpatticha 3878972
Merge branch 'migrate-mobile-api-tests' of github.com:kpatticha/kiban…
kpatticha 76d5c9f
Merge branch 'main' into migrate-mobile-api-tests
kpatticha 59fd80c
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 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 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
160 changes: 160 additions & 0 deletions
160
...ration/deployment_agnostic/apis/observability/apm/mobile/crashes/crash_group_list.spec.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,160 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import { apm, timerange } from '@kbn/apm-synthtrace-client'; | ||
import { | ||
APIClientRequestParamsOf, | ||
APIReturnType, | ||
} from '@kbn/apm-plugin/public/services/rest/create_call_apm_api'; | ||
import { RecursivePartial } from '@kbn/apm-plugin/typings/common'; | ||
import type { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace'; | ||
import type { DeploymentAgnosticFtrProviderContext } from '../../../../../ftr_provider_context'; | ||
|
||
type ErrorGroups = | ||
APIReturnType<'GET /internal/apm/mobile-services/{serviceName}/crashes/groups/main_statistics'>['errorGroups']; | ||
|
||
export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) { | ||
const apmApiClient = getService('apmApi'); | ||
const synthtrace = getService('synthtrace'); | ||
|
||
const serviceName = 'synth-swift'; | ||
const start = new Date('2021-01-01T00:00:00.000Z').getTime(); | ||
const end = new Date('2021-01-01T00:15:00.000Z').getTime() - 1; | ||
|
||
async function callApi( | ||
overrides?: RecursivePartial< | ||
APIClientRequestParamsOf<'GET /internal/apm/mobile-services/{serviceName}/crashes/groups/main_statistics'>['params'] | ||
> | ||
) { | ||
return await apmApiClient.readUser({ | ||
endpoint: 'GET /internal/apm/mobile-services/{serviceName}/crashes/groups/main_statistics', | ||
params: { | ||
path: { serviceName, ...overrides?.path }, | ||
query: { | ||
start: new Date(start).toISOString(), | ||
end: new Date(end).toISOString(), | ||
environment: 'ENVIRONMENT_ALL', | ||
kuery: '', | ||
...overrides?.query, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
describe('Crash group list', () => { | ||
it('handles empty state', async () => { | ||
const response = await callApi(); | ||
expect(response.status).to.be(200); | ||
expect(response.body.errorGroups).to.empty(); | ||
}); | ||
|
||
describe('when data is loaded', () => { | ||
describe('errors group', () => { | ||
let apmSynthtraceEsClient: ApmSynthtraceEsClient; | ||
|
||
const appleTransaction = { | ||
name: 'GET /apple 🍎 ', | ||
successRate: 75, | ||
failureRate: 25, | ||
}; | ||
|
||
const bananaTransaction = { | ||
name: 'GET /banana 🍌', | ||
successRate: 50, | ||
failureRate: 50, | ||
}; | ||
|
||
before(async () => { | ||
const serviceInstance = apm | ||
.service({ name: serviceName, environment: 'production', agentName: 'swift' }) | ||
.instance('instance-a'); | ||
|
||
apmSynthtraceEsClient = await synthtrace.createApmSynthtraceEsClient(); | ||
|
||
await apmSynthtraceEsClient.index([ | ||
timerange(start, end) | ||
.interval('1m') | ||
.rate(appleTransaction.successRate) | ||
.generator((timestamp) => | ||
serviceInstance | ||
.transaction({ transactionName: appleTransaction.name }) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
), | ||
timerange(start, end) | ||
.interval('1m') | ||
.rate(appleTransaction.failureRate) | ||
.generator((timestamp) => | ||
serviceInstance | ||
.transaction({ transactionName: appleTransaction.name }) | ||
.errors( | ||
serviceInstance | ||
.crash({ | ||
message: 'crash 1', | ||
}) | ||
.timestamp(timestamp) | ||
) | ||
.duration(1000) | ||
.timestamp(timestamp) | ||
.failure() | ||
), | ||
timerange(start, end) | ||
.interval('1m') | ||
.rate(bananaTransaction.successRate) | ||
.generator((timestamp) => | ||
serviceInstance | ||
.transaction({ transactionName: bananaTransaction.name }) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
), | ||
timerange(start, end) | ||
.interval('1m') | ||
.rate(bananaTransaction.failureRate) | ||
.generator((timestamp) => | ||
serviceInstance | ||
.transaction({ transactionName: bananaTransaction.name }) | ||
.errors( | ||
serviceInstance | ||
.crash({ | ||
message: 'crash 2', | ||
}) | ||
.timestamp(timestamp) | ||
) | ||
.duration(1000) | ||
.timestamp(timestamp) | ||
.failure() | ||
), | ||
]); | ||
}); | ||
|
||
after(() => apmSynthtraceEsClient.clean()); | ||
|
||
describe('returns the correct data', () => { | ||
let errorGroups: ErrorGroups; | ||
before(async () => { | ||
const response = await callApi(); | ||
errorGroups = response.body.errorGroups; | ||
}); | ||
it('returns correct number of crashes', () => { | ||
expect(errorGroups.length).to.equal(2); | ||
expect(errorGroups.map((error) => error.name).sort()).to.eql(['crash 1', 'crash 2']); | ||
}); | ||
|
||
it('returns correct occurrences', () => { | ||
const numberOfBuckets = 15; | ||
expect(errorGroups.map((error) => error.occurrences).sort()).to.eql([ | ||
appleTransaction.failureRate * numberOfBuckets, | ||
bananaTransaction.failureRate * numberOfBuckets, | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found out that this is causing the following issue
and as a result the documents are dropped.
The
grouping_name
in the mappingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I removed it