Skip to content

Commit dad128f

Browse files
aishwaryabhkshyjufabiocavsurgupta-msftmattchenderson
authored
Custom Host E2E Tests (#4201)
* Core Tools OOP Host (#3802) * this doesn't work * this finally works now * default should be oop host * added edge cases * fixing formatting * using determineTargetFramework * saving tests * adding copy step for OOP * fixing the webhost reference * removing test * setting host version in ps script * update to validate worker versions script * update versions for worker packages * adding ToString * validating worker version * validate worker versions * updating csproj to compile * addressing pr feedback * updating build steps * adding build step * fixing build step * trying to get this working * reverrting target runtimes * updating tests * adding dotnet info step * adding changes * removing extra test * trying to specify architecture * modifying tests to see if they work * narrowing down to tests that are failing * trying to see if it works with nobuild flag * addressing pr feedback * updating tests with latest logging * addressing comments and marking flaky tests * updating so that we are only using net8 framework * pushing change for branch build * adding single quotes * reverting quotes * adding code mirror fiile * updating build step * updatinng build steps * updating build step * adding step for dotnet publish * set inprochost compilation system to diff value and skip flaky test * updating public build pipeline to trigger * adding extra changes for pipeline * public build yml * updating official build * readd net8 build artifact step * readding space back * addressing initial comments * adding explicit openTelemetry dlls * simplifying logic of startHostAction * addressing PR feedback * start tests * changing some of the tests back * reverting test back to normal * fixing spacing for csproj * addressing PR feedback * adding extra variable * adding logic for edge case scenarios * added edge cases tests * removing extra line in node * addressing comments * moving validate host runtime to its own method * forgot to add return statement * Custom host changes for VS Scenario (#3831) * this doesn't work * this finally works now * default should be oop host * added edge cases * fixing formatting * using determineTargetFramework * saving tests * adding copy step for OOP * fixing the webhost reference * removing test * setting host version in ps script * update to validate worker versions script * update versions for worker packages * adding ToString * validating worker version * validate worker versions * updating csproj to compile * addressing pr feedback * updating build steps * adding build step * fixing build step * trying to get this working * reverrting target runtimes * updating tests * adding dotnet info step * adding changes * removing extra test * trying to specify architecture * modifying tests to see if they work * narrowing down to tests that are failing * trying to see if it works with nobuild flag * addressing pr feedback * updating tests with latest logging * addressing comments and marking flaky tests * updating so that we are only using net8 framework * pushing change for branch build * adding single quotes * reverting quotes * adding code mirror fiile * updating build step * updatinng build steps * updating build step * adding step for dotnet publish * set inprochost compilation system to diff value and skip flaky test * updating public build pipeline to trigger * adding extra changes for pipeline * public build yml * updating official build * readd net8 build artifact step * readding space back * addressing initial comments * adding explicit openTelemetry dlls * simplifying logic of startHostAction * addressing PR feedback * start tests * changing some of the tests back * reverting test back to normal * fixing spacing for csproj * addressing PR feedback * adding extra variable * adding logic for edge case scenarios * added edge cases tests * initial changes * removing extra line in node * removing files not needed for custom host * adding build steps * addressing comments * moving validate host runtime to its own method * forgot to add return statement * trying out creating directory * remove skip artifact gen * updating build step * updating build to include in official pipeline * updating publishing custom host step * code mirror * trying to get official build working * program cs update * updating custom host to work with parsing local.settings.json * console read line for stalling process * removing changes not needed for custom host * only including inproc6 and inproc8 changes * addressing initial comments * removing skip artifact gen flag * verbose logging * tryna add release pipeline * windows yaml changes * addressing comments about yml * updating log message * fixing spacing * fixing spacing again * trying spacing again * spacing change * tryan fix spacing this way * spacing * spacing * new line * regular indentation * super indent * changing spacing back to normal * addressing comments * fixing pipeline * Fix build to remove uploadToStorage (#3839) * build steps * trying to parallelize build steps * Revert "build steps" This reverts commit 9aa82fa. * Reapply "build steps" This reverts commit a7b7d46. * Revert "trying to parallelize build steps" This reverts commit d10ef5c. * Adding artifact assembler tool which consolidates the artifacts and produce the package (#3843) * Adding artifact assembler program which collects artifacts from different sources and assemble the final package for core tools. * Adding README * Remove downloaded artifact directories. Minor language update to README * Updating the artifact name to include "_inproc" suffix (#3849) * Small refactor and new tests (#3835) * Updating coretools to detect unsupported inproc6 sdk scenario (#3825) * Restructuring custom host to improve error handling (#3861) * Create Artifacts for releasing OOP core tools (#3848) * assemble artifacts * adding code mirror to test * try awaiting tasks to save space * removing --net8 dependency * trying to delete directory one at a time * trying again with extracting * diff build steps for vs and cli * forgot to include other step for var * trying out new changes * clean up each zip file after extracting * trying another approach * try to delete each directory after copying * removing logic for creating zips rn * including e2e test changes and add powershell file * removing multi targeting * pass in staging directory * adding param * adding logging * printing out paths * adding isolated e2e tests and changing verbosity for logger * adding a new label * comments * adding more clarifying comments * removing extra test and types * adding logging statement for failing task if we fail tests * updating tests to only run in winx64 and winx86 * target directory * target directory * changes to msi file * print out directory * resolving path * reorg files and try to set env variable * dont delete artifacts * update generate msi files * add doller sign for variable name and fix e2e test * changing runtime version * updating to get correct cli version * lol forgot to have content in zip ps script * Update src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs Co-authored-by: Lilian Kasem <[email protected]> * Update src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs Co-authored-by: Lilian Kasem <[email protected]> * Update src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs Co-authored-by: Lilian Kasem <[email protected]> * Update src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs Co-authored-by: Lilian Kasem <[email protected]> * Update src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs Co-authored-by: Lilian Kasem <[email protected]> * addressing comments * reverting programcs back to the way it was * staging directory not correct * merging * Revert "merging" This reverts commit 89cc110. * fixing spacing * wrong directory * trying to free up disk space * removing custom code mirror * removing dollar signs * updating build number * adding variables back * fix build number * fixing candle * fixing msi files * reverting files back to normal --------- Co-authored-by: Lilian Kasem <[email protected]> * Adding package reference (#3872) * adding system.text.json * update patch * move to 8.0.10 * fixing indentation * trying to change version * Templates version update (#3883) * Create metadata.json file in conslidated artifacts intermediate pipeline (#3884) * adding generate metadata file * remove code mirror * get correct inproc version * print out metadata file * fixing zip issue * fixing release number * fixing release number again * removing zip artifact script and fixing code mirror * template update (#4151) * Update templates for dotnet isolated worker 2.x (#4189) * adding tests for custom host * removing zipping for now * trying to print out value * update artifact assembler * removing extra delete file lol * adding env variables * add language * trying to see if this works for e2e tests * this should work * setting language * trying out new change * trying to set env variable * updating start tests * setting env variable * updating cli tester * trying to set testVsArtifacts * setting paths back to normal * local settings json parser print current directory * adding local.settings.json * tests should fail now if they actually fail * adding net6 inproc tests * updating path * start tests net6 update * updating zipping to happen * updating test project * fixing e2e test project * add trailing comma and test comment * updating tests to not exit with expected error * adding tests for custom host * removing zipping for now * trying to print out value * update artifact assembler * removing extra delete file lol * adding env variables * add language * trying to see if this works for e2e tests * this should work * setting language * trying out new change * trying to set env variable * updating start tests * setting env variable * updating cli tester * trying to set testVsArtifacts * setting paths back to normal * local settings json parser print current directory * adding local.settings.json * tests should fail now if they actually fail * adding net6 inproc tests * updating path * start tests net6 update * updating zipping to happen * updating test project * fixing e2e test project * add trailing comma and test comment * updating tests to not exit with expected error * updating artifact assembler * forgot to update assembler * changing environment variable back to normal * addressing comments * addressing comments * deleting extra test csproj folder entry and adding comments to pipeline helpers * adding osx support (#4213) * removing duplicate code * using net8 binaries instead of net6 for custom host osx * addressing feedback for method name --------- Co-authored-by: Shyju Krishnankutty <[email protected]> Co-authored-by: Fabio Cavalcante <[email protected]> Co-authored-by: Surbhi Gupta <[email protected]> Co-authored-by: Matthew Henderson <[email protected]> Co-authored-by: Lilian Kasem <[email protected]> Co-authored-by: Jacob Viau <[email protected]>
1 parent 0eb0036 commit dad128f

21 files changed

+364
-34
lines changed

src/Azure.Functions.ArtifactAssembler/ArtifactAssembler.cs

+35-22
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ internal sealed class ArtifactAssembler
1818
{ "Azure.Functions.Cli.linux-x64", "linux-x64" }
1919
};
2020

21+
private readonly string[] _net8OsxArtifacts =
22+
{
23+
"Azure.Functions.Cli.osx-x64",
24+
"Azure.Functions.Cli.osx-arm64",
25+
};
26+
2127
/// <summary>
2228
/// The artifacts for which we want to pack out-of-proc core tools with it (along with inproc6 and inproc8 directories).
2329
/// </summary>
@@ -172,22 +178,7 @@ private async Task CreateVisualStudioCoreToolsAsync()
172178

173179
foreach (string artifactName in _visualStudioArtifacts.Keys)
174180
{
175-
var inProc8ArtifactDirPath = Directory.EnumerateDirectories(_inProc8ExtractedRootDir)
176-
.FirstOrDefault(dir => dir.Contains(artifactName));
177-
if (inProc8ArtifactDirPath == null)
178-
{
179-
throw new InvalidOperationException($"Artifact directory '{inProc8ArtifactDirPath}' not found!");
180-
}
181-
182-
// Create a new directory to store the custom host with in-proc8 and in-proc6 files.
183-
var artifactDirName = Path.GetFileName(inProc8ArtifactDirPath);
184-
var consolidatedArtifactDirName = $"{artifactName}{Constants.InProcOutputArtifactNameSuffix}.{GetCoreToolsProductVersion(artifactDirName)}";
185-
var consolidatedArtifactDirPath = Path.Combine(customHostTargetArtifactDir, consolidatedArtifactDirName);
186-
Directory.CreateDirectory(consolidatedArtifactDirPath);
187-
188-
// Copy in-proc8 files and delete directory after
189-
await Task.Run(() => FileUtilities.CopyDirectory(inProc8ArtifactDirPath, Path.Combine(consolidatedArtifactDirPath, Constants.InProc8DirectoryName)));
190-
Directory.Delete(inProc8ArtifactDirPath, true);
181+
(string artifactDirName, string consolidatedArtifactDirPath) = await CreateInProc8CoreToolsHostHelper(artifactName, customHostTargetArtifactDir, createDirectory: true);
191182

192183
// Copy in-proc6 files and delete directory after
193184
var inProc6ArtifactDirPath = Path.Combine(_inProc6ExtractedRootDir, artifactDirName);
@@ -201,13 +192,12 @@ private async Task CreateVisualStudioCoreToolsAsync()
201192
EnsureArtifactDirectoryExist(coreToolsHostArtifactDirPath);
202193
await Task.Run(() => FileUtilities.CopyDirectory(coreToolsHostArtifactDirPath, consolidatedArtifactDirPath));
203194
Directory.Delete(coreToolsHostArtifactDirPath, true);
195+
}
204196

205-
// consolidatedArtifactDirPath now contains custom core-tools host, in-proc6 and in-proc8 sub directories. Create a zip file.
206-
var zipPath = Path.Combine(customHostTargetArtifactDir, $"{consolidatedArtifactDirName}.zip");
207-
await Task.Run(() => FileUtilities.CreateZipFile(consolidatedArtifactDirPath, zipPath));
208-
Console.WriteLine($"Successfully created target runtime zip at: {zipPath}");
209-
210-
Directory.Delete(consolidatedArtifactDirPath, true);
197+
// Create artifacts for .NET 8 OSX to use instead of the custom host
198+
foreach (string artifactName in _net8OsxArtifacts)
199+
{
200+
_ = await CreateInProc8CoreToolsHostHelper(artifactName, customHostTargetArtifactDir, createDirectory: false);
211201
}
212202

213203
// Delete directories
@@ -218,6 +208,29 @@ private async Task CreateVisualStudioCoreToolsAsync()
218208
Console.WriteLine("Finished assembling Visual Studio Core Tools artifacts");
219209
}
220210

