Skip to content

Adding func start tests #4364

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

Merged
merged 25 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5c9823c
initial changes
aishwaryabh Apr 14, 2025
f46c7cd
addressing comments with spacing and namespace changes
aishwaryabh Apr 16, 2025
74c5af3
forgot to add license header for constants file
aishwaryabh Apr 16, 2025
1668a99
addressing other nit comments
aishwaryabh Apr 16, 2025
7f8e14f
addressing stylecop warnings
aishwaryabh Apr 17, 2025
8a85a18
adding a readme
aishwaryabh Apr 17, 2025
6e40470
updating folder structure from func.e2etests to func.e2e.tests
aishwaryabh Apr 21, 2025
a8b6adc
including sln file
aishwaryabh Apr 21, 2025
22c2314
making e2e test solution compile
aishwaryabh Apr 21, 2025
0847ac2
moving vs test projects, renaming .runsettings folder, fixing license…
aishwaryabh Apr 21, 2025
9e64c40
adding more constants and using nameof for test name
aishwaryabh Apr 22, 2025
6fc8404
removing start tests file from old e2e project and dont publish test …
aishwaryabh Apr 22, 2025
c43a3cc
adding more tests to userSecretsTests for DNI equivalent and removing…
aishwaryabh Apr 22, 2025
13397c9
refactored tests lets see if this works
aishwaryabh Apr 22, 2025
747a909
removing python and java fixture to see if this works
aishwaryabh Apr 22, 2025
3ad53b9
adding nodev3 fixture back in
aishwaryabh Apr 22, 2025
fbb62c8
fixing some style issues and removing worker indexing
aishwaryabh Apr 23, 2025
0c0f576
removing uninstall dotnet templates
aishwaryabh Apr 23, 2025
74229e8
updating scripts to try this out in consolidated pipeline
aishwaryabh Apr 23, 2025
0024ac3
fixing editorconfig
aishwaryabh Apr 23, 2025
574a6b6
removing publishing test results
aishwaryabh Apr 23, 2025
f050c2b
fixing tests to pass:
aishwaryabh Apr 23, 2025
56403e5
tests should hopefully pass now
aishwaryabh Apr 23, 2025
785ea3e
fixed localsettings.json test hopefully
aishwaryabh Apr 23, 2025
0977c4a
addressing comments about readme
aishwaryabh Apr 24, 2025
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
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,17 @@ dotnet_diagnostic.IDE1006.severity = warning # Predefined type alias should not
# We allow usage of "var" inside tests as it reduces churn as we remove/rename types
csharp_style_var_for_built_in_types = true:none
csharp_style_var_elsewhere = true:none
dotnet_diagnostic.CA1861.severity = none
dotnet_diagnostic.CA2208.severity = none
dotnet_diagnostic.xUnit1000.severity = none

[**/test/**/*.cs]
# We allow usage of "var" inside tests as it reduces churn as we remove/rename types
csharp_style_var_for_built_in_types = true:none
csharp_style_var_elsewhere = true:none
dotnet_diagnostic.CA1861.severity = none
dotnet_diagnostic.CA2208.severity = none
dotnet_diagnostic.xUnit1000.severity = none

[**/generated/**/*.cs]
dotnet_analyzer_diagnostic.severity = none
7 changes: 7 additions & 0 deletions Azure.Functions.Cli.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreToolsHost", "src\CoreTo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.TestFramework", "test\Cli\TestFramework\Azure.Functions.Cli.TestFramework.csproj", "{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}"
EndProject
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,6 +59,10 @@ Global
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09}.Release|Any CPU.Build.0 = Release|Any CPU
{D61226F6-3472-32C7-16F5-F07705F779CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D61226F6-3472-32C7-16F5-F07705F779CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -70,6 +76,7 @@ Global
{BC78165E-CE5B-4303-BB8E-BC172E5B86E0} = {154FDAF2-0E86-450E-BE57-4E3D410B0FAC}
{0333D5B6-B628-4605-A51E-D0AEE4C3F1FC} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
{D61226F6-3472-32C7-16F5-F07705F779CE} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA1E01D6-A57B-4061-A333-EDC511D283C0}
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<RepoEngRoot>$(RepoRoot)eng/</RepoEngRoot>
<RepoSrcRoot>$(RepoRoot)src/</RepoSrcRoot>
<RepoTestRoot>$(RepoRoot)test/</RepoTestRoot>
</PropertyGroup>

