Skip to content

Commit 4e3d5d0

Browse files
authored
Fix create and deploy tests (#4369)
* CHANGELOG and bump version * Make fixes for flex being the basic create exp. * Point to our shared template * Add additionalStep to right parameters * Use whatever alias for python, not just 3.9 * Some more test fixes * ffffff * Shorten app name in testing * Must start with an alphabet * Install .NET 9 * Remove staging location * Convert paths to linux * Some fixup/cleanup * Add link to issue
1 parent 02aeea2 commit 4e3d5d0

File tree

10 files changed

+40
-25
lines changed

10 files changed

+40
-25
lines changed

.azure-pipelines/1esmain.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extends:
4949
parameters:
5050
sdl:
5151
credscan:
52-
suppressionsFile: $(Build.SourcesDirectory)\.azure-pipelines\compliance\CredScanSuppressions.json
52+
suppressionsFile: $(Build.SourcesDirectory)/.azure-pipelines/compliance/CredScanSuppressions.json
5353
codeql:
5454
language: javascript # only build a codeql database for javascript, since the jsoncli pipeline handles csharp
5555
# enabled: true # TODO: would like to enable only on scheduled builds but CodeQL cannot currently be disabled per https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/1es-codeql
@@ -62,3 +62,10 @@ extends:
6262
- template: azure-pipelines/1esstages.yml@azExtTemplates
6363
parameters:
6464
useAzureFederatedCredentials: ${{ parameters.enableLongRunningTests }}
65+
additionalSetupSteps:
66+
- script: |
67+
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
68+
chmod +x ./dotnet-install.sh
69+
./dotnet-install.sh --channel 9.0
70+
displayName: Install .NET 9.0
71+
name: Install_dotnet

.azure-pipelines/compliance/CredScanSuppressions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"_justification": "This is a false positive"
1919
},
2020
{
21-
"folder": "\\resources\\backupTemplates",
21+
"folder": "/resources/backupTemplates",
2222
"_justification": "folder to be suppressed because the templates contain lots of fake passwords and secrets"
2323
}
2424
]

extension.bundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export * from './src/commands/deleteFunctionApp';
2727
export * from './src/commands/deploy/deploy';
2828
export * from './src/commands/deploy/verifyAppSettings';
2929
export * from './src/commands/initProjectForVSCode/initProjectForVSCode';
30-
export * from './src/utils/durableUtils';
3130
export * from './src/constants';
31+
export * from './src/utils/durableUtils';
3232
// Export activate/deactivate for main.js
3333
export { activateInternal, deactivateInternal } from './src/extension';
3434
export * from './src/extensionVariables';

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-azurefunctions",
33
"displayName": "Azure Functions",
44
"description": "%azureFunctions.description%",
5-
"version": "1.16.2-alpha.0",
5+
"version": "1.16.2-alpha",
66
"publisher": "ms-azuretools",
77
"icon": "resources/azure-functions.png",
88
"aiKey": "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255",

src/utils/fs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export function getRandomHexString(length: number = 10): string {
6464
return buffer.toString('hex').slice(0, length);
6565
}
6666

67+
export function getRandomAlphanumericString(): string {
68+
// toString(36) to convert it into base 36 (26 char + 0 to 9) and slice(2) to remove the '0.'
69+
return Math.random().toString(36).slice(2);
70+
}
71+
6772
export function isPathEqual(fsPath1: string, fsPath2: string, relativeFunc: pathRelativeFunc = path.relative): boolean {
6873
const relativePath: string = relativeFunc(fsPath1, fsPath2);
6974
return relativePath === '';

test/nightly/createProjectAndDeploy.test.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
import { type ServiceClient } from '@azure/core-client';
77
import { createPipelineRequest } from '@azure/core-rest-pipeline';
8-
import { createTestActionContext, runWithTestActionContext, type TestInput } from '@microsoft/vscode-azext-dev';
8+
import { TestInput, createTestActionContext, runWithTestActionContext } from '@microsoft/vscode-azext-dev';
99
import { AzExtFsExtra } from '@microsoft/vscode-azext-utils';
1010
import * as assert from 'assert';
1111
import * as path from 'path';
1212
import * as vscode from 'vscode';
13-
import { FuncVersion, ProjectLanguage, copyFunctionUrl, createGenericClient, createNewProjectInternal, deployProductionSlot, getRandomHexString, nonNullProp } from '../../extension.bundle';
13+
import { FuncVersion, ProjectLanguage, copyFunctionUrl, createGenericClient, createNewProjectInternal, deployProductionSlot, getRandomAlphanumericString, getRandomHexString, nonNullProp } from '../../extension.bundle';
1414
import { addParallelSuite, runInSeries, type ParallelTest } from '../addParallelSuite';
1515
import { getTestWorkspaceFolder } from '../global.test';
1616
import { NodeModelInput, NodeModelVersion, PythonModelInput, PythonModelVersion, defaultTestFuncVersion, getCSharpValidateOptions, getJavaScriptValidateOptions, getPowerShellValidateOptions, getPythonValidateOptions, getTypeScriptValidateOptions, validateProject, type IValidateProjectOptions } from '../project/validateProject';
@@ -23,18 +23,19 @@ interface CreateProjectAndDeployTestCase extends ICreateProjectAndDeployOptions
2323
}
2424

