Skip to content

Commit b07029b

Browse files
authored
Adding func start tests (#4364)
1 parent 8ca6fc1 commit b07029b

File tree

63 files changed

+2794
-1999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2794
-1999
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,17 @@ dotnet_diagnostic.IDE1006.severity = warning # Predefined type alias should not
296296
# We allow usage of "var" inside tests as it reduces churn as we remove/rename types
297297
csharp_style_var_for_built_in_types = true:none
298298
csharp_style_var_elsewhere = true:none
299+
dotnet_diagnostic.CA1861.severity = none
300+
dotnet_diagnostic.CA2208.severity = none
301+
dotnet_diagnostic.xUnit1000.severity = none
299302

300303
[**/test/**/*.cs]
301304
# We allow usage of "var" inside tests as it reduces churn as we remove/rename types
302305
csharp_style_var_for_built_in_types = true:none
303306
csharp_style_var_elsewhere = true:none
307+
dotnet_diagnostic.CA1861.severity = none
308+
dotnet_diagnostic.CA2208.severity = none
309+
dotnet_diagnostic.xUnit1000.severity = none
304310

305311
[**/generated/**/*.cs]
306312
dotnet_analyzer_diagnostic.severity = none

Azure.Functions.Cli.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreToolsHost", "src\CoreTo
2323
EndProject
2424
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.TestFramework", "test\Cli\TestFramework\Azure.Functions.Cli.TestFramework.csproj", "{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}"
2525
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.E2E.Tests", "test\Cli\Func.E2E.Tests\Azure.Functions.Cli.E2E.Tests.csproj", "{D61226F6-3472-32C7-16F5-F07705F779CE}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
5759
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Debug|Any CPU.Build.0 = Debug|Any CPU
5860
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Release|Any CPU.ActiveCfg = Release|Any CPU
5961
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{D61226F6-3472-32C7-16F5-F07705F779CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{D61226F6-3472-32C7-16F5-F07705F779CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.Build.0 = Release|Any CPU
6066
EndGlobalSection
6167
GlobalSection(SolutionProperties) = preSolution
6268
HideSolutionNode = FALSE
@@ -70,6 +76,7 @@ Global
7076
{BC78165E-CE5B-4303-BB8E-BC172E5B86E0} = {154FDAF2-0E86-450E-BE57-4E3D410B0FAC}
7177
{0333D5B6-B628-4605-A51E-D0AEE4C3F1FC} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
7278
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
79+
{D61226F6-3472-32C7-16F5-F07705F779CE} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
7380
EndGlobalSection
7481
GlobalSection(ExtensibilityGlobals) = postSolution
7582
SolutionGuid = {FA1E01D6-A57B-4061-A333-EDC511D283C0}

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
55
<RepoEngRoot>$(RepoRoot)eng/</RepoEngRoot>
66
<RepoSrcRoot>$(RepoRoot)src/</RepoSrcRoot>
7+
<RepoTestRoot>$(RepoRoot)test/</RepoTestRoot>
78
</PropertyGroup>
89

910
<!-- artifacts -->

build/BuildSteps.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,42 @@ public static void Test()
332332
Shell.Run("dotnet", $"test {Settings.TestProjectFile} -f net8.0 --logger trx");
333333
}
334334

335+
public static void TestNewE2EProject()
336+
{
337+
var funcPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
338+
? Path.Combine(Settings.OutputDir, "win-x86", "func.exe")
339+
: Path.Combine(Settings.OutputDir, "linux-x64", "func");
340+
Environment.SetEnvironmentVariable("FUNC_PATH", funcPath);
341+
342+
string durableStorageConnectionVar = "DURABLE_STORAGE_CONNECTION";
343+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(durableStorageConnectionVar)))
344+
{
345+
Environment.SetEnvironmentVariable(durableStorageConnectionVar, "UseDevelopmentStorage=true");
346+
}
347+
348+
Environment.SetEnvironmentVariable("DURABLE_FUNCTION_PATH", Settings.DurableFolder);
349+
350+
Shell.Run("dotnet", $"test {Settings.NewTestProjectFile} -f net8.0 --blame-hang-timeout 10m --logger \"console;verbosity=detailed\"");
351+
}
352+
353+
public static void TestNewE2EProjectDotnetInProc()
354+
{
355+
var funcPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
356+
? Path.Combine(Settings.OutputDir, "win-x86", "func.exe")
357+
: Path.Combine(Settings.OutputDir, "linux-x64", "func");
358+
Environment.SetEnvironmentVariable("FUNC_PATH", funcPath);
359+
360+
string durableStorageConnectionVar = "DURABLE_STORAGE_CONNECTION";
361+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(durableStorageConnectionVar)))
362+
{
363+
Environment.SetEnvironmentVariable(durableStorageConnectionVar, "UseDevelopmentStorage=true");
364+
}
365+
366+
Environment.SetEnvironmentVariable("DURABLE_FUNCTION_PATH", Settings.DurableFolder);
367+
368+
Shell.Run("dotnet", $"test {Settings.NewTestProjectFile} -f net8.0 --logger trx --settings {Settings.RuntimeSettings} --blame-hang-timeout 10m");
369+
}
370+
335371
public static void CopyBinariesToSign()
336372
{
337373
string toSignDirPath = Path.Combine(Settings.OutputDir, Settings.SignInfo.ToSignDir);

build/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ static void Main(string[] args)
2727
.Then(AddGoZip)
2828
.Then(TestPreSignedArtifacts, skip: !args.Contains("--ci"))
2929
.Then(CopyBinariesToSign, skip: !args.Contains("--ci"))
30+
.Then(TestNewE2EProject)
31+
.Then(TestNewE2EProjectDotnetInProc)
3032
.Then(Test)
3133
.Then(Zip)
3234
.Then(DotnetPublishForNupkg)

build/Settings.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.IO;
33
using System.Runtime.CompilerServices;
44

@@ -39,6 +39,10 @@ private static string config(string @default = null, [CallerMemberName] string k
3939

4040
public static readonly string DurableFolder = Path.Combine(TestProjectPath, "Resources", "DurableTestFolder");
4141

42+
public static readonly string NewTestProjectFile = Path.Combine("..", "test", "Cli", "Func.E2E.Tests", "Azure.Functions.Cli.E2E.Tests.csproj");
43+
44+
public static readonly string RuntimeSettings = Path.Combine("..", "test", "Cli", "Func.E2E.Tests", ".runsettings", "start_tests", "ci_pipeline", "dotnet_inproc.runsettings");
45+
4246
public static readonly string[] TargetRuntimes = new[] {
4347
"min.win-arm64",
4448
"min.win-x86",

eng/ci/templates/official/jobs/build-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,16 @@ jobs:
108108
DURABLE_STORAGE_CONNECTION: $(DURABLE_STORAGE_CONNECTION)
109109
TELEMETRY_INSTRUMENTATION_KEY: $(TELEMETRY_INSTRUMENTATION_KEY)
110110
IntegrationBuildNumber: $(INTEGRATIONBUILDNUMBER)
111+
DirectoryToLogTo: $(Build.SourcesDirectory)/TestLogs
111112
displayName: 'Executing build script'
112113
114+
- task: 1ES.PublishPipelineArtifact@1
115+
condition: succeededOrFailed()
116+
inputs:
117+
targetPath: '$(Build.SourcesDirectory)/TestLogs'
118+
artifactName: 'TestLogs'
119+
artifactType: 'pipeline'
120+
113121
- template: ci/sign-files.yml@eng
114122
parameters:
115123
displayName: 'Authenticode signing (dll)'

eng/ci/templates/public/jobs/build-test-public.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ jobs:
5959
IsReleaseBuild: false
6060
IsPublicBuild: true
6161
IsCodeqlBuild: false
62+
DirectoryToLogTo: $(Build.SourcesDirectory)/TestLogs
6263
displayName: 'Executing build script'
6364
65+
- task: 1ES.PublishPipelineArtifact@1
66+
condition: succeededOrFailed()
67+
inputs:
68+
targetPath: '$(Build.SourcesDirectory)/TestLogs'
69+
artifactName: 'TestLogs'
70+
artifactType: 'pipeline'
71+
6472
- task: PublishTestResults@2
6573
inputs:
6674
testResultsFormat: 'VSTest'

eng/scripts/ArtifactAssemblerHelpers/testArtifacts.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Write-Host "$rootDir"
88
ls $rootDir
99

1010
# Set the path to test project (.csproj) and runtime settings
11-
$testProjectPath = ".\test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj"
12-
$runtimeSettings = ".\test\Azure.Functions.Cli.Tests\E2E\StartTests_artifact_consolidation.runsettings"
11+
$testProjectPath = ".\test\Cli\Func.E2E.Tests\Azure.Functions.Cli.E2E.Tests.csproj"
12+
$defaultRuntimeSettings = ".\test\Cli\Func.E2E.Tests\.runsettings\start_tests\artifact_consolidation_pipeline\default.runsettings"
13+
$inProcRuntimeSettings = ".\test\Cli\Func.E2E.Tests\.runsettings\start_tests\artifact_consolidation_pipeline\dotnet_inproc.runsettings"
1314

1415
dotnet build $testProjectPath
1516

@@ -29,8 +30,11 @@ Get-ChildItem -Path $StagingDirectory -Directory | ForEach-Object {
2930
[System.Environment]::SetEnvironmentVariable("FUNC_PATH", $funcExePath.FullName, "Process")
3031

3132
# Run dotnet test with the environment variable set
32-
Write-Host "Running 'dotnet test' on test project: $testProjectPath"
33-
dotnet test $testProjectPath --no-build --settings $runtimeSettings --logger "console;verbosity=detailed"
33+
Write-Host "Running 'dotnet test' on test project: $testProjectPath with default artifacts"
34+
dotnet test $testProjectPath --no-build --settings $defaultRuntimeSettings --logger "console;verbosity=detailed"
35+
36+
Write-Host "Running 'dotnet test' on test project: $testProjectPath with inproc artifacts"
37+
dotnet test $testProjectPath --no-build --settings $inProcRuntimeSettings --logger "console;verbosity=detailed"
3438

3539
if ($LASTEXITCODE -ne 0) {
3640
# If the exit code is non-zero, throw an error

eng/scripts/ArtifactAssemblerHelpers/testVsArtifacts.ps1

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,33 @@ Write-Host "Root directory: $rootDir"
88
ls $rootDir
99

1010
# Set the path to test project (.csproj) and runtime settings
11-
$testProjectPath = ".\test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj"
12-
$runtimeSettings = ".\test\Azure.Functions.Cli.Tests\E2E\StartTests_artifact_consolidation_visualstudio.runsettings"
11+
$testProjectPath = ".\test\Cli\Func.E2E.Tests\Azure.Functions.Cli.E2E.Tests.csproj"
12+
$runtimeSettings = ".\test\Cli\Func.E2E.Tests\.runsettings\start_tests\artifact_consolidation_pipeline\visualstudio.runsettings"
1313

1414
[System.Environment]::SetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "dotnet", "Process")
1515

16+
# Path for Visual Studio test projects (convert to absolute paths)
17+
$net8VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet8InProcProject"
18+
$net6VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet6InProcProject"
19+
20+
# Resolve paths to absolute paths
21+
$absoluteNet8VsProjectPath = (Resolve-Path -Path $net8VsProjectPath -ErrorAction SilentlyContinue).Path
22+
if (-not $absoluteNet8VsProjectPath) {
23+
$absoluteNet8VsProjectPath = (Join-Path -Path (Get-Location) -ChildPath $net8VsProjectPath)
24+
Write-Host "Absolute NET8 VS project path (constructed): $absoluteNet8VsProjectPath"
25+
} else {
26+
Write-Host "Absolute NET8 VS project path (resolved): $absoluteNet8VsProjectPath"
27+
}
28+
29+
$absoluteNet6VsProjectPath = (Resolve-Path -Path $net6VsProjectPath -ErrorAction SilentlyContinue).Path
30+
if (-not $absoluteNet6VsProjectPath) {
31+
$absoluteNet6VsProjectPath = (Join-Path -Path (Get-Location) -ChildPath $net6VsProjectPath)
32+
Write-Host "Absolute NET6 VS project path (constructed): $absoluteNet6VsProjectPath"
33+
} else {
34+
Write-Host "Absolute NET6 VS project path (resolved): $absoluteNet6VsProjectPath"
35+
}
36+
37+
# Build the test project
1638
dotnet build $testProjectPath
1739

1840
# Loop through each subdirectory within the parent directory
@@ -30,6 +52,10 @@ Get-ChildItem -Path $StagingDirectory -Directory | ForEach-Object {
3052

3153
# Set the environment variable FUNC_PATH to the func.exe or func path
3254
[System.Environment]::SetEnvironmentVariable("FUNC_PATH", $funcExePath.FullName, "Process")
55+
56+
# Set the environment variables for test projects - use the absolute paths
57+
[System.Environment]::SetEnvironmentVariable("NET8_VS_PROJECT_PATH", $absoluteNet8VsProjectPath, "Process")
58+
[System.Environment]::SetEnvironmentVariable("NET6_VS_PROJECT_PATH", $absoluteNet6VsProjectPath, "Process")
3359

3460
# Run dotnet test with the environment variable set
3561
Write-Host "Running 'dotnet test' on test project: $testProjectPath"

src/Cli/func/Common/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
33
using System.Reflection;
44
using Azure.Functions.Cli.Helpers;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.CompilerServices;
22

33
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.Tests")]
4-
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
4+
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
5+
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.E2E.Tests")]

test/Azure.Functions.Cli.Tests/Azure.Functions.Cli.Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,5 @@
4848
<ItemGroup>
4949
<ProjectReference Include="..\..\src\Cli\func\Azure.Functions.Cli.csproj" />
5050
</ItemGroup>
51-
52-
<PropertyGroup>
53-
<RunSettingsFilePath>$(MSBuildProjectDirectory)\E2E\StartTests_default.runsettings</RunSettingsFilePath>
54-
</PropertyGroup>
51+
5552
</Project>

0 commit comments

Comments
 (0)