Skip to content

Commit baf5c07

Browse files
SAM: fix failing SAM tests (#4170)
* test: Bump sam version in CI to see if it passes now - remove the old tech debt test to signal to us to check if a new version works. We do not need this anymore now. - Always download the latest version of sam cli in CI instead of using the fixed version. This is back to what it was before we hard set a version. Signed-off-by: nkomonen <[email protected]> * remove node14 from sam tests This is indicated as deprecated Signed-off-by: nkomonen <[email protected]> * fix: sam python tests failing due to race condition We would run continueDebugger() to "click" the continue button when debugging, but this failed due to there being no breakpoints and the debugger never pausing. When trying to continue the call would throw an error since it wasn't possible. The spirit of the test was to click the continue button to ensure the debugger completed. Since we do not pause anywhere, the solution this commit does is to instead wait for the debug session to return nothing, assuming this indicates it is done. Signed-off-by: nkomonen <[email protected]> * install older version of python extension so CI passes Signed-off-by: nkomonen <[email protected]> --------- Signed-off-by: nkomonen <[email protected]>
1 parent 7a8f47e commit baf5c07

File tree

4 files changed

+41
-43
lines changed

4 files changed

+41
-43
lines changed

buildspec/linuxIntegrationTests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ phases:
5454
- bash buildspec/shared/linux-pre_build.sh
5555
# Where non-root "pip3 install" puts things:
5656
- 'export PATH="$HOME/.local/bin:$PATH"'
57-
# Explicit older version since we assume the newer version is causing our CI to fail (python 3.10 sam tests specifically)
58-
- '>/dev/null pip install aws-sam-cli==1.94.0'
57+
- '>/dev/null pip3 install --upgrade aws-sam-cli'
5958
- '>/dev/null pip3 install --upgrade awscli'
6059
# Print info about sam (version, location, …).
6160
- 'pip3 show aws-sam-cli'

scripts/test/launchTestUtilities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ export async function invokeVSCodeCli(vsCodeExecutablePath: string, args: string
7676
}
7777

7878
export async function installVSCodeExtension(vsCodeExecutablePath: string, extensionIdentifier: string): Promise<void> {
79+
// HACK: `sam.test.ts` Codelens test was failing for python due to bug in newer version, so lock to last working version.
80+
// Edge Case: This specific python version does not work with the "minimum" vscode version, so we do not override it as it
81+
// will choose its own python extension version that works.
82+
if (extensionIdentifier === VSCODE_EXTENSION_ID.python && process.env[envvarVscodeTestVersion] !== minimum) {
83+
extensionIdentifier = `${VSCODE_EXTENSION_ID.python}@2023.20.0`
84+
}
85+
7986
console.log(`Installing VS Code Extension: ${extensionIdentifier}`)
8087
console.log(await invokeVSCodeCli(vsCodeExecutablePath, ['--install-extension', extensionIdentifier]))
8188
}

src/test/techdebt.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import assert from 'assert'
77
import * as semver from 'semver'
88
import * as env from '../shared/vscode/env'
9+
import { installVSCodeExtension } from '../../scripts/test/launchTestUtilities'
910

1011
// Checks project config and dependencies, to remind us to remove old things
1112
// when possible.
@@ -43,20 +44,23 @@ describe('tech debt', function () {
4344
)
4445
})
4546

