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

Fix, update, and enable long running tests #4209

Merged
merged 70 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
e1b52b5
try this
hossam-nasr Jun 19, 2024
de84793
fix build error
hossam-nasr Jun 19, 2024
8baaa0e
cleanup
hossam-nasr Jun 19, 2024
1e9cbd4
log subscription for verification
hossam-nasr Jun 19, 2024
9445ee8
only run function app operations tests?
hossam-nasr Jun 19, 2024
69ab449
try with correct prompt order
hossam-nasr Jun 19, 2024
6d45d99
try only function app operations
hossam-nasr Jun 19, 2024
2abcb74
add new options to rotating values
hossam-nasr Jun 19, 2024
59cafa7
fix create and deploy tests
hossam-nasr Jun 19, 2024
f7ec880
run only long running tests
hossam-nasr Jun 19, 2024
352b88a
remove the prompt for programming model version from v2
hossam-nasr Jun 19, 2024
d3e8689
test only create new project
hossam-nasr Jun 19, 2024
d1c4c6e
try fixing create new project tests
hossam-nasr Jun 20, 2024
13e7ac5
try installing java thru the pipeline
hossam-nasr Jun 20, 2024
40481b5
try again
hossam-nasr Jun 20, 2024
7ee8b14
specify input for F# too
hossam-nasr Jun 20, 2024
38336f8
try installing java again
hossam-nasr Jun 20, 2024
8752d72
try with windows-latest vmImage
hossam-nasr Jun 20, 2024
58c5c7e
try new pool
hossam-nasr Jun 20, 2024
00ccf31
give up on installing java for now
hossam-nasr Jun 20, 2024
58fe937
try all tests again
hossam-nasr Jun 20, 2024
3ab1aae
test
hossam-nasr Jun 20, 2024
b06208e
install java
hossam-nasr Jun 20, 2024
08073d9
try different pool
hossam-nasr Jun 21, 2024
f329fc8
try 2019?
hossam-nasr Jun 21, 2024
2576cb4
2017?
hossam-nasr Jun 21, 2024
0db8311
try creating new EventGrid tests
hossam-nasr Jun 25, 2024
3825d4a
remove the preinstall stage
hossam-nasr Jun 25, 2024
06584da
remove deprecated runtime tests
hossam-nasr Jun 25, 2024
2998db9
remove unnecessary eventgrid tests
hossam-nasr Jun 25, 2024
8012123
try only create function tests
hossam-nasr Jun 25, 2024
da8c26b
remove deprecated language versions
hossam-nasr Jun 25, 2024
3e20eed
add prompt for python prog model
hossam-nasr Jun 25, 2024
c5ceabb
try only Python tests
hossam-nasr Jun 25, 2024
a9d7ced
try all again
hossam-nasr Jun 25, 2024
664e76d
use python 3.8
hossam-nasr Jun 25, 2024
c129c73
use python 3.9
hossam-nasr Jun 25, 2024
f369b37
test only python tests again
hossam-nasr Jun 25, 2024
2cdc9d6
try fix with only create and deploy tests
hossam-nasr Jun 25, 2024
95b3a2f
remove deprecated Create API test
hossam-nasr Jun 25, 2024
d00cf3c
add subscription name step
hossam-nasr Jun 25, 2024
284a38b
remove subscription name step
hossam-nasr Jun 25, 2024
13a497d
try removing function.json line
hossam-nasr Jun 25, 2024
7280626
add model v4 and model v2 tests and test only create new project
hossam-nasr Jun 26, 2024
cb304a5
Revert "add model v4 and model v2 tests and test only create new proj…
hossam-nasr Jun 26, 2024
1d9bdef
try all tests again (sanity check)
hossam-nasr Jun 26, 2024
453c677
remove comment on line
hossam-nasr Jun 26, 2024
14fffba
fix package
hossam-nasr Jul 10, 2024
60d2723
merge fix
hossam-nasr Jul 10, 2024
9061fd3
update chokidar
hossam-nasr Jul 10, 2024
836b223
fix deploy tests
hossam-nasr Jul 10, 2024
ecb1a84
Merge branch 'main' into hossamnasr/fix-e2e-tests
hossam-nasr Jul 10, 2024
20a1d9d
use python 3.9
hossam-nasr Jul 10, 2024
f0c10d2
remove C# script tests
hossam-nasr Jul 10, 2024
d2245d2
disable Java and Ballerina tests for now
hossam-nasr Jul 10, 2024
f2c697a
try re-enabling .NET 3.1 tests
hossam-nasr Jul 10, 2024
8c52862
fix subpath issue
hossam-nasr Jul 10, 2024
5992ae4
apply fix for expected patterns too
hossam-nasr Jul 10, 2024
3eaf5b5
try .NET framework?
hossam-nasr Jul 10, 2024
4547ba2
clean up
hossam-nasr Jul 10, 2024
e597c66
add .NET 8.0 create function test
hossam-nasr Jul 10, 2024
768f007
return timeout to normal
hossam-nasr Jul 10, 2024
da44bbb
remove extra logging statement
hossam-nasr Jul 10, 2024
41a9139
remove unnecessary comment
hossam-nasr Jul 10, 2024
2d2fa94
endgame
hossam-nasr Jul 10, 2024
db8daaa
remove .NET 8 from create function tests
hossam-nasr Jul 10, 2024
a3ac625
add issue reference in disabling java tests comment
hossam-nasr Jul 16, 2024
a7e0eb3
use constant for input
hossam-nasr Jul 16, 2024
f579c9a
update comments
hossam-nasr Jul 16, 2024
25b763e
fix typo
hossam-nasr Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,898 changes: 2,209 additions & 9,689 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions test/createFunction/createFunction.Ballerina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ class BallerinaFunctionTester extends FunctionTesterBase {
}
}

