-
Notifications
You must be signed in to change notification settings - Fork 737
test(amazonq): performance test for LSP setup. #5677
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 all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0905fa9
implement test, remove fs-extra
Hweinstock f52947b
add another test case
Hweinstock 60faa0c
add comments explaining the inputs
Hweinstock 4276229
update threshold
Hweinstock 91a87d1
adjust thresholds
Hweinstock 4e1e951
add more breathing room for linux tests
Hweinstock 6840095
adjust thresholds
Hweinstock 14da431
merge in master
Hweinstock 6c1af55
nerf threshold
Hweinstock 72d2137
make thresholds more lenient
Hweinstock f610941
make thresholds more lenient
Hweinstock dc24f30
remove some code dupe
Hweinstock 3f8ecd0
merge in master
Hweinstock e56a77f
Merge branch 'master' into pTests/tryInstallLsp
Hweinstock b5919ad
merge master
Hweinstock 07c65a6
move to integ
Hweinstock eaa6da7
fix imports
Hweinstock be3f6b7
Merge branch 'master' into pTests/tryInstallLsp
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import assert from 'assert' | ||
| import sinon from 'sinon' | ||
| import { Content } from 'aws-sdk/clients/codecommit' | ||
| import AdmZip from 'adm-zip' | ||
| import path from 'path' | ||
| import { LspController } from '../amazonq' | ||
| import { fs, getRandomString, globals } from '../shared' | ||
| import { createTestWorkspace } from '../test/testUtil' | ||
| import { performanceTest } from '../shared/performance/performance' | ||
|
|
||
| // fakeFileContent is matched to fakeQServerContent based on hash. | ||
| const fakeHash = '4eb2865c8f40a322aa04e17d8d83bdaa605d6f1cb363af615240a5442a010e0aef66e21bcf4c88f20fabff06efe8a214' | ||
|
|
||
| const fakeQServerContent = { | ||
| filename: 'qserver-fake.zip', | ||
| url: 'https://aws-language-servers/fake.zip', | ||
| hashes: [`sha384:${fakeHash}`], | ||
| bytes: 93610849, | ||
| serverVersion: '1.1.1', | ||
| } | ||
|
|
||
| const fakeNodeContent = { | ||
| filename: 'fake-file', | ||
| url: 'https://aws-language-servers.fake-file', | ||
| hashes: [`sha384:${fakeHash}`], | ||
| bytes: 94144448, | ||
| serverVersion: '1.1.1', | ||
| } | ||
|
|
||
| function createStubs(numberOfFiles: number, fileSize: number) { | ||
| // Avoid making HTTP request or mocking giant manifest, stub what we need directly from request. | ||
| sinon.stub(LspController.prototype, 'fetchManifest') | ||
| // Directly feed the runtime specifications. | ||
| sinon.stub(LspController.prototype, 'getQserverFromManifest').returns(fakeQServerContent) | ||
| sinon.stub(LspController.prototype, 'getNodeRuntimeFromManifest').returns(fakeNodeContent) | ||
| // avoid fetch call. | ||
| sinon.stub(LspController.prototype, '_download').callsFake(getFakeDownload(numberOfFiles, fileSize)) | ||
| // Hard code the hash since we are creating files on the spot, whose hashes can't be predicted. | ||
| sinon.stub(LspController.prototype, 'getFileSha384').resolves(fakeHash) | ||
| // Don't allow tryInstallLsp to move runtimes out of temporary folder. | ||
| sinon.stub(fs, 'rename') | ||
| } | ||
|
|
||
| /** | ||
| * Creates a fake zip with some files in it. | ||
| * @param filepath where to write the zip to. | ||
| * @param _content unused parameter, for compatability with real function. | ||
| */ | ||
| const getFakeDownload = function (numberOfFiles: number, fileSize: number) { | ||
| return async function (filepath: string, _content: Content) { | ||
| const dummyFilesPath = ( | ||
| await createTestWorkspace(numberOfFiles, { | ||
| fileNamePrefix: 'fakeFile', | ||
| fileContent: getRandomString(fileSize), | ||
| workspaceName: 'workspace', | ||
| }) | ||
| ).uri.fsPath | ||
| await fs.writeFile(path.join(dummyFilesPath, 'qserver'), 'this value shouldnt matter') | ||
| const zip = new AdmZip() | ||
| zip.addLocalFolder(dummyFilesPath) | ||
| zip.writeZip(filepath) | ||
| } | ||
| } | ||
|
|
||
| function performanceTestWrapper(numFiles: number, fileSize: number) { | ||
| return performanceTest( | ||
| { | ||
| testRuns: 10, | ||
| linux: { | ||
| userCpuUsage: 100, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 6, | ||
| duration: 15, | ||
| }, | ||
| darwin: { | ||
| userCpuUsage: 100, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 6, | ||
| duration: 15, | ||
| }, | ||
| win32: { | ||
| userCpuUsage: 100, | ||
| systemCpuUsage: 35, | ||
| heapTotal: 6, | ||
| duration: 15, | ||
| }, | ||
| }, | ||
| 'many small files in zip', | ||
| function () { | ||
| return { | ||
| setup: async () => { | ||
| createStubs(numFiles, fileSize) | ||
| }, | ||
| execute: async () => { | ||
| return await LspController.instance.tryInstallLsp(globals.context) | ||
| }, | ||
| verify: async (_setup: any, result: boolean) => { | ||
| assert.ok(result) | ||
| }, | ||
| } | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| describe('tryInstallLsp', function () { | ||
| afterEach(function () { | ||
| sinon.restore() | ||
| }) | ||
| describe('performance tests', function () { | ||
| performanceTestWrapper(250, 10) | ||
| performanceTestWrapper(10, 1000) | ||
| }) | ||
| }) |
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.
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.
probably should start a subdir in testInteg, maybe
testInteg/perf/. Or perf tests could in "normal" places (testInteg/path/to/module/) but use afoo.perf.test.tsfilename convention.