46-
it('remove explicit sam cli version', function () {
47-
// Indicate to start using the latest aws-sam-cli version in our CI
48-
// https://issues.amazon.com/issues/IDE-11386
47+
it('stop skipping CodeCatalyst E2E Tests', function () {
48+
// https://issues.amazon.com/issues/IDE-10496
4949
assert(
5050
new Date() < new Date(2024, 1, 15),
51-
'Remove use of 1.94.0 for aws-sam-cli in linuxIntegrationTests.yml and see if integration tests are passing now'
51+
'Re-evaluate if we should still keep skipping CodeCatalyst E2E Tests'
5252
)
5353
})
5454

55-
it('stop skipping CodeCatalyst E2E Tests', function () {
56-
// https://issues.amazon.com/issues/IDE-10496
55+
it('stop not using latest python extension version in integration CI tests', function () {
56+
/**
57+
* The explicitly set version is done in {@link installVSCodeExtension}
58+
* The parent ticket for SAM test issues: IDE-12295
59+
* Python Extension Bug Issue (if this is fixed, then this should be too): https://github.com/microsoft/vscode-python/issues/22659
60+
*/
5761
assert(
5862
new Date() < new Date(2024, 1, 15),
59-
'Re-evaluate if we should still keep skipping CodeCatalyst E2E Tests'
63+
'Re-evaluate if we can use the latest python extension version in CI integration tests'
6064
)
6165
})
6266
})

src/testInteg/sam.test.ts

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import { waitUntil } from '../shared/utilities/timeoutUtils'
2424
import { AwsSamDebuggerConfiguration } from '../shared/sam/debugger/awsSamDebugConfiguration.gen'
2525
import { AwsSamTargetType } from '../shared/sam/debugger/awsSamDebugConfiguration'
2626
import { insertTextIntoFile } from '../shared/utilities/textUtilities'
27-
import { sleep } from '../shared/utilities/timeoutUtils'
2827
import globals from '../shared/extensionGlobals'
2928
import { closeAllEditors } from '../test/testUtil'
29+
import { ToolkitError } from '../shared/errors'
3030

3131
const projectFolder = testUtils.getTestWorkspaceFolder()
3232

3333
/* Test constants go here */
3434
const codelensTimeout: number = 60000
35-
const codelensRetryInterval: number = 200
35+
const codelensRetryInterval: number = 5000
3636
const noDebugSessionTimeout: number = 5000
3737
const noDebugSessionInterval: number = 100
3838

@@ -55,15 +55,6 @@ interface TestScenario {
5555
// to reduce the chance of automated tests timing out.
5656
const scenarios: TestScenario[] = [
5757
// zips
58-
{
59-
runtime: 'nodejs14.x',
60-
displayName: 'nodejs14.x (ZIP)',
61-
path: 'hello-world/app.js',
62-
debugSessionType: 'pwa-node',
63-
language: 'javascript',
64-
dependencyManager: 'npm',
65-
vscodeMinimum: '1.50.0',
66-
},
6758
{
6859
runtime: 'nodejs16.x',
6960
displayName: 'nodejs16.x (ZIP)',
@@ -150,16 +141,6 @@ const scenarios: TestScenario[] = [
150141
// },
151142

152143
// images
153-
{
154-
runtime: 'nodejs14.x',
155-
displayName: 'nodejs14.x (Image)',
156-
baseImage: 'amazon/nodejs14.x-base',
157-
path: 'hello-world/app.js',
158-
debugSessionType: 'pwa-node',
159-
language: 'javascript',
160-
dependencyManager: 'npm',
161-
vscodeMinimum: '1.50.0',
162-
},
163144
{
164145
runtime: 'nodejs16.x',
165146
displayName: 'nodejs16.x (Image)',
@@ -326,25 +307,32 @@ async function startDebugger(
326307
)
327308
})
328309

329-
// Executes the 'F5' action
310+
// Executes the 'F5' action to start debugging
330311
await vscode.debug.startDebugging(undefined, testConfig)
331312
if (!vscode.debug.activeDebugSession) {
332313
logSession('EXIT', `${testConfig.name} (exited immediately)`)
333314
return
334315
}
335316
logSession('START', vscode.debug.activeDebugSession.name)
336-
await sleep(400)
337-
await continueDebugger()
338-
await sleep(400)
339-
await continueDebugger()
340-
await sleep(400)
341-
await continueDebugger()
342317

343-
return success
344-
}
318+
// Some tests need to hit debug continue to the debugger to complete.
319+
// Testing locally seemed to take 600-800 millis to run.
320+
const result = await waitUntil(
321+
async () => {
322+
try {
323+
await vscode.commands.executeCommand('workbench.action.debug.continue')
324+
return true
325+
} catch {
326+
return false
327+
}
328+
},
329+
{ interval: 500, timeout: 10_000 }
330+
)
331+
if (result === undefined) {
332+
throw new ToolkitError(`Toolkit: Debug session did not stop. Something may have gotten stuck.`)
333+
}
345334

346-
async function continueDebugger(): Promise<void> {
347-
await vscode.commands.executeCommand('workbench.action.debug.continue')
335+
return success
348336
}
349337

350338
async function stopDebugger(logMsg: string | undefined): Promise<void> {
@@ -507,13 +495,13 @@ describe('SAM Integration Tests', async function () {
507495
) {
508496
this.skip()
509497
}
510-
511498
const codeLenses = await testUtils.getAddConfigCodeLens(
512499
samAppCodeUri,
513500
codelensTimeout,
514501
codelensRetryInterval
515502
)
516-
assert.ok(codeLenses && codeLenses.length === 2)
503+
assert.ok(codeLenses, 'No CodeLenses provided')
504+
assert.strictEqual(codeLenses.length, 2, 'Incorrect amount of CodeLenses provided')
517505

518506
let manifestFile: RegExp
519507
switch (scenario.language) {

0 commit comments

Comments
 (0)