2525
const testCases: CreateProjectAndDeployTestCase[] = [
26-
{ title: 'JavaScript (Model V3)', ...getJavaScriptValidateOptions(true), createProjectInputs: [NodeModelInput[NodeModelVersion.v3]], deployInputs: [getRotatingNodeVersion()], languageModelVersion: NodeModelVersion.v3 },
27-
{ title: 'JavaScript (Model V4)', ...getJavaScriptValidateOptions(true, undefined, undefined, undefined, NodeModelVersion.v4), createProjectInputs: [NodeModelInput[NodeModelVersion.v4]], deployInputs: [getRotatingNodeVersion()], languageModelVersion: NodeModelVersion.v4 },
28-
{ title: 'TypeScript (Model V3)', ...getTypeScriptValidateOptions(), createProjectInputs: [NodeModelInput[NodeModelVersion.v3]], deployInputs: [getRotatingNodeVersion()], languageModelVersion: NodeModelVersion.v3 },
29-
{ title: 'TypeScript (Model V4)', ...getTypeScriptValidateOptions({ modelVersion: NodeModelVersion.v4 }), createProjectInputs: [NodeModelInput[NodeModelVersion.v4]], deployInputs: [getRotatingNodeVersion()], languageModelVersion: NodeModelVersion.v4 },
26+
{ title: 'JavaScript (Model V3)', ...getJavaScriptValidateOptions(true), createProjectInputs: [NodeModelInput[NodeModelVersion.v3]], deployInputs: [getRotatingNodeVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: NodeModelVersion.v3 },
27+
{ title: 'JavaScript (Model V4)', ...getJavaScriptValidateOptions(true, undefined, undefined, undefined, NodeModelVersion.v4), createProjectInputs: [NodeModelInput[NodeModelVersion.v4]], deployInputs: [getRotatingNodeVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: NodeModelVersion.v4 },
28+
{ title: 'TypeScript (Model V3)', ...getTypeScriptValidateOptions(), createProjectInputs: [NodeModelInput[NodeModelVersion.v3]], deployInputs: [getRotatingNodeVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: NodeModelVersion.v3 },
29+
{ title: 'TypeScript (Model V4)', ...getTypeScriptValidateOptions({ modelVersion: NodeModelVersion.v4 }), createProjectInputs: [NodeModelInput[NodeModelVersion.v4]], deployInputs: [getRotatingNodeVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: NodeModelVersion.v4 },
3030
// Temporarily disable Ballerina tests until we can install Ballerina on the new pipelines
3131
// https://github.com/microsoft/vscode-azurefunctions/issues/4210
3232
// { title: 'Ballerina', ...getBallerinaValidateOptions(), createProjectInputs: ["JVM"], deployInputs: [/java.*11/i] },
33-
{ title: 'C# .NET Framework', buildMachineOsToSkip: 'darwin', ...getCSharpValidateOptions('net48'), createProjectInputs: [/net.*Framework/i], deployInputs: [/net.*Framework/i], createFunctionInputs: ['Company.Function'] },
34-
{ title: 'C# .NET 8', ...getCSharpValidateOptions('net8.0', FuncVersion.v4), createProjectInputs: [/net.*8/i], deployInputs: [/net.*8/i], createFunctionInputs: ['Company.Function'] },
35-
{ title: 'PowerShell', ...getPowerShellValidateOptions(), deployInputs: [/powershell.*7.4/i] },
36-
{ title: 'Python (Model V1)', ...getPythonValidateOptions('.venv'), createProjectInputs: [PythonModelInput[PythonModelVersion.v1], /3\.9/], deployInputs: [getRotatingPythonVersion()], languageModelVersion: PythonModelVersion.v1 },
37-
{ title: 'Python (Model V2)', ...getPythonValidateOptions('.venv', undefined, PythonModelVersion.v2), createProjectInputs: [PythonModelInput[PythonModelVersion.v2], /3\.9/], deployInputs: [getRotatingPythonVersion()], languageModelVersion: PythonModelVersion.v2 },
33+
{ title: 'C# .NET 8', ...getCSharpValidateOptions('net8.0', FuncVersion.v4), createProjectInputs: [/net.*8/i], deployInputs: [/net.*8/i, TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], createFunctionInputs: ['Company.Function'] },
34+
// Temporarily disable .NET 9 test for now; it seems to break after running clean release (functions)
35+
// { title: 'C# .NET 9', ...getCSharpValidateOptions('net9.0', FuncVersion.v4), createProjectInputs: [/net.*9/i], deployInputs: [/net.*9/i, TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], createFunctionInputs: ['Company.Function'] },
36+
{ title: 'PowerShell', ...getPowerShellValidateOptions(), deployInputs: [/powershell.*7.4/i, TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/] },
37+
{ title: 'Python (Model V1)', ...getPythonValidateOptions('.venv'), createProjectInputs: [PythonModelInput[PythonModelVersion.v1], /py/], deployInputs: [getRotatingPythonVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: PythonModelVersion.v1 },
38+
{ title: 'Python (Model V2)', ...getPythonValidateOptions('.venv', undefined, PythonModelVersion.v2), createProjectInputs: [PythonModelInput[PythonModelVersion.v2], /py/], deployInputs: [getRotatingPythonVersion(), TestInput.UseDefaultValue /* instance mem size*/, TestInput.UseDefaultValue /*max instance*/], languageModelVersion: PythonModelVersion.v2 },
3839
]
3940

4041
const parallelTests: ParallelTest[] = [];
@@ -63,7 +64,7 @@ interface ICreateProjectAndDeployOptions extends IValidateProjectOptions {
6364
}
6465

6566
async function testCreateProjectAndDeploy(options: ICreateProjectAndDeployOptions): Promise<void> {
66-
const functionName: string = 'func' + getRandomHexString(); // function name must start with a letter
67+
const functionName: string = 'f' + getRandomAlphanumericString(); // function name must only contain alphanumeric
6768

6869
const testWorkspacePath = getTestWorkspaceFolder();
6970
await runWithTestActionContext('createNewProject', async context => {
@@ -86,11 +87,13 @@ async function testCreateProjectAndDeploy(options: ICreateProjectAndDeployOption
8687
const routePrefix: string = getRandomHexString();
8788
await addRoutePrefixToProject(testWorkspacePath, routePrefix);
8889

89-
const appName: string = 'funcBasic' + getRandomHexString();
90+
// TODO: investigate why our SDK calls are throwing errors when app name is over ~12 characters
91+
// https://github.com/microsoft/vscode-azurefunctions/issues/4368
92+
const appName: string = 'f' + getRandomAlphanumericString();
9093
resourceGroupsToDelete.push(appName);
9194
await runWithTestActionContext('deploy', async context => {
9295
options.deployInputs = options.deployInputs || [];
93-
await context.ui.runWithInputs([testWorkspacePath, /create new function app/i, appName, ...options.deployInputs, getRotatingLocation()], async () => {
96+
await context.ui.runWithInputs([testWorkspacePath, /create new function app/i, appName, getRotatingLocation(), ...options.deployInputs], async () => {
9497
await deployProductionSlot(context)
9598
});
9699
});

test/nightly/getRotatingValue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ export function getRotatingAuthLevel(): string {
1111
}
1212

1313
let locationCount: number = getStartingIndex();
14-
const locations: string[] = ['Australia East', 'East Asia', 'East US', 'North Europe', 'South Central US', 'Southeast Asia', 'UK South', 'West Europe'];
14+
const locations: string[] = ["East US", "South Central US", "West US 2", "West US 3", "Australia East", "Southeast Asia", "North Europe", "Sweden Central", "UK South", "East Asia", "East US 2"];
1515
export function getRotatingLocation(): string {
1616
locationCount += 1;
1717
return locations[locationCount % locations.length];
1818
}
1919

2020
let nodeVersionCount: number = getStartingIndex();
21-
const nodeVersions: RegExp[] = [/node.*18/i, /node.*20/i];
21+
const nodeVersions: RegExp[] = [/node.*20/i];
2222
export function getRotatingNodeVersion(): RegExp {
2323
nodeVersionCount += 1;
2424
return nodeVersions[nodeVersionCount % nodeVersions.length];
2525
}
2626

2727
let pyVersionCount: number = getStartingIndex();
28-
const pyVersions: RegExp[] = [/python.*3\.8/i, /python.*3\.9/i, /python.*3\.10/i, /python.*3\.11/i];
28+
const pyVersions: RegExp[] = [/python.*3\.10/i, /python.*3\.11/i];
2929
export function getRotatingPythonVersion(): RegExp {
3030
pyVersionCount += 1;
3131
return pyVersions[pyVersionCount % pyVersions.length];

test/project/createNewPythonProject.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ suite('Create New Python Project (Model V1)', () => {
2828
}
2929
this.timeout(2 * 60 * 1000);
3030

31-
const alias: string = process.platform === 'win32' ? 'py -3.9' : 'python3.9';
31+
const alias: string = process.platform === 'win32' ? 'py' : 'python';
3232
await runWithTestActionContext('createProject', async context => {
3333
await createAndValidateProject(context, { ...getPythonValidateOptions('.venv', FuncVersion.v4), inputs: [modelV1Input, /enter/i, alias] });
3434
});

tools/JsonCli/.azure-pipelines/1esmain.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extends:
3939
parameters:
4040
sdl:
4141
credscan:
42-
suppressionsFile: $(Build.SourcesDirectory)\.azure-pipelines\compliance\CredScanSuppressions.json
42+
suppressionsFile: $(Build.SourcesDirectory)/.azure-pipelines/compliance/CredScanSuppressions.json
4343
codeql:
4444
language: csharp # only build a codeql database for csharp, since the pipeline at the root handles javascript
4545
# enabled: true # TODO: would like to enable only on scheduled builds but CodeQL cannot currently be disabled per https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/1es-codeql

0 commit comments

Comments
 (0)