Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 changes: 9 additions & 2 deletions DotNetWorker.Extensions.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
# Visual Studio Version 18
VisualStudioVersion = 18.1.11312.151 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{FD7243E4-BF18-43F8-8744-BA1D17ACF378}"
EndProject
Expand Down Expand Up @@ -82,6 +82,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Timer.Tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Worker.Extensions.Http.AspNetCore.Analyzers", "extensions\Worker.Extensions.Http.AspNetCore.Analyzers\src\Worker.Extensions.Http.AspNetCore.Analyzers.csproj", "{914B3E60-DE19-4827-956F-22080C817820}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E2EAspNetCoreApp", "test\E2ETests\E2EApps\E2EAspNetCoreApp\E2EAspNetCoreApp.csproj", "{2A48230E-525D-9ECE-0B98-67417F8AC4F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -204,6 +206,10 @@ Global
{914B3E60-DE19-4827-956F-22080C817820}.Debug|Any CPU.Build.0 = Debug|Any CPU
{914B3E60-DE19-4827-956F-22080C817820}.Release|Any CPU.ActiveCfg = Release|Any CPU
{914B3E60-DE19-4827-956F-22080C817820}.Release|Any CPU.Build.0 = Release|Any CPU
{2A48230E-525D-9ECE-0B98-67417F8AC4F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A48230E-525D-9ECE-0B98-67417F8AC4F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A48230E-525D-9ECE-0B98-67417F8AC4F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A48230E-525D-9ECE-0B98-67417F8AC4F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -239,6 +245,7 @@ Global
{B6342174-5436-4846-B43C-39D8E34AE5CF} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{6947034E-C97F-4F78-940F-B6A398E23C9C} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{914B3E60-DE19-4827-956F-22080C817820} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
{2A48230E-525D-9ECE-0B98-67417F8AC4F5} = {0EA6A975-2934-4837-9932-2328EFE23BFD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {497D2ED4-A13E-4BCA-8D29-F30CA7D0EA4A}
Expand Down
52 changes: 52 additions & 0 deletions eng/ci/templates/steps/install-core-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
steps:
- pwsh: |
$ErrorActionPreference = 'Stop'
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()

if ($IsWindows) {
$os = "win"
}
elseif ($IsMacOS) {
$os = "osx"
}
else {
$os = "linux"
}

# GitHub API call for latest release
$releaseInfo = Invoke-RestMethod -Uri "https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest" -Headers @{ "User-Agent" = "PowerShell" }

$version = $releaseInfo.tag_name
Write-Host "Latest Core Tools version: $version"

# Look for zip file matching os and arch
$pattern = "Azure\.Functions\.Cli\.$os-$arch\..*\.zip$"
$asset = $releaseInfo.assets | Where-Object { $_.name -match $pattern }

if (-not $asset) {
Write-Error "Could not find a Core Tools .zip for OS '$os' and arch '$arch'"
exit 1
}

$coreToolsUrl = $asset.browser_download_url
Write-Host "Downloading Azure Functions Core Tools from $coreToolsUrl"

$zipPath = "$(Agent.TempDirectory)/Azure.Functions.Cli.zip"
Invoke-WebRequest -Uri $coreToolsUrl -OutFile $zipPath

$installPath = "$(Agent.ToolsDirectory)/Azure.Functions.Cli/$version"
New-Item -ItemType Directory -Path $installPath -Force | Out-Null

Write-Host "Extracting to $installPath"
Expand-Archive -Path $zipPath -DestinationPath $installPath -Force

if ($IsMacOS -or $IsLinux)
{
& "chmod" "a+x" "$installPath/func"
}

Write-Host "Azure Functions Core Tools installed to $installPath"

# Make Core Tools available on PATH for subsequent steps
Write-Host "##vso[task.prependpath]$installPath"
displayName: 'Install Azure Functions Core Tools'
5 changes: 4 additions & 1 deletion eng/ci/templates/steps/setup-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ parameters:

steps:

- ${{ if not(parameters.SkipCoreTools) }}:
- template: /eng/ci/templates/steps/install-core-tools.yml@self

- task: PowerShell@2
displayName: 'Setup E2E tests'
inputs:
Expand All @@ -29,7 +32,7 @@ steps:
-DotnetVersion ${{ parameters.DotnetVersion }}
-SkipStorageEmulator:$${{ parameters.SkipStorageEmulator }}
-SkipCosmosDBEmulator:$${{ parameters.SkipCosmosDBEmulator }}
-SkipCoreTools:$${{ parameters.SkipCoreTools }}
-UseCoreToolsBuildFromIntegrationTests:$${{ parameters.UseCoreToolsBuild }}
-SkipBuildOnPack:$${{ parameters.SkipBuildOnPack }}
-SkipCoreTools
pwsh: true
10 changes: 5 additions & 5 deletions setup-e2e-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ else
& "chmod" "a+x" "$FUNC_CLI_DIRECTORY/func"
}

Write-Host "------"
}
if (Test-Path $output)
{
Remove-Item $output -Recurse -Force -ErrorAction Ignore
}

if (Test-Path $output)
{
Remove-Item $output -Recurse -Force -ErrorAction Ignore
Write-Host "------"
}

Write-Host "----- Executing tests for Dotnet version $DotnetVersion -----"
Expand Down
4 changes: 2 additions & 2 deletions test/E2ETests/E2EApps/E2EApp/E2EApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" Condition="'$(TargetFramework)' == 'net48'" />
<!-- Use version 8.0.1 for .NET Core or other target frameworks -->
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.8" Condition="'$(TargetFramework)' != 'net48'" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Condition="$(TestBuild) != 'true'" Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
<PackageReference Condition="$(TestBuild) != 'true'" Include="Microsoft.Azure.Functions.Worker" Version="2.1.0" />
<PackageReference Include="System.Text.Json" Version="10.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.41" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
<PackageReference Condition="$(TestBuild) != 'true'" Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
<PackageReference Condition="$(TestBuild) != 'true'" Include="Microsoft.Azure.Functions.Worker" Version="2.1.0" />
</ItemGroup>

</Project>
18 changes: 8 additions & 10 deletions test/E2ETests/E2ETests.slnf
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"solution": {
"path": "..\\..\\DotNetWorker.sln",
"path": "..\\..\\DotNetWorker.Extensions.sln",
"projects": [
"extensions\\Worker.Extensions.Abstractions\\Worker.Extensions.Abstractions.csproj",
"extensions\\Worker.Extensions.CosmosDB\\Worker.Extensions.CosmosDB.csproj",
"extensions\\Worker.Extensions.EventHubs\\Worker.Extensions.EventHubs.csproj",
"extensions\\Worker.Extensions.Http\\Worker.Extensions.Http.csproj",
"extensions\\Worker.Extensions.Storage\\Worker.Extensions.Storage.csproj",
"extensions\\Worker.Extensions.Timer\\Worker.Extensions.Timer.csproj",
"src\\DotNetWorker.Core\\DotNetWorker.Core.csproj",
"src\\DotNetWorker.Grpc\\DotNetWorker.Grpc.csproj",
"src\\DotNetWorker\\DotNetWorker.csproj",
"extensions\\Worker.Extensions.Abstractions\\src\\Worker.Extensions.Abstractions.csproj",
"extensions\\Worker.Extensions.CosmosDB\\src\\Worker.Extensions.CosmosDB.csproj",
"extensions\\Worker.Extensions.EventHubs\\src\\Worker.Extensions.EventHubs.csproj",
"extensions\\Worker.Extensions.Http\\src\\Worker.Extensions.Http.csproj",
"extensions\\Worker.Extensions.Storage\\src\\Worker.Extensions.Storage.csproj",
"extensions\\Worker.Extensions.Timer\\src\\Worker.Extensions.Timer.csproj",
"test\\E2ETests\\E2EApps\\E2EApp\\E2EApp.csproj",
"test\\E2ETests\\E2EApps\\E2EAspNetCoreApp\\E2EAspNetCoreApp.csproj",
"test\\E2ETests\\E2ETests\\E2ETests.csproj",
"test\\TestUtility\\TestUtility.csproj"
]
Expand Down
38 changes: 8 additions & 30 deletions test/E2ETests/E2ETests/Fixtures/FixtureHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;

namespace Microsoft.Azure.Functions.Tests.E2ETests
Expand All @@ -15,41 +12,22 @@ public static class FixtureHelpers
{
public static Process GetFuncHostProcess(bool enableAuth = false, string testAppName = null)
{
var funcProcess = new Process();
var rootDir = Path.GetFullPath(@"../../../../../..");
var e2eAppBinPath = Path.Combine(rootDir, "test", "E2ETests", "E2EApps", testAppName, "bin");
string e2eHostJson = Directory.GetFiles(e2eAppBinPath, "host.json", SearchOption.AllDirectories).FirstOrDefault();

if (e2eHostJson == null)
{
throw new InvalidOperationException($"Could not find a built worker app under '{e2eAppBinPath}'");
}

var e2eAppPath = Path.GetDirectoryName(e2eHostJson);

var cliPath = Path.Combine(rootDir, "Azure.Functions.Cli", "func");

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
cliPath += ".exe";
}

if (!File.Exists(cliPath))
{
throw new InvalidOperationException($"Could not find '{cliPath}'. Try running '{Path.Combine(rootDir, "setup-e2e-tests.ps1")}' to install it.");
}
Process funcProcess = new();
string e2eAppPath = Path.Combine(TestUtility.RepoRoot, "test", "E2ETests", "E2EApps", testAppName);

funcProcess.StartInfo.UseShellExecute = false;
funcProcess.StartInfo.RedirectStandardError = true;
funcProcess.StartInfo.RedirectStandardOutput = true;
funcProcess.StartInfo.CreateNoWindow = true;
funcProcess.StartInfo.WorkingDirectory = e2eAppPath;
funcProcess.StartInfo.FileName = cliPath;
funcProcess.StartInfo.ArgumentList.Add("start");
funcProcess.StartInfo.ArgumentList.Add("--verbose");
funcProcess.StartInfo.FileName = "dotnet";
funcProcess.StartInfo.ArgumentList.Add("run");
funcProcess.StartInfo.ArgumentList.Add("--no-build");

if (enableAuth)
{
// '--' to pass args to func host
funcProcess.StartInfo.ArgumentList.Add("--");
funcProcess.StartInfo.ArgumentList.Add("--enableAuth");
}

Expand Down
21 changes: 7 additions & 14 deletions test/Sdk.E2ETests/TestUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,13 @@ public static void ValidateFunctionsMetadata(string actualFilePath, string embed
{
JToken functionsMetadataContents = JToken.Parse(File.ReadAllText(actualFilePath));
var assembly = Assembly.GetExecutingAssembly();
string resourceName = assembly.GetManifestResourceNames()
.Single(str => str.EndsWith(embeddedResourceName));
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
using (StreamReader reader = new StreamReader(stream))
{
using (var jsonReader = new JsonTextReader(reader))
{
JsonSerializer serializer = new JsonSerializer();
var expected = serializer.Deserialize<JToken>(jsonReader);
Assert.True(JToken.DeepEquals(functionsMetadataContents, expected), $"Actual: {functionsMetadataContents}{Environment.NewLine}Expected: {expected}");
}
}
}
string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith(embeddedResourceName));
using Stream stream = assembly.GetManifestResourceStream(resourceName);
using StreamReader reader = new(stream);
using JsonTextReader jsonReader = new(reader);
JsonSerializer serializer = new();
var expected = serializer.Deserialize<JToken>(jsonReader);
Assert.True(JToken.DeepEquals(functionsMetadataContents, expected), $"Actual: {functionsMetadataContents}{Environment.NewLine}Expected: {expected}");
}

public static async Task RestoreAndBuildProjectAsync(string fullPathToProjFile, string outputDir, string additionalParams, ITestOutputHelper outputHelper)
Expand Down