Skip to content
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

test(slowsam): samcli test speed up #5964

Merged
merged 10 commits into from
Nov 12, 2024
Merged

Conversation

Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Nov 8, 2024

Problem

  • The test failure is due to timeout on Windows when first searching for the SAM cli path in src/shared/sam/cli/samCliLocator.ts. This is a known slow process.
  • The verification of SAM is also slow (100-200ms), even if result is cached and we do this each time we read from cache.

Solution

  • Verify the cache once, rather than on each read.
  • Find sam cli in the before hook to allow all sam tests to run under same conditions. Otherwise, the first test is then responsible for actually finding the path causing it to take way longer than the rest of the tests.
  • Allow 3x retries on before hook on windows to avoid flakiness.

Notes

  • An alternative solution could involve manually inserting into the cache, or mocking a piece of the component, but wanted to keep the test coverage as is.
  • This approach also allows us to isolate the finding code into its own test (rather than whatever the first test is) to see if there are performance regressions.
  • Additionally, retry mechanism was more effective than increasing the timeout in reducing flakiness.

fix #2675


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

This comment was marked as resolved.

@Hweinstock Hweinstock changed the title test(slowsam): investigating slow SAM test (WIP) test(slowsam): samcli test speed up. Nov 8, 2024
@Hweinstock Hweinstock changed the title test(slowsam): samcli test speed up. test(slowsam): samcli test speed up Nov 8, 2024
@Hweinstock Hweinstock marked this pull request as ready for review November 11, 2024 16:23
@Hweinstock Hweinstock requested a review from a team as a code owner November 11, 2024 16:23
@@ -15,6 +14,7 @@ import * as vscode from 'vscode'
import globals from '../../extensionGlobals'
import { SamCliSettings } from './samCliSettings'
import { addTelemetryEnvVar, collectSamErrors, SamCliError } from './samCliInvokerUtils'
import { fs } from '../..'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid importing from index.ts files in core, it can cause circular dependencies (e.g. we export this file through that index.ts directly or indirectly). Instead import directly from the file.

Copy link
Contributor Author

@Hweinstock Hweinstock Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what purpose does index.js serve if its not supposed to be imported from? Is it just for exporting to external modules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just for exporting to external modules?

Yes, it's for the packages/amazon/ and packages/toolkit/ modules, which depend on packages/core/.

@justinmk3 justinmk3 merged commit 1153658 into aws:master Nov 12, 2024
23 of 25 checks passed
@Hweinstock Hweinstock deleted the slowSamTest branch November 12, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unreliable test: SamCliLocalInvokeInvocation, ChildProcess tests are slow
3 participants