<!-- artifacts -->
Expand Down
36 changes: 36 additions & 0 deletions build/BuildSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,42 @@ public static void Test()
Shell.Run("dotnet", $"test {Settings.TestProjectFile} -f net8.0 --logger trx");
}

public static void TestNewE2EProject()
{
var funcPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Path.Combine(Settings.OutputDir, "win-x86", "func.exe")
: Path.Combine(Settings.OutputDir, "linux-x64", "func");
Environment.SetEnvironmentVariable("FUNC_PATH", funcPath);

string durableStorageConnectionVar = "DURABLE_STORAGE_CONNECTION";
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(durableStorageConnectionVar)))
{
Environment.SetEnvironmentVariable(durableStorageConnectionVar, "UseDevelopmentStorage=true");
}

Environment.SetEnvironmentVariable("DURABLE_FUNCTION_PATH", Settings.DurableFolder);

Shell.Run("dotnet", $"test {Settings.NewTestProjectFile} -f net8.0 --blame-hang-timeout 10m --logger \"console;verbosity=detailed\"");
}

public static void TestNewE2EProjectDotnetInProc()
{
var funcPath = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Path.Combine(Settings.OutputDir, "win-x86", "func.exe")
: Path.Combine(Settings.OutputDir, "linux-x64", "func");
Environment.SetEnvironmentVariable("FUNC_PATH", funcPath);

string durableStorageConnectionVar = "DURABLE_STORAGE_CONNECTION";
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(durableStorageConnectionVar)))
{
Environment.SetEnvironmentVariable(durableStorageConnectionVar, "UseDevelopmentStorage=true");
}

Environment.SetEnvironmentVariable("DURABLE_FUNCTION_PATH", Settings.DurableFolder);

Shell.Run("dotnet", $"test {Settings.NewTestProjectFile} -f net8.0 --logger trx --settings {Settings.RuntimeSettings} --blame-hang-timeout 10m");
}

