-
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
Changes from 9 commits
57dab4b
c56b967
d100360
4ea87f7
1c9ccb8
a15364b
2a8485d
08647ab
516f4db
c8d957c
1513753
829ace7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /*! | ||
| * 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) | ||
| } | ||
| /** | ||
| * Tests 250 files w/ 10 bytes each. | ||
| * Running more files can lead to flaky test from timeout. | ||
|
||
| */ | ||
| performanceTest( | ||
| { | ||
| testRuns: 10, | ||
| linux: { | ||
| userCpuUsage: 90, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 4, | ||
| }, | ||
| darwin: { | ||
| userCpuUsage: 90, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 4, | ||
| }, | ||
| win32: { | ||
| userCpuUsage: 90, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 4, | ||
| }, | ||
| }, | ||
| 'handles many files', | ||
| function () { | ||
| const telemetry = new TelemetryHelper() | ||
| return { | ||
| setup: async () => { | ||
| return await createTestWorkspace(250, { | ||
| fileNamePrefix: 'file', | ||
| fileContent: '0123456789', | ||
| fileNameSuffix: '.md', | ||
| }) | ||
| }, | ||
| execute: async (workspace: WorkspaceFolder) => { | ||
| return await prepareRepoData([workspace.uri.fsPath], [workspace], telemetry, { | ||
| record: () => {}, | ||
| } as unknown as Metric<AmazonqCreateUpload>) | ||
| }, | ||
| verify: async (_w: WorkspaceFolder, result: resultType) => verifyResult(result, telemetry, 2500), | ||
| } | ||
| } | ||
| ) | ||
| /** | ||
| * Runs 10 files of size 1000 bytes. | ||
| */ | ||
| performanceTest( | ||
| { | ||
| testRuns: 10, | ||
| linux: { | ||
| userCpuUsage: 65, | ||
| systemCpuUsage: 30, | ||
| heapTotal: 1, | ||
| }, | ||
| darwin: { | ||
| userCpuUsage: 50, | ||
| systemCpuUsage: 25, | ||
| heapTotal: 1, | ||
| }, | ||
| win32: { | ||
| userCpuUsage: 60, | ||
| systemCpuUsage: 30, | ||
| heapTotal: 1, | ||
| }, | ||
| }, | ||
|
|
||
| 'handles large files', | ||
| function () { | ||
| const telemetry = new TelemetryHelper() | ||
| return { | ||
| setup: async () => { | ||
| return await createTestWorkspace(10, { | ||
| fileNamePrefix: 'file', | ||
| fileContent: getRandomString(1000), | ||
| fileNameSuffix: '.md', | ||
| }) | ||
| }, | ||
| execute: async (workspace: WorkspaceFolder) => { | ||
| return await prepareRepoData([workspace.uri.fsPath], [workspace], telemetry, { | ||
| record: () => {}, | ||
| } as unknown as Metric<AmazonqCreateUpload>) | ||
| }, | ||
| verify: async (_w: WorkspaceFolder, result: resultType) => verifyResult(result, telemetry, 10000), | ||
| } | ||
| } | ||
| ) | ||
| }) | ||
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).