-
Notifications
You must be signed in to change notification settings - Fork 736
test(amazonq): add performance test for prepareRepoData #5670
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
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
57dab4b
add test for many files
Hweinstock c56b967
clean up implementation to factor out duplicate code across two cases
Hweinstock d100360
Merge branch 'master' into pTests/prepareRepoData
Hweinstock 4ea87f7
adjust thresholds, remove utility function
Hweinstock 1c9ccb8
adjust thresholds based on CI results
Hweinstock a15364b
adjust thresholds
Hweinstock 2a8485d
refactor to avoid top-level defs
Hweinstock 08647ab
remove duration due to flakiness
Hweinstock 516f4db
update threshold add comment
Hweinstock c8d957c
add top level describe
Hweinstock 1513753
reduce code dupe, merge settings
Hweinstock 829ace7
Merge branch 'master' into pTests/prepareRepoData
Hweinstock 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
114 changes: 114 additions & 0 deletions
114
packages/core/src/test/amazonqFeatureDev/prepareRepoData.test.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,114 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import assert from 'assert' | ||
| import { WorkspaceFolder } from 'vscode' | ||
| import { performanceTest } from '../../shared/performance/performance' | ||
| import { createTestWorkspace } from '../testUtil' | ||
| import { prepareRepoData, TelemetryHelper } from '../../amazonqFeatureDev' | ||
| import { AmazonqCreateUpload, getRandomString, Metric } from '../../shared' | ||
|
|
||
| type resultType = { | ||
| zipFileBuffer: Buffer | ||
| zipFileChecksum: string | ||
| } | ||
|
|
||
| describe('prepareRepoDataPerformanceTest', function () { | ||
| function verifyResult(result: resultType, telemetry: TelemetryHelper, expectedSize: number): void { | ||
| assert.ok(result) | ||
| assert.strictEqual(Buffer.isBuffer(result.zipFileBuffer), true) | ||
| assert.strictEqual(telemetry.repositorySize, expectedSize) | ||
| assert.strictEqual(result.zipFileChecksum.length, 44) | ||
| } | ||
|
|
||
| performanceTest( | ||
| { | ||
| testRuns: 10, | ||
| linux: { | ||
| userCpuUsage: 80, | ||
| heapTotal: 4, | ||
| duration: 1.5, | ||
| }, | ||
| darwin: { | ||
| userCpuUsage: 80, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 4, | ||
| duration: 10, | ||
| }, | ||
| win32: { | ||
| userCpuUsage: 80, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 4, | ||
| duration: 3, | ||
| }, | ||
| }, | ||
| 'handles many files', | ||
| function () { | ||
| const telemetry = new TelemetryHelper() | ||
| let workspace: WorkspaceFolder | ||
| let result: resultType | ||
| return { | ||
| setup: async () => { | ||
| workspace = await createTestWorkspace(500, { | ||
| fileNamePrefix: 'file', | ||
| fileContent: '0123456789', | ||
| fileNameSuffix: '.md', | ||
| }) | ||
| }, | ||
| execute: async () => { | ||
| result = await prepareRepoData([workspace.uri.fsPath], [workspace], telemetry, { | ||
| record: () => {}, | ||
| } as unknown as Metric<AmazonqCreateUpload>) | ||
| }, | ||
| verify: async () => verifyResult(result, telemetry, 5000), | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| performanceTest( | ||
| { | ||
| testRuns: 10, | ||
| linux: { | ||
| userCpuUsage: 65, | ||
| systemCpuUsage: 30, | ||
| heapTotal: 1, | ||
| duration: 0.2, | ||
| }, | ||
| darwin: { | ||
| userCpuUsage: 50, | ||
| systemCpuUsage: 25, | ||
| heapTotal: 1, | ||
| duration: 0.4, | ||
| }, | ||
| win32: { | ||
| userCpuUsage: 60, | ||
| systemCpuUsage: 30, | ||
| heapTotal: 1, | ||
| duration: 0.2, | ||
| }, | ||
| }, | ||
|
|
||
| 'handles large files', | ||
| function () { | ||
| const telemetry = new TelemetryHelper() | ||
| let result: resultType | ||
| let workspace: WorkspaceFolder | ||
| return { | ||
| setup: async () => { | ||
| workspace = await createTestWorkspace(10, { | ||
jpinkney-aws marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fileNamePrefix: 'file', | ||
| fileContent: getRandomString(1000), | ||
| fileNameSuffix: '.md', | ||
| }) | ||
| }, | ||
| execute: async () => { | ||
| result = await prepareRepoData([workspace.uri.fsPath], [workspace], telemetry, { | ||
| record: () => {}, | ||
| } as unknown as Metric<AmazonqCreateUpload>) | ||
| }, | ||
| verify: async () => verifyResult(result, telemetry, 10000), | ||
| } | ||
| } | ||
| ) | ||
| }) | ||
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'd probably just have a top level describe thats prepareRepoData and then a second describe that has performance test in it, that way it can easily seperate perf tests from non perf tests if anyone wants to add it
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.
There are also some existing correctness tests in
test/unit/amazonqFeatureDev/util/files.test.ts. I kept the performance tests in core since thats where thestartSecurityScanis (src/test/codewhisperer/commands/startSecurityScan.test.ts).