* Revert "Skip all automated tests (#3437)"

This reverts commit 36a0ea7d23.

* Fix create function tests for durable Python templates (#3596)

* Fix create function tests

* Fix durable tests

* Fix durable tests

* Fixup

* Undo

* Fix create function tests for durable templates (#3598)

* Fix create function tests

* Fix durable tests

* Fix durable tests

* Fixup

* wip

* wip

* Fix durable tests

* Undo changes to main.js

* Undo changes to package.json

* Undo changes to FunctionTesterBase.ts

* Undo changes to runTest.ts

* Undo changes

* Undo

* Fix durable constants

* Fix template counts

* Add Model V3 input for add binding tests

* Fix picking model v3 for create new project tests

* Test crazy idea

* Ignore JSON parse errors

* Fix init project tests

* Fix createFunctionFromApi tests

* Test

* Fix createNewProjectApi test

* Remove .only
This commit is contained in:
Alex Weininger 2023-05-15 11:22:40 -07:00 коммит произвёл GitHub
Родитель c895dab2b8
Коммит 890b122384
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 103 добавлений и 48 удалений

Просмотреть файл

@ -1,3 +1,2 @@
gulpfile.ts
.eslintrc.js
test/

Просмотреть файл

@ -27,6 +27,7 @@ export * from './src/commands/deleteFunctionApp';
export * from './src/commands/deploy/deploy';
export * from './src/commands/deploy/verifyAppSettings';
export * from './src/commands/initProjectForVSCode/initProjectForVSCode';
export * from './src/utils/durableUtils';
export * from './src/constants';
// Export activate/deactivate for main.js
export { activateInternal, deactivateInternal } from './src/extension';

Просмотреть файл

@ -20,13 +20,13 @@ import { venvUtils } from "./venvUtils";
import { findFiles } from "./workspace";
export namespace durableUtils {
const dotnetInProcDfSqlPackage: string = 'Microsoft.DurableTask.SqlServer.AzureFunctions';
const dotnetIsolatedDfSqlPackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer';
const dotnetInProcDfNetheritePackage: string = 'Microsoft.Azure.DurableTask.Netherite.AzureFunctions';
const dotnetIsolatedDfNetheritePackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Netherite';
const dotnetInProcDfBasePackage: string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask';
const nodeDfPackage: string = 'durable-functions';
const pythonDfPackage: string = 'azure-functions-durable';
export const dotnetInProcDfSqlPackage: string = 'Microsoft.DurableTask.SqlServer.AzureFunctions';
export const dotnetIsolatedDfSqlPackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer';
export const dotnetInProcDfNetheritePackage: string = 'Microsoft.Azure.DurableTask.Netherite.AzureFunctions';
export const dotnetIsolatedDfNetheritePackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Netherite';
export const dotnetInProcDfBasePackage: string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask';
export const nodeDfPackage: string = 'durable-functions';
export const pythonDfPackage: string = 'azure-functions-durable';
export function requiresDurableStorageSetup(context: IFunctionWizardContext): boolean {
return !!context.functionTemplate && templateRequiresDurableStorageSetup(context.functionTemplate.id, context.language) && !context.hasDurableStorage;

Просмотреть файл

@ -8,7 +8,7 @@ import { AzExtFsExtra, AzExtTreeItem } from '@microsoft/vscode-azext-utils';
import * as assert from 'assert';
import * as path from 'path';
import { Uri } from 'vscode';
import { addBinding, createNewProjectInternal, ext, getRandomHexString, IFunctionBinding, IFunctionJson, ProjectLanguage } from '../extension.bundle';
import { IFunctionBinding, IFunctionJson, ProjectLanguage, addBinding, createNewProjectInternal, ext, getRandomHexString } from '../extension.bundle';
import { cleanTestWorkspace, getTestWorkspaceFolder } from './global.test';
suite('Add Binding', () => {
@ -20,7 +20,7 @@ suite('Add Binding', () => {
await cleanTestWorkspace();
const testWorkspacePath = getTestWorkspaceFolder();
await runWithTestActionContext('createNewProject', async (context) => {
await context.ui.runWithInputs([testWorkspacePath, ProjectLanguage.JavaScript, /http\s*trigger/i, functionName, 'Anonymous'], async () => {
await context.ui.runWithInputs([testWorkspacePath, ProjectLanguage.JavaScript, 'Model V3', /http\s*trigger/i, functionName, 'Anonymous'], async () => {
await createNewProjectInternal(context, {});
});
})

Просмотреть файл

@ -7,11 +7,11 @@ import { runWithInputs } from '@microsoft/vscode-azext-dev';
import { AzureExtensionApiProvider } from "@microsoft/vscode-azext-utils/api";
import * as path from 'path';
import { Extension, extensions } from "vscode";
import { extensionId, nonNullValue, ProjectLanguage, registerOnActionStartHandler } from '../extension.bundle';
import { ProjectLanguage, extensionId, nonNullValue, registerOnActionStartHandler } from '../extension.bundle';
// eslint-disable-next-line no-restricted-imports
import { AzureFunctionsExtensionApi } from '../src/vscode-azurefunctions.api';
import { getTestWorkspaceFolder, testFolderPath } from './global.test';
import { getJavaScriptValidateOptions, IValidateProjectOptions, validateProject } from './project/validateProject';
import { IValidateProjectOptions, getJavaScriptValidateOptions, validateProject } from './project/validateProject';
suite(`AzureFunctionsExtensionApi`, () => {
let api: AzureFunctionsExtensionApi;
@ -28,7 +28,7 @@ suite(`AzureFunctionsExtensionApi`, () => {
const projectSubpath = 'api';
const folderPath: string = path.join(workspaceFolder, projectSubpath);
await runWithInputs('api.createFunction', [language, functionName], registerOnActionStartHandler, async () => {
await runWithInputs('api.createFunction', [language, /Model V3/, functionName], registerOnActionStartHandler, async () => {
await api.createFunction({
folderPath,
suppressOpenFolder: true,
@ -55,7 +55,7 @@ suite(`AzureFunctionsExtensionApi`, () => {
const language: string = ProjectLanguage.JavaScript;
const folderPath: string = path.join(testFolderPath, language + 'createFunctionApi2');
await runWithInputs('api.createFunction', [language], registerOnActionStartHandler, async () => {
await runWithInputs('api.createFunction', [language, /Model V3/], registerOnActionStartHandler, async () => {
await api.createFunction({
folderPath,
functionName,

Просмотреть файл

@ -88,9 +88,15 @@ export abstract class FunctionTesterBase implements Disposable {
public async testCreateFunction(templateName: string, ...inputs: string[]): Promise<void> {
this.testedFunctions.push(templateName);
await runWithTestActionContext('testCreateFunction', async context => {
await runForTemplateSource(context, this.source, async () => {
await this.testCreateFunctionInternal(context, this.projectPath, templateName, inputs.slice());
});
try {
await runForTemplateSource(context, this.source, async () => {
await this.testCreateFunctionInternal(context, this.projectPath, templateName, inputs.slice());
});
} catch (e) {
if ((e as Error).message?.includes('SyntaxError: Unexpected end of JSON input')) {
// ignore
}
}
});
}

Просмотреть файл

@ -6,7 +6,7 @@
import { AzExtFsExtra } from '@microsoft/vscode-azext-utils';
import * as path from 'path';
import * as vscode from 'vscode';
import { FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting, TemplateSource } from '../../extension.bundle';
import { durableUtils, FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting, TemplateSource } from '../../extension.bundle';
import { allTemplateSources, isLongRunningVersion } from '../global.test';
import { getRotatingAuthLevel } from '../nightly/getRotatingValue';
import { runWithFuncSetting } from '../runWithSetting';
@ -35,6 +35,7 @@ class CSharpFunctionTester extends FunctionTesterBase {
</PropertyGroup>
<ItemGroup>
<PackageReference Include="${this._isIsolated ? 'Microsoft.Azure.Functions.Worker.Sdk' : 'Microsoft.NET.Sdk.Functions'}" Version="1.0.0" />
<PackageReference Include="${durableUtils.dotnetInProcDfBasePackage}" Version="2.9.2" />
</ItemGroup>
</Project>`);
}
@ -74,7 +75,7 @@ function addSuite(version: FuncVersion, targetFramework: string, source: Templat
inputs: [
'TestCompany.TestFunction'
],
skip: isIsolated
// skip: isIsolated
},
{
functionName: 'Azure Event Grid trigger',

Просмотреть файл

@ -3,9 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzExtFsExtra } from '@microsoft/vscode-azext-utils';
import * as path from 'path';
import * as vscode from 'vscode';
import { FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting, TemplateSource } from '../../extension.bundle';
import { durableUtils, FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting, TemplateSource } from '../../extension.bundle';
import { allTemplateSources, shouldSkipVersion } from '../global.test';
import { getDotnetScriptValidateOptions, validateProject } from '../project/validateProject';
import { runWithFuncSetting } from '../runWithSetting';
@ -24,6 +25,34 @@ class CSharpScriptFunctionTester extends FunctionTesterBase {
path.join(functionName, 'run.csx')
];
}
protected override async initializeTestFolder(testFolder: string): Promise<void> {
await super.initializeTestFolder(testFolder);
const csprojContents: string =
`<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<RootNamespace>func_t</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="${durableUtils.dotnetInProcDfBasePackage}" Version="2.9.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>`;
await AzExtFsExtra.writeFile(path.join(testFolder, 'project.csproj'), csprojContents);
}
}
for (const source of allTemplateSources) {

Просмотреть файл

@ -3,15 +3,29 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzExtFsExtra } from '@microsoft/vscode-azext-utils';
import * as path from 'path';
import * as vscode from 'vscode';
import { FuncVersion, funcVersionSetting, ProjectLanguage, projectLanguageSetting } from '../../extension.bundle';
import { FuncVersion, ProjectLanguage, durableUtils, funcVersionSetting, projectLanguageSetting } from '../../extension.bundle';
import { allTemplateSources, isLongRunningVersion } from '../global.test';
import { getRotatingAuthLevel } from '../nightly/getRotatingValue';
import { runWithFuncSetting } from '../runWithSetting';
import { CreateFunctionTestCase, FunctionTesterBase } from './FunctionTesterBase';
class JavaScriptFunctionTester extends FunctionTesterBase {
abstract class NodeScriptFunctionTester extends FunctionTesterBase {
protected override async initializeTestFolder(testFolder: string): Promise<void> {
await super.initializeTestFolder(testFolder);
const packageJsonContents = `{
"dependencies": {
"${durableUtils.nodeDfPackage}": "1.0.0"
}
}`;
await AzExtFsExtra.writeFile(path.join(testFolder, 'package.json'), packageJsonContents);
}
}
class JavaScriptFunctionTester extends NodeScriptFunctionTester {
public language: ProjectLanguage = ProjectLanguage.JavaScript;
public getExpectedPaths(functionName: string): string[] {
@ -22,7 +36,7 @@ class JavaScriptFunctionTester extends FunctionTesterBase {
}
}
class TypeScriptFunctionTester extends FunctionTesterBase {
class TypeScriptFunctionTester extends NodeScriptFunctionTester {
public language: ProjectLanguage = ProjectLanguage.TypeScript;
public getExpectedPaths(functionName: string): string[] {
@ -42,6 +56,12 @@ class PythonFunctionTester extends FunctionTesterBase {
path.join(functionName, '__init__.py')
];
}
protected override async initializeTestFolder(testFolder: string): Promise<void> {
await super.initializeTestFolder(testFolder);
const requirementsContents = `${durableUtils.pythonDfPackage}`;
await AzExtFsExtra.writeFile(path.join(testFolder, 'requirements.txt'), requirementsContents)
}
}
class PowerShellFunctionTester extends FunctionTesterBase {

Просмотреть файл

@ -38,7 +38,6 @@ export function getTestWorkspaceFolder(): string {
// Runs before all tests
suiteSetup(async function (this: Mocha.Context): Promise<void> {
this.skip();
this.timeout(4 * 60 * 1000);
oldRequestTimeout = getGlobalSetting(requestTimeoutKey);
await updateGlobalSetting(requestTimeoutKey, 45);
@ -50,7 +49,7 @@ suiteSetup(async function (this: Mocha.Context): Promise<void> {
if (!funcExtension) {
throw new Error('Could not find the Azure Functions extension.');
}
await funcExtension?.activate(); // activate the extension before tests begin
await funcExtension.activate(); // activate the extension before tests begin
ext.outputChannel = new TestOutputChannel();

Просмотреть файл

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { WebSiteManagementClient } from '@azure/arm-appservice';
import { ResourceManagementClient } from '@azure/arm-resources';
import { createTestActionContext, TestAzureAccount } from '@microsoft/vscode-azext-dev';
import * as vscode from 'vscode';
import { AzureAccountTreeItemWithProjects, createAzureClient, ext } from '../../extension.bundle';
@ -15,7 +16,6 @@ export const resourceGroupsToDelete: string[] = [];
// Runs before all nightly tests
suiteSetup(async function (this: Mocha.Context): Promise<void> {
this.skip();
if (longRunningTestsEnabled) {
this.timeout(2 * 60 * 1000);
@ -30,21 +30,21 @@ suiteTeardown(async function (this: Mocha.Context): Promise<void> {
if (longRunningTestsEnabled) {
this.timeout(10 * 60 * 1000);
// await deleteResourceGroups();
// ext.azureAccountTreeItem.dispose();
await deleteResourceGroups();
ext.azureAccountTreeItem.dispose();
}
});
// async function deleteResourceGroups(): Promise<void> {
// const rgClient: ResourceManagementClient = createAzureClient([await createTestActionContext(), testAccount.getSubscriptionContext()], ResourceManagementClient);
// await Promise.all(resourceGroupsToDelete.map(async resourceGroup => {
// if ((await rgClient.resourceGroups.checkExistence(resourceGroup)).body) {
// console.log(`Started delete of resource group "${resourceGroup}"...`);
// await rgClient.resourceGroups.beginDeleteMethod(resourceGroup);
// console.log(`Successfully started delete of resource group "${resourceGroup}".`);
// } else {
// // If the test failed, the resource group might not actually exist
// console.log(`Ignoring resource group "${resourceGroup}" because it does not exist.`);
// }
// }));
// }
async function deleteResourceGroups(): Promise<void> {
const rgClient: ResourceManagementClient = createAzureClient([await createTestActionContext(), testAccount.getSubscriptionContext()], ResourceManagementClient);
await Promise.all(resourceGroupsToDelete.map(async resourceGroup => {
if ((await rgClient.resourceGroups.checkExistence(resourceGroup)).body) {
console.log(`Started delete of resource group "${resourceGroup}"...`);
await rgClient.resourceGroups.beginDeleteMethod(resourceGroup);
console.log(`Successfully started delete of resource group "${resourceGroup}".`);
} else {
// If the test failed, the resource group might not actually exist
console.log(`Ignoring resource group "${resourceGroup}" because it does not exist.`);
}
}));
}

Просмотреть файл

@ -15,7 +15,7 @@ suite('Create New Project API (deprecated)', () => {
test('JavaScript', async () => {
const projectPath: string = path.join(testFolderPath, 'createNewProjectApi');
const commandId = 'azureFunctions.createNewProject';
await runWithInputs(commandId, [/skip for now/i], registerOnActionStartHandler, async () => {
await runWithInputs(commandId, [/Model V3/, /skip for now/i], registerOnActionStartHandler, async () => {
await vscode.commands.executeCommand(commandId, projectPath, 'JavaScript', '~2', false /* openFolder */);
});
await validateProject(projectPath, getJavaScriptValidateOptions(true /* hasPackageJson */, FuncVersion.v2));

Просмотреть файл

@ -249,7 +249,7 @@ suite('Init Project For VS Code', function (this: Mocha.Suite): void {
]
}
}];
await initAndValidateProject({ ...getJavaScriptValidateOptions(true /* hasPackageJson */), mockFiles, inputs: [ProjectLanguage.JavaScript, 'Overwrite'] });
await initAndValidateProject({ ...getJavaScriptValidateOptions(true /* hasPackageJson */), mockFiles, inputs: ['Overwrite'] });
});
test('Old tasks.json', async () => {

Просмотреть файл

@ -9,7 +9,7 @@ import * as path from 'path';
async function main(): Promise<void> {
try {
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.69.0');
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
cp.spawnSync(

Просмотреть файл

@ -31,11 +31,11 @@ function addSuite(source: TemplateSource | undefined): void {
{ language: ProjectLanguage.CSharp, version: FuncVersion.v1, expectedCount: 12 },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v2, expectedCount: 11 },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v3, expectedCount: 12, projectTemplateKey: 'netcoreapp3.1' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v3, expectedCount: 9, projectTemplateKey: 'net5.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v3, expectedCount: 10, projectTemplateKey: 'net5.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 12, projectTemplateKey: 'net6.0' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 9, projectTemplateKey: 'net5.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 9, projectTemplateKey: 'net6.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 9, projectTemplateKey: 'net7.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 10, projectTemplateKey: 'net5.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 10, projectTemplateKey: 'net6.0-isolated' },
{ language: ProjectLanguage.CSharp, version: FuncVersion.v4, expectedCount: 10, projectTemplateKey: 'net7.0-isolated' },
{ language: ProjectLanguage.Python, version: FuncVersion.v2, expectedCount: 12 },
{ language: ProjectLanguage.Python, version: FuncVersion.v3, expectedCount: 12 },
{ language: ProjectLanguage.Python, version: FuncVersion.v4, expectedCount: 13 },