public static void CopyBinariesToSign()
{
string toSignDirPath = Path.Combine(Settings.OutputDir, Settings.SignInfo.ToSignDir);
Expand Down
2 changes: 2 additions & 0 deletions build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static void Main(string[] args)
.Then(AddGoZip)
.Then(TestPreSignedArtifacts, skip: !args.Contains("--ci"))
.Then(CopyBinariesToSign, skip: !args.Contains("--ci"))
.Then(TestNewE2EProject)
.Then(TestNewE2EProjectDotnetInProc)
.Then(Test)
.Then(Zip)
.Then(DotnetPublishForNupkg)
Expand Down
6 changes: 5 additions & 1 deletion build/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

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

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

public static readonly string NewTestProjectFile = Path.Combine("..", "test", "Cli", "Func.E2E.Tests", "Azure.Functions.Cli.E2E.Tests.csproj");

public static readonly string RuntimeSettings = Path.Combine("..", "test", "Cli", "Func.E2E.Tests", ".runsettings", "start_tests", "ci_pipeline", "dotnet_inproc.runsettings");

public static readonly string[] TargetRuntimes = new[] {
"min.win-arm64",
"min.win-x86",
Expand Down
8 changes: 8 additions & 0 deletions eng/ci/templates/official/jobs/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,16 @@ jobs:
DURABLE_STORAGE_CONNECTION: $(DURABLE_STORAGE_CONNECTION)
TELEMETRY_INSTRUMENTATION_KEY: $(TELEMETRY_INSTRUMENTATION_KEY)
IntegrationBuildNumber: $(INTEGRATIONBUILDNUMBER)
DirectoryToLogTo: $(Build.SourcesDirectory)/TestLogs
displayName: 'Executing build script'

- task: 1ES.PublishPipelineArtifact@1
condition: succeededOrFailed()
inputs:
targetPath: '$(Build.SourcesDirectory)/TestLogs'
artifactName: 'TestLogs'
artifactType: 'pipeline'

- template: ci/sign-files.yml@eng
parameters:
displayName: 'Authenticode signing (dll)'
Expand Down
8 changes: 8 additions & 0 deletions eng/ci/templates/public/jobs/build-test-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ jobs:
IsReleaseBuild: false
IsPublicBuild: true
IsCodeqlBuild: false
DirectoryToLogTo: $(Build.SourcesDirectory)/TestLogs
displayName: 'Executing build script'

- task: 1ES.PublishPipelineArtifact@1
condition: succeededOrFailed()
inputs:
targetPath: '$(Build.SourcesDirectory)/TestLogs'
artifactName: 'TestLogs'
artifactType: 'pipeline'

- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
Expand Down
12 changes: 8 additions & 4 deletions eng/scripts/ArtifactAssemblerHelpers/testArtifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Write-Host "$rootDir"
ls $rootDir

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

dotnet build $testProjectPath

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

# Run dotnet test with the environment variable set
Write-Host "Running 'dotnet test' on test project: $testProjectPath"
dotnet test $testProjectPath --no-build --settings $runtimeSettings --logger "console;verbosity=detailed"
Write-Host "Running 'dotnet test' on test project: $testProjectPath with default artifacts"
dotnet test $testProjectPath --no-build --settings $defaultRuntimeSettings --logger "console;verbosity=detailed"

Write-Host "Running 'dotnet test' on test project: $testProjectPath with inproc artifacts"
dotnet test $testProjectPath --no-build --settings $inProcRuntimeSettings --logger "console;verbosity=detailed"

if ($LASTEXITCODE -ne 0) {
# If the exit code is non-zero, throw an error
Expand Down
30 changes: 28 additions & 2 deletions eng/scripts/ArtifactAssemblerHelpers/testVsArtifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,33 @@ Write-Host "Root directory: $rootDir"
ls $rootDir

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

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

# Path for Visual Studio test projects (convert to absolute paths)
$net8VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet8InProcProject"
$net6VsProjectPath = ".\test\TestFunctionApps\VisualStudioTestProjects\TestNet6InProcProject"

# Resolve paths to absolute paths
$absoluteNet8VsProjectPath = (Resolve-Path -Path $net8VsProjectPath -ErrorAction SilentlyContinue).Path
if (-not $absoluteNet8VsProjectPath) {
$absoluteNet8VsProjectPath = (Join-Path -Path (Get-Location) -ChildPath $net8VsProjectPath)
Write-Host "Absolute NET8 VS project path (constructed): $absoluteNet8VsProjectPath"
} else {
Write-Host "Absolute NET8 VS project path (resolved): $absoluteNet8VsProjectPath"
}

$absoluteNet6VsProjectPath = (Resolve-Path -Path $net6VsProjectPath -ErrorAction SilentlyContinue).Path
if (-not $absoluteNet6VsProjectPath) {
$absoluteNet6VsProjectPath = (Join-Path -Path (Get-Location) -ChildPath $net6VsProjectPath)
Write-Host "Absolute NET6 VS project path (constructed): $absoluteNet6VsProjectPath"
} else {
Write-Host "Absolute NET6 VS project path (resolved): $absoluteNet6VsProjectPath"
}

# Build the test project
dotnet build $testProjectPath

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

# Set the environment variable FUNC_PATH to the func.exe or func path
[System.Environment]::SetEnvironmentVariable("FUNC_PATH", $funcExePath.FullName, "Process")

# Set the environment variables for test projects - use the absolute paths
[System.Environment]::SetEnvironmentVariable("NET8_VS_PROJECT_PATH", $absoluteNet8VsProjectPath, "Process")
[System.Environment]::SetEnvironmentVariable("NET6_VS_PROJECT_PATH", $absoluteNet6VsProjectPath, "Process")

# Run dotnet test with the environment variable set
Write-Host "Running 'dotnet test' on test project: $testProjectPath"
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/func/Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using Azure.Functions.Cli.Helpers;
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/func/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.Tests")]
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
[assembly: InternalsVisibleToAttribute("DynamicProxyGenAssembly2")]
[assembly: InternalsVisibleToAttribute("Azure.Functions.Cli.E2E.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,5 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Cli\func\Azure.Functions.Cli.csproj" />
</ItemGroup>

<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\E2E\StartTests_default.runsettings</RunSettingsFilePath>
</PropertyGroup>

</Project>
Loading