211+
// This method creates a new directory for the core tools host and copies the inproc8 files
212+
private async Task<(string artifactDirName, string consolidatedArtifactDirPath)> CreateInProc8CoreToolsHostHelper(string artifactName, string customHostTargetArtifactDir, bool createDirectory)
213+
{
214+
var inProcArtifactDirPath = Directory.EnumerateDirectories(_inProc8ExtractedRootDir)
215+
.FirstOrDefault(dir => dir.Contains(artifactName));
216+
if (inProcArtifactDirPath == null)
217+
{
218+
throw new InvalidOperationException($"Artifact directory '{inProcArtifactDirPath}' not found!");
219+
}
220+
221+
// Create a new directory to store the custom host.
222+
var artifactDirName = Path.GetFileName(inProcArtifactDirPath);
223+
var consolidatedArtifactDirName = $"{artifactName}{Constants.InProcOutputArtifactNameSuffix}.{GetCoreToolsProductVersion(artifactDirName)}";
224+
var consolidatedArtifactDirPath = Path.Combine(customHostTargetArtifactDir, consolidatedArtifactDirName);
225+
Directory.CreateDirectory(consolidatedArtifactDirPath);
226+
227+
// Copy in-proc8 files and delete directory after
228+
await Task.Run(() => FileUtilities.CopyDirectory(inProcArtifactDirPath, createDirectory ? Path.Combine(consolidatedArtifactDirPath, Constants.InProc8DirectoryName): consolidatedArtifactDirPath));
229+
Directory.Delete(inProcArtifactDirPath, true);
230+
231+
return (artifactDirName, consolidatedArtifactDirPath);
232+
}
233+
221234
private async Task CreateCliCoreToolsAsync()
222235
{
223236
Console.WriteLine("Starting to assemble CLI Core Tools artifacts");

src/Azure.Functions.ArtifactAssembler/CliArtifactZipper.cs src/Azure.Functions.ArtifactAssembler/ArtifactZipper.cs

+37-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66
namespace Azure.Functions.ArtifactAssembler
77
{
8-
internal sealed class CliArtifactZipper
8+
internal sealed class ArtifactZipper
99
{
1010
private readonly string _rootWorkingDirectory;
11-
public CliArtifactZipper(string rootWorkingDirectory)
11+
public ArtifactZipper(string rootWorkingDirectory)
1212
{
1313
_rootWorkingDirectory = rootWorkingDirectory;
1414
}
1515

1616
internal void ZipCliArtifacts()
1717
{
18+
Console.WriteLine("Zipping CLI Artifacts");
1819
string stagingDirectory = Path.Combine(_rootWorkingDirectory, Constants.StagingDirName, Constants.CliOutputArtifactDirectoryName);
1920

2021
// Get all directories in the staging directory
@@ -49,6 +50,40 @@ internal void ZipCliArtifacts()
4950
Console.WriteLine("All directories zipped successfully!");
5051
}
5152

53+
internal void ZipVisualStudioArtifacts()
54+
{
55+
Console.WriteLine("Zipping Visual Studio Artifacts");
56+
string stagingDirectory = Path.Combine(_rootWorkingDirectory, Constants.StagingDirName, Constants.VisualStudioOutputArtifactDirectoryName);
57+
58+
// Get all directories in the staging directory
59+
var directories = Directory.EnumerateDirectories(stagingDirectory);
60+
61+
foreach (var dir in directories)
62+
{
63+
// Define zip file path and name
64+
string zipFileName = $"{new DirectoryInfo(dir).Name}.zip";
65+
string zipFilePath = Path.Combine(stagingDirectory, zipFileName);
66+
67+
// Compress directory into zip file
68+
FileUtilities.CreateZipFile(dir, zipFilePath);
69+
Console.WriteLine($"Zipped: {dir} -> {zipFilePath}");
70+
71+
// Verify zip creation and delete original directory to free up space
72+
if (File.Exists(zipFilePath))
73+
{
74+
Console.WriteLine($"Successfully created zip: {zipFilePath}");
75+
Directory.Delete(dir, true);
76+
Console.WriteLine($"Deleted original directory: {dir}");
77+
}
78+
else
79+
{
80+
Console.WriteLine($"Failed to create zip for: {dir}");
81+
}
82+
}
83+
84+
Console.WriteLine("All directories zipped successfully!");
85+
}
86+
5287
internal void CreateWorkerDirectoryIfDoesNotExist(string dir)
5388
{
5489
string workersPath = Path.Combine(dir, "workers");

src/Azure.Functions.ArtifactAssembler/PipelineHelpers/generateMetadataFile.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note that this file should be used with YAML steps directly when the consolidated pipeline is migrated over to YAML
12
param (
23
[string]$StagingDirectory
34
)

src/Azure.Functions.ArtifactAssembler/PipelineHelpers/generateMsiFiles.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note that this file should be used with YAML steps directly when the consolidated pipeline is migrated over to YAML
12
param (
23
[string]$ArtifactsPath
34
)

src/Azure.Functions.ArtifactAssembler/PipelineHelpers/testArtifacts.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note that this file should be used with YAML steps directly when the consolidated pipeline is migrated over to YAML
12
param (
23
[string]$StagingDirectory
34
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Note that this file should be used with YAML steps directly when the consolidated pipeline is migrated over to YAML
2+
param (
3+
[string]$StagingDirectory
4+
)
5+
6+
# Set the path to test project (.csproj) and runtime settings
7+
$testProjectPath = "..\..\test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj"
8+
$runtimeSettings = "..\..\test\Azure.Functions.Cli.Tests\E2E\StartTests_artifact_consolidation_visualstudio.runsettings"
9+
10+
[System.Environment]::SetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "dotnet", "Process")
11+
12+
dotnet build $testProjectPath
13+
14+
# Loop through each subdirectory within the parent directory
15+
Get-ChildItem -Path $StagingDirectory -Directory | ForEach-Object {
16+
$subDir = $_.FullName
17+
Write-Host "name of current file: $subDir"
18+
if ($subDir -like "*win-x*") {
19+
Write-Host "Current directory: $subDir"
20+
# Find func.exe in the subdirectory
21+
$funcExePath = Get-ChildItem -Path $subDir -Filter "func.exe" -ErrorAction SilentlyContinue
22+
23+
if ($funcExePath) {
24+
$funcExePathFullName = $funcExePath.FullName
25+
Write-Host "Setting FUNC_PATH to: $funcExePathFullName"
26+
27+
# Set the environment variable FUNC_PATH to the func.exe or func path
28+
[System.Environment]::SetEnvironmentVariable("FUNC_PATH", $funcExePath.FullName, "Process")
29+
30+
# Run dotnet test with the environment variable set
31+
Write-Host "Running 'dotnet test' on test project: $testProjectPath"
32+
dotnet test $testProjectPath --no-build --settings $runtimeSettings --logger "console;verbosity=detailed"
33+
34+
if ($LASTEXITCODE -ne 0) {
35+
# If the exit code is non-zero, throw an error
36+
Write-Host "Tests failed with exit code $LASTEXITCODE"
37+
throw "dotnet test failed within $subDir. Exiting with error."
38+
} else {
39+
# If the exit code is zero, tests passed
40+
Write-Host "All tests passed successfully within $subDir"
41+
}
42+
} else {
43+
Write-Host "No func.exe or func found in: $subDir"
44+
}
45+
}
46+
}

src/Azure.Functions.ArtifactAssembler/Program.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ static async Task<int> Main(string[] args)
1414
// Check if an argument for zipping is passed
1515
if (args.Length > 0 && args[0].Equals("zip", StringComparison.OrdinalIgnoreCase))
1616
{
17-
var zipCliArtifacts = new CliArtifactZipper(currentWorkingDirectory);
18-
zipCliArtifacts.ZipCliArtifacts();
17+
var zipArtifacts = new ArtifactZipper(currentWorkingDirectory);
18+
zipArtifacts.ZipCliArtifacts();
19+
zipArtifacts.ZipVisualStudioArtifacts();
1920
}
2021
else
2122
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<ItemGroup>
4949
<ProjectReference Include="..\..\src\Azure.Functions.Cli\Azure.Functions.Cli.csproj" />
5050
</ItemGroup>
51-
51+
5252
<PropertyGroup>
5353
<RunSettingsFilePath>$(MSBuildProjectDirectory)\E2E\StartTests_default.runsettings</RunSettingsFilePath>
5454
</PropertyGroup>

test/Azure.Functions.Cli.Tests/E2E/Helpers/CliTester.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static CliTester()
4141

4242
public static async Task Run(RunConfiguration[] runConfigurations, ITestOutputHelper output = null, string workingDir = null, bool startHost = false)
4343
{
44+
bool wasWorkingDirPassedIn = (workingDir != null);
4445
string workingDirectory = workingDir ?? Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
4546

4647
bool cleanupDirectory = string.IsNullOrEmpty(workingDir);
@@ -54,7 +55,7 @@ public static async Task Run(RunConfiguration[] runConfigurations, ITestOutputHe
5455

5556
try
5657
{
57-
await InternalRun(workingDirectory, runConfigurations, output, startHost);
58+
await InternalRun(workingDirectory, runConfigurations, output, startHost, wasWorkingDirPassedIn);
5859
}
5960
finally
6061
{
@@ -73,7 +74,7 @@ public static async Task Run(RunConfiguration[] runConfigurations, ITestOutputHe
7374
}
7475
}
7576

76-
private static async Task InternalRun(string workingDir, RunConfiguration[] runConfigurations, ITestOutputHelper output, bool startHost)
77+
private static async Task InternalRun(string workingDir, RunConfiguration[] runConfigurations, ITestOutputHelper output, bool startHost, bool wasWorkingDirPassedIn)
7778
{
7879
await using var hostExe = new Executable(_func, StartHostCommand, workingDirectory: workingDir);
7980
var stdout = new StringBuilder();
@@ -132,6 +133,13 @@ string cmd when cmd.StartsWith("dotnet", StringComparison.OrdinalIgnoreCase) =>
132133
catch (Exception e)
133134
{
134135
logErr($"Error while running test: {e.Message}");
136+
// Throw an error if working directory was passed in
137+
// For some reason, tests don't fail with the working directory not being the default one so we need this specification
138+
if(wasWorkingDirPassedIn)
139+
{
140+
exitError = true;
141+
}
142+
135143
}
136144
finally
137145
{
@@ -166,7 +174,7 @@ string cmd when cmd.StartsWith("dotnet", StringComparison.OrdinalIgnoreCase) =>
166174
}
167175
}
168176

169-
// AssertExitError(runConfiguration, exitError);
177+
AssertExitError(runConfiguration, exitError);
170178
AssertFiles(runConfiguration, workingDir);
171179
AssertDirectories(runConfiguration, workingDir);
172180
AssertOutputContent(runConfiguration, stdout);

test/Azure.Functions.Cli.Tests/E2E/Helpers/TestTraits.cs

+6
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ internal static class TestTraits
2525
/// We still want to run these tests in the PR/ official core tools pipelines and in the artifact consolidation pipeline for a sanity check before publishing the artifacts.
2626
/// </summary>
2727
public const string UseInConsolidatedArtifactGeneration = "UseInConsolidatedArtifactGeneration";
28+
29+
/// <summary>
30+
/// Tests with UseInVisualStudioConsolidatedArtifactGeneration label will not be run in the default scenario and only in the artifact consolidation pipeline
31+
/// Otherwise tests with this label will fail in the PR/ official core tools pipelines since the nested inproc artifacts are not present.
32+
/// </summary>
33+
public const string UseInVisualStudioConsolidatedArtifactGeneration = "UseInVisualStudioConsolidatedArtifactGeneration";
2834
}
2935
}

test/Azure.Functions.Cli.Tests/E2E/StartTests.cs

+70-3
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,76 @@ await CliTester.Run(new RunConfiguration[]
350350
}, _output);
351351
}
352352

353+
[Fact]
354+
[Trait(TestTraits.Group, TestTraits.UseInVisualStudioConsolidatedArtifactGeneration)]
355+
public async Task Start_InProc_Net8_VisualStudio_SuccessfulFunctionExecution()
356+
{
357+
await CliTester.Run(new RunConfiguration[]
358+
{
359+
new RunConfiguration
360+
{
361+
Commands = new[]
362+
{
363+
$"start --port {_funcHostPort} --verbose"
364+
},
365+
ExpectExit = false,
366+
Test = async (workingDir, p, _) =>
367+
{
368+
using (var client = new HttpClient() { BaseAddress = new Uri($"http://localhost:{_funcHostPort}") })
369+
{
370+
(await WaitUntilReady(client)).Should().BeTrue(because: _serverNotReady);
371+
var response = await client.GetAsync("/api/Function1?name=Test");
372+
var result = await response.Content.ReadAsStringAsync();
373+
p.Kill();
374+
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
375+
376+
if (_output is Xunit.Sdk.TestOutputHelper testOutputHelper)
377+
{
378+
testOutputHelper.Output.Should().Contain("Loading .NET 8 host");
379+
}
380+
}
381+
},
382+
CommandTimeout = TimeSpan.FromSeconds(300),
383+
}
384+
}, _output, "../../../E2E/TestProject/TestNet8InProcProject");
385+
386+
}
387+
388+
[Fact]
389+
[Trait(TestTraits.Group, TestTraits.UseInVisualStudioConsolidatedArtifactGeneration)]
390+
public async Task Start_InProc_Net6_VisualStudio_SuccessfulFunctionExecution()
391+
{
392+
await CliTester.Run(new RunConfiguration[]
393+
{
394+
new RunConfiguration
395+
{
396+
Commands = new[]
397+
{
398+
$"start --port {_funcHostPort} --verbose"
399+
},
400+
ExpectExit = false,
401+
Test = async (workingDir, p, _) =>
402+
{
403+
using (var client = new HttpClient() { BaseAddress = new Uri($"http://localhost:{_funcHostPort}") })
404+
{
405+
(await WaitUntilReady(client)).Should().BeTrue(because: _serverNotReady);
406+
var response = await client.GetAsync("/api/Function2?name=Test");
407+
var result = await response.Content.ReadAsStringAsync();
408+
p.Kill();
409+
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
410+
411+
if (_output is Xunit.Sdk.TestOutputHelper testOutputHelper)
412+
{
413+
testOutputHelper.Output.Should().Contain("Loading .NET 6 host");
414+
}
415+
}
416+
},
417+
CommandTimeout = TimeSpan.FromSeconds(300),
418+
}
419+
}, _output, "../../../E2E/TestProject/TestNet6InProcProject");
420+
421+
}
422+
353423
[Fact]
354424
public async Task Start_DotnetIsolated_Net9_SuccessfulFunctionExecution()
355425
{
@@ -1431,7 +1501,6 @@ await CliTester.Run(new RunConfiguration[]
14311501
$"start --port {_funcHostPort}"
14321502
},
14331503
ExpectExit = true,
1434-
ExitInError = true,
14351504
OutputContains = new[] { "Extension bundle configuration should not be present" },
14361505
},
14371506
}, _output);
@@ -1466,7 +1535,6 @@ await CliTester.Run(new RunConfiguration[]
14661535
$"start --port {_funcHostPort}"
14671536
},
14681537
ExpectExit = true,
1469-
ExitInError = true,
14701538
OutputContains = new[] { "Host.json file in missing" },
14711539
},
14721540
}, _output);
@@ -1616,7 +1684,6 @@ await CliTester.Run(new RunConfiguration[]
16161684
},
16171685
CommandTimeout = TimeSpan.FromSeconds(300),
16181686
ExpectExit = true,
1619-
ExitInError = true,
16201687
OutputContains = new[]
16211688
{
16221689
"Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger, kafkatrigger, orchestrationTrigger, activityTrigger, entityTrigger",

0 commit comments

Comments
 (0)