for (const version of [FuncVersion.v2, FuncVersion.v3, FuncVersion.v4]) {
for (const source of backupLatestTemplateSources) {
addSuite(new BallerinaFunctionTester(version, source));
}
for (const source of backupLatestTemplateSources) {
addSuite(new BallerinaFunctionTester(FuncVersion.v4, source));
}


function addSuite(tester: FunctionTesterBase): void {
const testCases: CreateFunctionTestCase[] = [
{
Expand Down
26 changes: 1 addition & 25 deletions test/createFunction/createFunction.CSharp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

import { AzExtFsExtra } from '@microsoft/vscode-azext-utils';
import * as path from 'path';
import * as vscode from 'vscode';
import { durableUtils, FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting, type TemplateSource } from '../../extension.bundle';
import { durableUtils, FuncVersion, ProjectLanguage, type TemplateSource } from '../../extension.bundle';
import { backupLatestTemplateSources, isLongRunningVersion } from '../global.test';
import { getRotatingAuthLevel } from '../nightly/getRotatingValue';
import { runWithFuncSetting } from '../runWithSetting';
import { FunctionTesterBase, type CreateFunctionTestCase } from './FunctionTesterBase';

class CSharpFunctionTester extends FunctionTesterBase {
Expand Down Expand Up @@ -42,8 +40,6 @@ class CSharpFunctionTester extends FunctionTesterBase {
}

for (const source of backupLatestTemplateSources) {
addSuite(FuncVersion.v2, 'netcoreapp2.1', source);
addSuite(FuncVersion.v3, 'netcoreapp3.1', source);
addSuite(FuncVersion.v4, 'net6.0', source, true);
addSuite(FuncVersion.v4, 'net6.0', source, false);
addSuite(FuncVersion.v4, 'net7.0', source, true);
Expand Down Expand Up @@ -173,25 +169,5 @@ function addSuite(version: FuncVersion, targetFramework: string, source: Templat
timeoutMS: 60 * 1000,
isLongRunning: isLongRunningVersion(version),
suppressParallel: true, // lots of errors like "The process cannot access the file because it is being used by another process" 😢
addTests: () => {
if (version === FuncVersion.v2) {
// https://github.com/Microsoft/vscode-azurefunctions/blob/main/docs/api.md#create-local-function
test('createFunction API (deprecated)', async () => {
// Intentionally testing IoTHub trigger since a partner team plans to use that
const templateId: string = 'Azure.Function.CSharp.IotHubTrigger.2.x';
const functionName: string = 'createFunctionApi';
const namespace: string = 'TestCompany.TestFunction';
const iotPath: string = 'messages/events';
const connection: string = 'IoTHub_Setting';
await runWithFuncSetting(projectLanguageSetting, ProjectLanguage.CSharp, async () => {
await runWithFuncSetting(funcVersionSetting, FuncVersion.v2, async () => {
// Intentionally testing weird casing
await vscode.commands.executeCommand('azureFunctions.createFunction', tester.projectPath, templateId, functionName, { namEspace: namespace, PaTh: iotPath, ConneCtion: connection });
});
});
await tester.validateFunction(tester.projectPath, functionName, [namespace, iotPath, connection]);
});
}
}
});
}
103 changes: 0 additions & 103 deletions test/createFunction/createFunction.CSharpScript.test.ts

This file was deleted.

14 changes: 7 additions & 7 deletions test/createFunction/createFunction.Script.v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ class PowerShellFunctionTester extends FunctionTesterBase {
}
}

for (const version of [FuncVersion.v2, FuncVersion.v3, FuncVersion.v4]) {
for (const source of backupLatestTemplateSources) {
addSuite(new JavaScriptFunctionTester(version, source));
addSuite(new TypeScriptFunctionTester(version, source));
addSuite(new PythonFunctionTester(version, source));
addSuite(new PowerShellFunctionTester(version, source));
}

for (const source of backupLatestTemplateSources) {
addSuite(new JavaScriptFunctionTester(FuncVersion.v4, source));
addSuite(new TypeScriptFunctionTester(FuncVersion.v4, source));
addSuite(new PythonFunctionTester(FuncVersion.v4, source));
addSuite(new PowerShellFunctionTester(FuncVersion.v4, source));
}


function addSuite(tester: FunctionTesterBase): void {
const testCases: CreateFunctionTestCase[] = [
{
Expand Down
25 changes: 13 additions & 12 deletions test/nightly/createProjectAndDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as vscode from 'vscode';
import { FuncVersion, copyFunctionUrl, createGenericClient, createNewProjectInternal, deployProductionSlot, getRandomHexString, nonNullProp } from '../../extension.bundle';
import { addParallelSuite, runInSeries, type ParallelTest } from '../addParallelSuite';
import { getTestWorkspaceFolder } from '../global.test';
import { defaultTestFuncVersion, getBallerinaValidateOptions, getCSharpValidateOptions, getJavaScriptValidateOptions, getPowerShellValidateOptions, getPythonValidateOptions, getTypeScriptValidateOptions, validateProject, type IValidateProjectOptions } from '../project/validateProject';
import { defaultTestFuncVersion, getCSharpValidateOptions, getJavaScriptValidateOptions, getPowerShellValidateOptions, getPythonValidateOptions, getTypeScriptValidateOptions, validateProject, type IValidateProjectOptions } from '../project/validateProject';
import { getRotatingAuthLevel, getRotatingLocation, getRotatingNodeVersion, getRotatingPythonVersion } from './getRotatingValue';
import { resourceGroupsToDelete } from './global.nightly.test';

Expand All @@ -23,14 +23,15 @@ interface CreateProjectAndDeployTestCase extends ICreateProjectAndDeployOptions
}

const testCases: CreateProjectAndDeployTestCase[] = [
{ title: 'JavaScript', ...getJavaScriptValidateOptions(true), deployInputs: [getRotatingNodeVersion()] },
{ title: 'TypeScript', ...getTypeScriptValidateOptions(), deployInputs: [getRotatingNodeVersion()] },
{ title: 'Ballerina', ...getBallerinaValidateOptions(), deployInputs: [/java.*11/i] },
// All C# tests on mac and .NET 6 on windows are consistently timing out for some unknown reason. Will skip for now
{ title: 'C# .NET Core 3.1', buildMachineOsToSkip: 'darwin', ...getCSharpValidateOptions('netcoreapp3.1'), createProjectInputs: [/net.*3/i], deployInputs: [/net.*3/i], createFunctionInputs: ['Company.Function'] },
{ title: 'C# .NET 6', buildMachineOsToSkip: ['darwin', 'win32'], ...getCSharpValidateOptions('net6.0', FuncVersion.v4), createProjectInputs: [/net.*6/i], deployInputs: [/net.*6/i], createFunctionInputs: ['Company.Function'] },
{ title: 'PowerShell', ...getPowerShellValidateOptions(), deployInputs: [/powershell.*7/i] },
{ title: 'Python', buildMachineOsToSkip: 'win32', ...getPythonValidateOptions('.venv'), createProjectInputs: [/3\.7/], deployInputs: [getRotatingPythonVersion()] }
{ title: 'JavaScript', ...getJavaScriptValidateOptions(true), createProjectInputs: [/Model V3/], deployInputs: [getRotatingNodeVersion()] },
{ title: 'TypeScript', ...getTypeScriptValidateOptions(), createProjectInputs: [/Model V3/], deployInputs: [getRotatingNodeVersion()] },
// Temporarily disable Ballerina tests until we can install Ballerina on the new pipelines
// https://github.com/microsoft/vscode-azurefunctions/issues/4210
// { title: 'Ballerina', ...getBallerinaValidateOptions(), createProjectInputs: ["JVM"], deployInputs: [/java.*11/i] },
{ title: 'C# .NET Framework', buildMachineOsToSkip: 'darwin', ...getCSharpValidateOptions('net48'), createProjectInputs: [/net.*Framework/i], deployInputs: [/net.*Framework/i], createFunctionInputs: ['Company.Function'] },
{ title: 'C# .NET 8', ...getCSharpValidateOptions('net8.0', FuncVersion.v4), createProjectInputs: [/net.*8/i], deployInputs: [/net.*8/i], createFunctionInputs: ['Company.Function'] },
{ title: 'PowerShell', ...getPowerShellValidateOptions(), deployInputs: [/powershell.*7.4/i] },
{ title: 'Python', ...getPythonValidateOptions('.venv'), createProjectInputs: [/Model V1/, /3\.9/], deployInputs: [getRotatingPythonVersion()] }
]

const parallelTests: ParallelTest[] = [];
Expand Down Expand Up @@ -102,8 +103,7 @@ async function addRoutePrefixToProject(testWorkspacePath: string, routePrefix: s
}

async function validateFunctionUrl(appName: string, functionName: string, routePrefix: string): Promise<void> {
// first input matches any item except local project (aka it should match the test subscription)
const inputs: (string | RegExp)[] = [/^((?!Local Project).)*$/i, appName, functionName];
const inputs: (string | RegExp)[] = [appName, functionName];

let functionUrl: string | undefined;
await runWithTestActionContext('copyFunctionUrl', async context => {
Expand All @@ -119,7 +119,8 @@ async function validateFunctionUrl(appName: string, functionName: string, routeP
assert.ok(functionUrl?.includes(routePrefix), `Function url "${functionUrl}" did not include routePrefix "${routePrefix}".`);

const client: ServiceClient = await createGenericClient(await createTestActionContext(), undefined);
const response = await client.sendRequest(createPipelineRequest({ method: 'POST', url: functionUrl!, body: JSON.stringify({ name: "World" }) }));
// PowerShell functions expect Name capitalized, so we set both
const response = await client.sendRequest(createPipelineRequest({ method: 'POST', url: functionUrl!, body: JSON.stringify({ name: "World", Name: "World" }) }));
const body: string = nonNullProp(response, 'bodyAsText');
assert.ok((body.includes('Hello') && body.includes('World')) || body.includes('Welcome'), 'Expected function response to include "Hello World" or "Welcome"');
}
32 changes: 6 additions & 26 deletions test/nightly/functionAppOperations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

import { type Site } from '@azure/arm-appservice';
import { tryGetWebApp } from '@microsoft/vscode-azext-azureappservice';
import { runWithInputs, runWithTestActionContext } from '@microsoft/vscode-azext-dev';
import { runWithTestActionContext } from '@microsoft/vscode-azext-dev';
import * as assert from 'assert';
import * as vscode from 'vscode';
import { DialogResponses, ProjectLanguage, createFunctionAppAdvanced, deleteFunctionApp, getRandomHexString, registerOnActionStartHandler } from '../../extension.bundle';
import { DialogResponses, createFunctionAppAdvanced, deleteFunctionApp, getRandomHexString } from '../../extension.bundle';
import { cleanTestWorkspace, longRunningTestsEnabled } from '../global.test';
import { runWithFuncSetting } from '../runWithSetting';
import { getRotatingLocation, getRotatingNodeVersion } from './getRotatingValue';
import { resourceGroupsToDelete, subscriptionContext, testClient } from './global.nightly.test';
import { getRotatingLocation } from './getRotatingValue';
import { resourceGroupsToDelete, testClient } from './global.nightly.test';

suite('Function App Operations', function (this: Mocha.Suite): void {
this.timeout(7 * 60 * 1000);
Expand Down Expand Up @@ -42,7 +40,7 @@ suite('Function App Operations', function (this: Mocha.Suite): void {
});

test('Create - Advanced', async () => {
const testInputs: (string | RegExp)[] = [appName, /\.net/i, 'Windows', '$(plus) Create new resource group', rgName, location, 'Consumption', '$(plus) Create new storage account', saName, '$(plus) Create new Application Insights resource', aiName];
const testInputs: (string | RegExp)[] = [appName, 'Consumption', location, /\.net/i, 'Windows', '$(plus) Create new resource group', rgName, '$(plus) Create new storage account', saName, '$(plus) Create new Application Insights resource', aiName];
hossam-nasr marked this conversation as resolved.
Show resolved Hide resolved
await runWithTestActionContext('createFunctionAppAdvanced', async context => {
await context.ui.runWithInputs(testInputs, async () => {
await createFunctionAppAdvanced(context);
Expand All @@ -53,7 +51,7 @@ suite('Function App Operations', function (this: Mocha.Suite): void {
});

test('Create - Advanced - Existing RG/SA/AI', async () => {
const testInputs: (string | RegExp)[] = [app2Name, /\.net/i, 'Windows', rgName, location, 'Consumption', saName, aiName];
const testInputs: (string | RegExp)[] = [app2Name, 'Consumption', location, /\.net/i, 'Windows', rgName, saName, aiName];
await runWithTestActionContext('createFunctionAppAdvanced', async context => {
await context.ui.runWithInputs(testInputs, async () => {
await createFunctionAppAdvanced(context);
Expand All @@ -63,24 +61,6 @@ suite('Function App Operations', function (this: Mocha.Suite): void {
assert.ok(createdApp);
});

// https://github.com/Microsoft/vscode-azurefunctions/blob/main/docs/api.md#create-function-app
test('Create - API (deprecated)', async () => {
const apiRgName: string = getRandomHexString();
resourceGroupsToDelete.push(apiRgName);
const apiAppName: string = getRandomHexString();
const inputs = [apiAppName, getRotatingNodeVersion(), getRotatingLocation()];
const commandId = 'azureFunctions.createFunctionApp';

await runWithFuncSetting('projectLanguage', ProjectLanguage.JavaScript, async () => {
await runWithInputs(commandId, inputs, registerOnActionStartHandler, async () => {
const actualFuncAppId: string = <string>await vscode.commands.executeCommand(commandId, subscriptionContext.subscriptionId, apiRgName);
const site: Site | undefined = await tryGetWebApp(testClient, apiRgName, apiAppName);
assert.ok(site);
assert.equal(actualFuncAppId, site.id);
});
});
});

test('Delete', async () => {
await runWithTestActionContext('deleteFunctionApp', async context => {
await context.ui.runWithInputs([appName, DialogResponses.deleteResponse.title, DialogResponses.yes.title], async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/nightly/getRotatingValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export function getRotatingLocation(): string {
}

let nodeVersionCount: number = getStartingIndex();
const nodeVersions: RegExp[] = [/node.*12/i, /node.*14/i];
const nodeVersions: RegExp[] = [/node.*18/i, /node.*20/i];
export function getRotatingNodeVersion(): RegExp {
nodeVersionCount += 1;
return nodeVersions[nodeVersionCount % nodeVersions.length];
}

let pyVersionCount: number = getStartingIndex();
const pyVersions: RegExp[] = [/python.*3\.7/i, /python.*3\.8/i, /python.*3\.9/i];
const pyVersions: RegExp[] = [/python.*3\.8/i, /python.*3\.9/i, /python.*3\.10/i, /python.*3\.11/i];
export function getRotatingPythonVersion(): RegExp {
pyVersionCount += 1;
return pyVersions[pyVersionCount % pyVersions.length];
Expand Down
Loading
Loading