From e427f1337c8263d23e3ce0a134b21f041686c7e2 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 2 Apr 2025 11:03:20 +0200 Subject: [PATCH 01/41] Migrate from VSTest to Microsoft.Testing.Platform --- .github/workflows/run-tests.yml | 38 ++++---- .github/workflows/tests.yml | 10 +- Directory.Packages.props | 4 +- eng/.runsettings | 33 ------- eng/Testing.props | 13 +-- eng/Versions.props | 2 +- eng/Xunit3/Microsoft.Testing.Platform.targets | 91 +++++++++++++++++++ eng/Xunit3/Xunit3.targets | 16 +++- eng/testing/.runsettings | 37 +------- .../Aspire.Components.Common.Tests.csproj | 1 + tests/Aspire.EndToEnd.Tests/.runsettings | 30 +----- .../.runsettings | 25 +---- .../.runsettings | 25 +---- tests/Aspire.Playground.Tests/.runsettings | 30 +----- tests/Aspire.Templates.Tests/.runsettings | 30 +----- tests/Directory.Build.props | 4 - tests/Directory.Build.targets | 7 +- .../TemplatesTesting/BuildEnvironment.cs | 2 - tests/helix/send-to-helix-basictests.targets | 4 +- .../send-to-helix-buildonhelixtests.targets | 5 +- .../helix/send-to-helix-endtoendtests.targets | 2 +- tests/helix/send-to-helix-inner.proj | 12 +-- .../send-to-helix-templatestests.targets | 4 +- 23 files changed, 167 insertions(+), 258 deletions(-) delete mode 100644 eng/.runsettings create mode 100644 eng/Xunit3/Microsoft.Testing.Platform.targets diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ffa66ee7217..283919de1ec 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -220,18 +220,13 @@ jobs: TEST_LOG_PATH: ${{ github.workspace }}/artifacts/log/test-logs TestsRunningOutsideOfRepo: true run: > - dotnet test -s .runsettings -v:n ${{ env.TEST_ASSEMBLY_NAME }}.dll - -l "console;verbosity=normal" - -l "trx;LogFilePrefix=${{ inputs.testShortName }}" - -l "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" - --blame - --blame-hang-timeout ${{ inputs.testHangTimeout }} - --blame-crash + dotnet exec ${{ env.TEST_ASSEMBLY_NAME }}.dll + '@.runsettings' + --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" + --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} + --crashdump --results-directory ${{ github.workspace }}/testresults ${{ inputs.extraTestArgs }} - -- - RunConfiguration.CollectSourceInformation=true - RunConfiguration.TestSessionTimeout=${{ inputs.testSessionTimeoutMs }} - name: Run tests if: ${{ ! inputs.requiresNugets }} @@ -240,24 +235,23 @@ jobs: CI: false DCP_DIAGNOSTICS_LOG_LEVEL: debug DCP_DIAGNOSTICS_LOG_FOLDER: ${{ github.workspace }}/testresults/dcp + # During restore and build, we use -ci, which causes NUGET_PACKAGES to point to a local cache (Arcade behavior). + # In this step, we are not using Arcade, but want to make sure that MSBuild is able to evaluate correctly. + # So, we manually set NUGET_PACKAGES + NUGET_PACKAGES: ${{ github.workspace }}/.packages + run: > ${{ env.DOTNET_SCRIPT }} test ${{ env.TEST_PROJECT_PATH }} /p:ContinuousIntegrationBuild=true - -s eng/testing/.runsettings - -l "console;verbosity=normal" - -l "trx;LogFilePrefix=${{ inputs.testShortName }}" - -l "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" - "--blame" - --blame-hang-timeout ${{ inputs.testHangTimeout }} - --blame-crash - --results-directory testresults + -bl:${{ github.workspace }}/testresults/test.binlog --no-restore --no-build - -bl:${{ github.workspace }}/testresults/test.binlog - ${{ inputs.extraTestArgs }} -- - RunConfiguration.CollectSourceInformation=true - RunConfiguration.TestSessionTimeout=${{ inputs.testSessionTimeoutMs }} + --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" + --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} + --crashdump + --results-directory testresults + ${{ inputs.extraTestArgs }} # Save the result of the previous steps - success or failure # in the form of a file result-success/result-failure -{name}.rst diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cf0cb24f42b..42a58f116f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,7 +74,7 @@ jobs: with: testShortName: ${{ matrix.shortname }} os: "ubuntu-latest" - extraTestArgs: "--filter \"(quarantined!=true)\"" + extraTestArgs: "--filter-not-trait \"quarantined=true\"" integrations_test_win: uses: ./.github/workflows/run-tests.yml @@ -87,7 +87,7 @@ jobs: with: testShortName: ${{ matrix.shortname }} os: "windows-latest" - extraTestArgs: "--filter \"(quarantined!=true)\"" + extraTestArgs: "--filter-not-trait \"quarantined=true\"" templates_test_lin: name: Templates Linux @@ -102,8 +102,7 @@ jobs: testProjectPath: tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj testSessionTimeoutMs: 1200000 testHangTimeout: 12m - # append '.' to the name so only the test class with exactly that name is run - extraTestArgs: "--filter \"(quarantined!=true)&(FullyQualifiedName~Aspire.Templates.Tests.${{ matrix.shortname }}.)\"" + extraTestArgs: "--filter-not-trait quarantined=true --filter-class Aspire.Templates.Tests.${{ matrix.shortname }}" requiresNugets: true requiresTestSdk: true @@ -120,8 +119,7 @@ jobs: testProjectPath: tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj testSessionTimeoutMs: 1200000 testHangTimeout: 12m - # append '.' to the name so only the test class with exactly that name is run - extraTestArgs: "--filter \"(quarantined!=true)&(FullyQualifiedName~Aspire.Templates.Tests.${{ matrix.shortname }}.)\"" + extraTestArgs: "--filter-not-trait quarantined=true --filter-class Aspire.Templates.Tests.${{ matrix.shortname }}" requiresNugets: true requiresTestSdk: true diff --git a/Directory.Packages.props b/Directory.Packages.props index 54b045ccef3..b49c13c0428 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,6 +10,9 @@ 1.0.0 8.0.6 + true + true + false @@ -144,7 +147,6 @@ - diff --git a/eng/.runsettings b/eng/.runsettings deleted file mode 100644 index 955954d2c90..00000000000 --- a/eng/.runsettings +++ /dev/null @@ -1,33 +0,0 @@ - - - - - category!=failing - - - - - - - - Minimal - - - - - - - - - - - - - - - - - - - diff --git a/eng/Testing.props b/eng/Testing.props index 327a5822c2f..db96018efb6 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -1,17 +1,12 @@ - - <_QuarantinedTestRunAdditionalArgs>-trait "quarantined=true" - <_NonQuarantinedTestRunAdditionalArgs>-notrait "quarantined=true" - - - - <_QuarantinedTestRunAdditionalArgs>--filter "quarantined=true" - <_NonQuarantinedTestRunAdditionalArgs>--filter "quarantined!=true" + + <_QuarantinedTestRunAdditionalArgs>--filter-trait "quarantined=true" + <_NonQuarantinedTestRunAdditionalArgs>--filter-not-trait "quarantined=true" 10m - <_BlameArgs>--blame --blame-hang-timeout $(BlameHangTimeout) --blame-crash + <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crash-dump $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) diff --git a/eng/Versions.props b/eng/Versions.props index 9fb2dae920b..117919191e4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -12,10 +12,10 @@ 8.0.13 8.0.406 - true 2.0.0 1.20.0 3.0.2 + 1.6.3 false release diff --git a/eng/Xunit3/Microsoft.Testing.Platform.targets b/eng/Xunit3/Microsoft.Testing.Platform.targets new file mode 100644 index 00000000000..8dd598feb4d --- /dev/null +++ b/eng/Xunit3/Microsoft.Testing.Platform.targets @@ -0,0 +1,91 @@ + + + + + + + + <_TestResultDirectory>$([System.IO.Path]::GetDirectoryName('%(TestToRun.ResultsTrxPath)')) + <_TestResultTrxFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsTrxPath)')) + <_TestResultXmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsXmlFileName)')) + <_TestResultHtmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsHtmlFileName)')) + + + + <_TestEnvironment>%(TestToRun.EnvironmentDisplay) + <_TestAssembly>%(TestToRun.Identity) + <_TestAssembly>$([System.IO.Path]::ChangeExtension($(_TestAssembly), '.exe')) + <_TestRuntime>%(TestToRun.TestRuntime) + <_TestTimeout>%(TestToRun.TestTimeout) + <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments) + + <_TestRunner>$(_TestAssembly) + <_TestRunnerArgs>$(_TestRunnerAdditionalArguments) --results-directory "$(_TestResultDirectory)" --report-xunit --report-xunit-filename "$(_TestResultXmlFileName)" --report-xunit-html --report-xunit-html-filename "$(_TestResultHtmlFileName)" + + + + <_TestRunnerArgs>$(_TestRunnerArgs) --auto-reporters off + + + + <_TestRunnerCommand>"$(_TestRunner)" $(_TestRunnerArgs) + + + <_TestRunnerCommand Condition="'$(TestCaptureOutput)' != 'false'">$(_TestRunnerCommand) > "%(TestToRun.ResultsStdOutPath)" 2>&1 + + + + <_OutputFiles Include="%(TestToRun.ResultsXmlPath)" /> + <_OutputFiles Include="%(TestToRun.ResultsHtmlPath)" /> + <_OutputFiles Include="%(TestToRun.ResultsStdOutPath)" /> + + + + + + + + + + + + + + + + + + <_ResultsFileToDisplay>%(TestToRun.ResultsHtmlPath) + <_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath) + + + + + + + + + + + diff --git a/eng/Xunit3/Xunit3.targets b/eng/Xunit3/Xunit3.targets index 2cda46b44b6..71b6dccb5c6 100644 --- a/eng/Xunit3/Xunit3.targets +++ b/eng/Xunit3/Xunit3.targets @@ -4,15 +4,23 @@ - + + + + + - + + + + + - - \ No newline at end of file + + diff --git a/eng/testing/.runsettings b/eng/testing/.runsettings index 88a92c090ab..ddc26403421 100644 --- a/eng/testing/.runsettings +++ b/eng/testing/.runsettings @@ -1,35 +1,2 @@ - - - - - 1200000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - - - - - - - - - - - - - +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index efa2d072e97..6b71584841d 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,6 +2,7 @@ $(DefaultTargetFramework) + $(TestingPlatformCommandLineArguments) --ignore-exit-code 8 diff --git a/tests/Aspire.EndToEnd.Tests/.runsettings b/tests/Aspire.EndToEnd.Tests/.runsettings index 348b55730ea..52afd9578bb 100644 --- a/tests/Aspire.EndToEnd.Tests/.runsettings +++ b/tests/Aspire.EndToEnd.Tests/.runsettings @@ -1,26 +1,4 @@ - - - - true - - - - 900000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - +--show-live-output on + +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Aspire.Hosting.Containers.Tests/.runsettings b/tests/Aspire.Hosting.Containers.Tests/.runsettings index 591a45e7ab7..ddc26403421 100644 --- a/tests/Aspire.Hosting.Containers.Tests/.runsettings +++ b/tests/Aspire.Hosting.Containers.Tests/.runsettings @@ -1,23 +1,2 @@ - - - - - 900000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Aspire.Hosting.Keycloak.Tests/.runsettings b/tests/Aspire.Hosting.Keycloak.Tests/.runsettings index 591a45e7ab7..ddc26403421 100644 --- a/tests/Aspire.Hosting.Keycloak.Tests/.runsettings +++ b/tests/Aspire.Hosting.Keycloak.Tests/.runsettings @@ -1,23 +1,2 @@ - - - - - 900000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Aspire.Playground.Tests/.runsettings b/tests/Aspire.Playground.Tests/.runsettings index 1eb28e08584..52afd9578bb 100644 --- a/tests/Aspire.Playground.Tests/.runsettings +++ b/tests/Aspire.Playground.Tests/.runsettings @@ -1,26 +1,4 @@ - - - - true - - - - 1200000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - +--show-live-output on + +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Aspire.Templates.Tests/.runsettings b/tests/Aspire.Templates.Tests/.runsettings index 1eb28e08584..52afd9578bb 100644 --- a/tests/Aspire.Templates.Tests/.runsettings +++ b/tests/Aspire.Templates.Tests/.runsettings @@ -1,26 +1,4 @@ - - - - true - - - - 1200000 - - category!=failing - - - - - - TestResults.trx - - - - - normal - - - - - +--show-live-output on + +# Filter out failing (wrong framework, platform, runtime or activeissue) tests +--filter-not-trait "category=failing" diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 8c0aabbcfa9..978c94342d8 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -20,10 +20,6 @@ Exe - - - - false diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 1493871f5a3..2adfe0a38b3 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -8,9 +8,6 @@ - - $(RunSettingsFilePath) - true $(RepoRoot)tests\helix\xunit.runner.json @@ -20,6 +17,8 @@ true true + + $(TestingPlatformCommandLineArguments) @"$(RunSettingsFilePath)" @@ -50,7 +49,7 @@ - + diff --git a/tests/Shared/TemplatesTesting/BuildEnvironment.cs b/tests/Shared/TemplatesTesting/BuildEnvironment.cs index fa1b7dada05..9ac45678a0a 100644 --- a/tests/Shared/TemplatesTesting/BuildEnvironment.cs +++ b/tests/Shared/TemplatesTesting/BuildEnvironment.cs @@ -154,8 +154,6 @@ public BuildEnvironment(bool useSystemDotNet = false, string sdkDirName = "dotne // Avoid using the msbuild terminal logger, so the output can be read // in the tests EnvVars["_MSBUILDTLENABLED"] = "0"; - // .. and disable new output style for vstest - EnvVars["VsTestUseMSBuildOutput"] = "false"; EnvVars["SkipAspireWorkloadManifest"] = "true"; DotNet = Path.Combine(sdkForTemplatePath!, "dotnet"); diff --git a/tests/helix/send-to-helix-basictests.targets b/tests/helix/send-to-helix-basictests.targets index fcfb8bdc47d..a2015de2aa1 100644 --- a/tests/helix/send-to-helix-basictests.targets +++ b/tests/helix/send-to-helix-basictests.targets @@ -21,8 +21,8 @@ - <_TestRunCommandArguments Condition="'$(OS)' != 'Windows_NT'" Include="--filter "quarantined!=true" -- RunConfiguration.TestSessionTimeout=$TEST_TIMEOUT" /> - <_TestRunCommandArguments Condition="'$(OS)' == 'Windows_NT'" Include="--filter "quarantined!=true" -- RunConfiguration.TestSessionTimeout=%TEST_TIMEOUT%" /> + <_TestRunCommandArguments Condition="'$(OS)' != 'Windows_NT'" Include="--filter-not-trait "quarantined=true" -- RunConfiguration.TestSessionTimeout=$TEST_TIMEOUT" /> + <_TestRunCommandArguments Condition="'$(OS)' == 'Windows_NT'" Include="--filter-not-trait "quarantined=true" -- RunConfiguration.TestSessionTimeout=%TEST_TIMEOUT%" /> diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index 096bf419beb..e9d43c4cbb6 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -30,15 +30,16 @@ <_TestRunCommandArguments Remove="@(_TestRunCommandArguments)" /> + <_TestBlameArguments Remove="@(_TestBlameArguments)" /> <_TestBlameArguments Include="--blame-crash" /> <_TestBlameArguments Include="--blame-crash-dump-type full" /> - <_TestRunCommandArguments Include="dotnet test -s .runsettings --results-directory $(_HelixLogsPath) -v:n" /> + <_TestRunCommandArguments Include="dotnet exec @.runsettings --results-directory $(_HelixLogsPath)" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> - <_TestRunCommandArguments Include="--filter "quarantined!=true"" /> + <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> diff --git a/tests/helix/send-to-helix-endtoendtests.targets b/tests/helix/send-to-helix-endtoendtests.targets index a64f35da2a4..8fe033afd7d 100644 --- a/tests/helix/send-to-helix-endtoendtests.targets +++ b/tests/helix/send-to-helix-endtoendtests.targets @@ -21,7 +21,7 @@ Text="Could not find EndToEnd tests at %24(_E2ETestsArchivePath)=$(_E2ETestsArchivePath)" /> - <_TestRunCommandArguments Include="--filter "(quarantined!=true)&(scenario=$(_TestScenarioEnvVar))"" /> + <_TestRunCommandArguments Include="--filter-not-trait "(quarantined=true)&(scenario=$(_TestScenarioEnvVar))"" /> diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index ba38f534cd5..bfa18fddc7f 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -62,13 +62,13 @@ - <_TestBlameArguments Include="--blame-hang" /> - <_TestBlameArguments Include="--blame-hang-dump-type full" /> - <_TestBlameArguments Include="--blame-hang-timeout 10m" /> - <_TestBlameArguments Include="--blame-crash" /> - <_TestBlameArguments Include="--blame-crash-dump-type full" /> + <_TestBlameArguments Include="--hangdump" /> + <_TestBlameArguments Include="--hangdump-type Full" /> + <_TestBlameArguments Include="--hangdump-timeout 10m" /> + <_TestBlameArguments Include="--crashdump" /> + <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet test -s .runsettings $(_TestNameEnvVar).dll --ResultsDirectory:$(_HelixLogsPath) -v:n" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx @.runsettings" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> diff --git a/tests/helix/send-to-helix-templatestests.targets b/tests/helix/send-to-helix-templatestests.targets index cdd6cee0918..1c88d47dd23 100644 --- a/tests/helix/send-to-helix-templatestests.targets +++ b/tests/helix/send-to-helix-templatestests.targets @@ -59,8 +59,8 @@ To fix that, append '.' to the name so only the test class with exactly that name is run. --> - %(PreCommands) $(_ShellCommandSeparator) set "TEST_ARGS=--filter quarantined^^!=true^&category^^!=failing^&FullyQualifiedName~%(Identity)." - %(PreCommands) $(_ShellCommandSeparator) export "TEST_ARGS=--filter quarantined!=true&category!=failing&FullyQualifiedName~%(Identity)." + %(PreCommands) $(_ShellCommandSeparator) set "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)." + %(PreCommands) $(_ShellCommandSeparator) export "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)." $(_TestRunCommand) $(_workItemTimeout) From d09bcd50102680a0d12a9567759ab0bd9f121a9e Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 2 Apr 2025 19:10:28 +0200 Subject: [PATCH 02/41] Address TODO --- tests/helix/send-to-helix-buildonhelixtests.targets | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index e9d43c4cbb6..7fcb4dd7691 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -30,10 +30,9 @@ <_TestRunCommandArguments Remove="@(_TestRunCommandArguments)" /> - <_TestBlameArguments Remove="@(_TestBlameArguments)" /> - <_TestBlameArguments Include="--blame-crash" /> - <_TestBlameArguments Include="--blame-crash-dump-type full" /> + <_TestBlameArguments Include="--crashdump" /> + <_TestBlameArguments Include="--crashdump-type Full" /> <_TestRunCommandArguments Include="dotnet exec @.runsettings --results-directory $(_HelixLogsPath)" /> From 58a546a317e5eb71f308dac6ffcd8f9aa72eae27 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 08:48:32 +0200 Subject: [PATCH 03/41] Cleanup stuff around runsettings --- .github/workflows/run-tests.yml | 1 - eng/testing/.runsettings | 2 -- tests/Aspire.EndToEnd.Tests/.runsettings | 4 ---- .../Aspire.EndToEnd.Tests.csproj | 2 +- tests/Aspire.Hosting.Containers.Tests/.runsettings | 2 -- tests/Aspire.Hosting.Keycloak.Tests/.runsettings | 2 -- tests/Aspire.Playground.Tests/.runsettings | 4 ---- .../Aspire.Playground.Tests.csproj | 2 +- tests/Aspire.Templates.Tests/.runsettings | 4 ---- .../Aspire.Templates.Tests.csproj | 3 ++- tests/Directory.Build.props | 2 -- tests/Directory.Build.targets | 4 +--- tests/helix/send-to-helix-basictests.targets | 12 ++---------- tests/helix/send-to-helix-buildonhelixtests.targets | 2 +- tests/helix/send-to-helix-inner.proj | 2 +- 15 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 eng/testing/.runsettings delete mode 100644 tests/Aspire.EndToEnd.Tests/.runsettings delete mode 100644 tests/Aspire.Hosting.Containers.Tests/.runsettings delete mode 100644 tests/Aspire.Hosting.Keycloak.Tests/.runsettings delete mode 100644 tests/Aspire.Playground.Tests/.runsettings delete mode 100644 tests/Aspire.Templates.Tests/.runsettings diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 283919de1ec..9ee736861e5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -221,7 +221,6 @@ jobs: TestsRunningOutsideOfRepo: true run: > dotnet exec ${{ env.TEST_ASSEMBLY_NAME }}.dll - '@.runsettings' --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump diff --git a/eng/testing/.runsettings b/eng/testing/.runsettings deleted file mode 100644 index ddc26403421..00000000000 --- a/eng/testing/.runsettings +++ /dev/null @@ -1,2 +0,0 @@ -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.EndToEnd.Tests/.runsettings b/tests/Aspire.EndToEnd.Tests/.runsettings deleted file mode 100644 index 52afd9578bb..00000000000 --- a/tests/Aspire.EndToEnd.Tests/.runsettings +++ /dev/null @@ -1,4 +0,0 @@ ---show-live-output on - -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj b/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj index c5284c6947a..f64367a6a98 100644 --- a/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj +++ b/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj @@ -21,8 +21,8 @@ BUILD_FOR_TESTS_RUNNING_OUTSIDE_OF_REPO;$(DefineConstants) xunit.runner.json - $(MSBuildThisFileDirectory).runsettings $(TestArchiveTestsDirForEndToEndTests) + $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Aspire.Hosting.Containers.Tests/.runsettings b/tests/Aspire.Hosting.Containers.Tests/.runsettings deleted file mode 100644 index ddc26403421..00000000000 --- a/tests/Aspire.Hosting.Containers.Tests/.runsettings +++ /dev/null @@ -1,2 +0,0 @@ -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.Hosting.Keycloak.Tests/.runsettings b/tests/Aspire.Hosting.Keycloak.Tests/.runsettings deleted file mode 100644 index ddc26403421..00000000000 --- a/tests/Aspire.Hosting.Keycloak.Tests/.runsettings +++ /dev/null @@ -1,2 +0,0 @@ -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.Playground.Tests/.runsettings b/tests/Aspire.Playground.Tests/.runsettings deleted file mode 100644 index 52afd9578bb..00000000000 --- a/tests/Aspire.Playground.Tests/.runsettings +++ /dev/null @@ -1,4 +0,0 @@ ---show-live-output on - -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 18be600b7f7..7dfafd789df 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -18,7 +18,6 @@ $(MSBuildThisFileDirectory)..\..\playground\ $(MSBuildThisFileDirectory)..\Shared\ - $(MSBuildThisFileDirectory).runsettings true @@ -33,6 +32,7 @@ gets built independently on helix. --> $(NoWarn);xUnit1051 + $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Aspire.Templates.Tests/.runsettings b/tests/Aspire.Templates.Tests/.runsettings deleted file mode 100644 index 52afd9578bb..00000000000 --- a/tests/Aspire.Templates.Tests/.runsettings +++ /dev/null @@ -1,4 +0,0 @@ ---show-live-output on - -# Filter out failing (wrong framework, platform, runtime or activeissue) tests ---filter-not-trait "category=failing" diff --git a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj index 6b50c7c40ac..fd9e50279dc 100644 --- a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj +++ b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj @@ -7,7 +7,6 @@ true xunit.runner.json - $(MSBuildThisFileDirectory).runsettings $(TestArchiveTestsDirForTemplateTests) true @@ -25,6 +24,8 @@ gets built independently on helix. --> $(NoWarn);xUnit1051 + + $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 978c94342d8..4ec31d1bbcc 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -5,8 +5,6 @@ - - $(RepositoryEngineeringDir)testing\.runsettings $([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix', 'tests')) $([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix', 'templates-tests')) $([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix', 'e2e-tests')) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 2adfe0a38b3..64ca89eb923 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -8,7 +8,6 @@ - true $(RepoRoot)tests\helix\xunit.runner.json $(RepositoryEngineeringDir)testing\xunit.runner.json @@ -18,11 +17,10 @@ true - $(TestingPlatformCommandLineArguments) @"$(RunSettingsFilePath)" + $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" - diff --git a/tests/helix/send-to-helix-basictests.targets b/tests/helix/send-to-helix-basictests.targets index a2015de2aa1..29b05b8a3e1 100644 --- a/tests/helix/send-to-helix-basictests.targets +++ b/tests/helix/send-to-helix-basictests.targets @@ -21,8 +21,7 @@ - <_TestRunCommandArguments Condition="'$(OS)' != 'Windows_NT'" Include="--filter-not-trait "quarantined=true" -- RunConfiguration.TestSessionTimeout=$TEST_TIMEOUT" /> - <_TestRunCommandArguments Condition="'$(OS)' == 'Windows_NT'" Include="--filter-not-trait "quarantined=true" -- RunConfiguration.TestSessionTimeout=%TEST_TIMEOUT%" /> + <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> @@ -37,16 +36,9 @@ <_DefaultWorkItems TestName="$([System.Text.RegularExpressions.Regex]::Replace(%(FileName), $(TargetFrameworkSuffixRegex), '$1'))" /> <_DefaultWorkItems TestNameSuffix="$([System.Text.RegularExpressions.Regex]::Replace(%(FileName), $(TargetFrameworkSuffixRegex), '$2'))" /> - - <_DefaultWorkItems TimeoutMs="900000" /> - - <_DefaultWorkItems Condition="$([System.String]::new('%(FileName)').StartsWith('Aspire.Hosting.Elasticsearch.Tests'))" TimeoutMs="3600000" /> - <_DefaultWorkItems Condition="$([System.String]::new('%(FileName)').StartsWith('Aspire.Hosting.Oracle.Tests'))" TimeoutMs="1200000" /> - <_DefaultWorkItems Condition="$([System.String]::new('%(FileName)').StartsWith('Aspire.Pomelo.EntityFrameworkCore.MySql.Tests'))" TimeoutMs="1200000" /> - %(Identity) - $(_EnvVarSetKeyword) "TEST_NAME=%(TestName)" $(_ShellCommandSeparator) $(_EnvVarSetKeyword) TEST_TIMEOUT=%(TimeoutMs) $(_ShellCommandSeparator) $(_EnvVarSetKeyword) "TEST_NAME_SUFFIX=%(TestNameSuffix)" $(_ShellCommandSeparator) $(_EnvVarSetKeyword) "CODE_COV_FILE_SUFFIX=%(TestNameSuffix)" + $(_EnvVarSetKeyword) "TEST_NAME=%(TestName)" $(_ShellCommandSeparator) $(_EnvVarSetKeyword) $(_ShellCommandSeparator) $(_EnvVarSetKeyword) "TEST_NAME_SUFFIX=%(TestNameSuffix)" $(_ShellCommandSeparator) $(_EnvVarSetKeyword) "CODE_COV_FILE_SUFFIX=%(TestNameSuffix)" $(_TestRunCommand) $(_workItemTimeout) diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index 7fcb4dd7691..3896f0bf3c2 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -35,7 +35,7 @@ <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="dotnet exec @.runsettings --results-directory $(_HelixLogsPath)" /> + <_TestRunCommandArguments Include="dotnet exec --results-directory $(_HelixLogsPath)" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index bfa18fddc7f..776469c1d29 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -68,7 +68,7 @@ <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx @.runsettings" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> From 3e4ccd1bbbf04199e3602f4bfb0ab8e1589e4ce2 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 09:14:51 +0200 Subject: [PATCH 04/41] Add comment --- .../Aspire.Components.Common.Tests.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index 6b71584841d..ceb7987abe4 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,6 +2,9 @@ $(DefaultTargetFramework) + + + $(TestingPlatformCommandLineArguments) --ignore-exit-code 8 From f1a32f2e72514d0d88cf961b4dbb02df6aa88dc4 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 11:24:00 +0200 Subject: [PATCH 05/41] Progress --- .github/workflows/run-tests.yml | 3 ++- tests/Directory.Build.targets | 1 + tests/Shared/RepoTesting/Aspire.RepoTesting.targets | 2 -- tests/Shared/RepoTesting/Directory.Packages.Helix.props | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9ee736861e5..a0cb9f0e245 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -242,11 +242,12 @@ jobs: run: > ${{ env.DOTNET_SCRIPT }} test ${{ env.TEST_PROJECT_PATH }} /p:ContinuousIntegrationBuild=true + /p:TrxFileNamePrefix="${{ inputs.testShortName }}" -bl:${{ github.workspace }}/testresults/test.binlog --no-restore --no-build -- - --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" + --report-trx --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump --results-directory testresults diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 64ca89eb923..e63c7c7b508 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -18,6 +18,7 @@ true $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" + $(TestingPlatformCommandLineArguments) --report-trx-filename "$(TrxFileNamePrefix)_$(TargetFramework)_$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss')).trx" diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index deb1a291271..a70ba8e55b3 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -67,8 +67,6 @@ - - diff --git a/tests/Shared/RepoTesting/Directory.Packages.Helix.props b/tests/Shared/RepoTesting/Directory.Packages.Helix.props index a36826bcfe9..3a74f01ca7e 100644 --- a/tests/Shared/RepoTesting/Directory.Packages.Helix.props +++ b/tests/Shared/RepoTesting/Directory.Packages.Helix.props @@ -86,7 +86,5 @@ - - From 8bd7802c8dc3a8c3078fc682f3f8287394bb3179 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 11:26:52 +0200 Subject: [PATCH 06/41] Remove locale --- .../Aspire.Components.Common.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index ceb7987abe4..3e291ae6127 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -2,7 +2,7 @@ $(DefaultTargetFramework) - + $(TestingPlatformCommandLineArguments) --ignore-exit-code 8 From c1797245993dbba7757f6a2b5433ac17571541b4 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 13:22:27 +0200 Subject: [PATCH 07/41] Always show live output --- .github/workflows/run-tests.yml | 1 + eng/Testing.props | 2 ++ tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj | 1 - tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj | 1 - tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj | 2 -- tests/Directory.Build.targets | 2 +- tests/helix/send-to-helix-buildonhelixtests.targets | 2 +- tests/helix/send-to-helix-inner.proj | 2 +- 8 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a0cb9f0e245..2ee855bcc56 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -225,6 +225,7 @@ jobs: --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump --results-directory ${{ github.workspace }}/testresults + --show-live-output on ${{ inputs.extraTestArgs }} - name: Run tests diff --git a/eng/Testing.props b/eng/Testing.props index db96018efb6..5a74f4de73a 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -8,6 +8,8 @@ 10m <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crash-dump + $(TestRunnerAdditionalArguments) --show-live-output on + $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) diff --git a/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj b/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj index f64367a6a98..dac8c42142f 100644 --- a/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj +++ b/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj @@ -22,7 +22,6 @@ xunit.runner.json $(TestArchiveTestsDirForEndToEndTests) - $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 7dfafd789df..3d3c8376a61 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -32,7 +32,6 @@ gets built independently on helix. --> $(NoWarn);xUnit1051 - $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj index fd9e50279dc..d07562415b8 100644 --- a/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj +++ b/tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj @@ -24,8 +24,6 @@ gets built independently on helix. --> $(NoWarn);xUnit1051 - - $(TestingPlatformCommandLineArguments) --show-live-output on diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index e63c7c7b508..1eb40349840 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -17,7 +17,7 @@ true - $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" + $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" --show-live-output on $(TestingPlatformCommandLineArguments) --report-trx-filename "$(TrxFileNamePrefix)_$(TargetFramework)_$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss')).trx" diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index 3896f0bf3c2..fee43b78578 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -35,7 +35,7 @@ <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="dotnet exec --results-directory $(_HelixLogsPath)" /> + <_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath)" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 776469c1d29..9b313e32f16 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -68,7 +68,7 @@ <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> From d82894abd69dcc61f72faf77ad12f11bd2222af5 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 13:31:26 +0200 Subject: [PATCH 08/41] Restore test session timeout --- .github/workflows/run-tests.yml | 4 +++- .github/workflows/tests.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2ee855bcc56..4dd4cf60d05 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,7 +13,7 @@ on: # relative the repo root required: false type: string - testSessionTimeoutMs: + testSessionTimeout: required: false type: string default: "600000" @@ -226,6 +226,7 @@ jobs: --crashdump --results-directory ${{ github.workspace }}/testresults --show-live-output on + --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} - name: Run tests @@ -252,6 +253,7 @@ jobs: --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump --results-directory testresults + --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} # Save the result of the previous steps - success or failure diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 42a58f116f2..572f07719e1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -100,7 +100,7 @@ jobs: testShortName: ${{ matrix.shortname }} os: "ubuntu-latest" testProjectPath: tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj - testSessionTimeoutMs: 1200000 + testSessionTimeout: 20m testHangTimeout: 12m extraTestArgs: "--filter-not-trait quarantined=true --filter-class Aspire.Templates.Tests.${{ matrix.shortname }}" requiresNugets: true @@ -117,7 +117,7 @@ jobs: testShortName: ${{ matrix.shortname }} os: "windows-latest" testProjectPath: tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj - testSessionTimeoutMs: 1200000 + testSessionTimeout: 20m testHangTimeout: 12m extraTestArgs: "--filter-not-trait quarantined=true --filter-class Aspire.Templates.Tests.${{ matrix.shortname }}" requiresNugets: true From 04dfe1256d130cb226e977cd3e82b7b6dcd9a624 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 13:41:06 +0200 Subject: [PATCH 09/41] Fix timeout --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4dd4cf60d05..5b83abed356 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,7 +16,7 @@ on: testSessionTimeout: required: false type: string - default: "600000" + default: "10m" testHangTimeout: required: false type: string From 6cd862b7fda990f85db767a4339d55bfe6333f26 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 14:24:54 +0200 Subject: [PATCH 10/41] Fix typo --- eng/Testing.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Testing.props b/eng/Testing.props index 5a74f4de73a..380d5e37ad9 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -6,7 +6,7 @@ 10m - <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crash-dump + <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crashdump $(TestRunnerAdditionalArguments) --show-live-output on From 3b40316bd6f4b6cc12c79855ce66be43a196f30b Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 15:05:56 +0200 Subject: [PATCH 11/41] Fix duplicate commnand-line options --- eng/Testing.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Testing.props b/eng/Testing.props index 380d5e37ad9..6c2f2194028 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -10,7 +10,7 @@ $(TestRunnerAdditionalArguments) --show-live-output on - $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) - $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(TestRunnerAdditionalArguments) $(_BlameArgs) + $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(_BlameArgs) + $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(_BlameArgs) From f7e699411df6b1c26792f2def2d7ac2c7f2a1f30 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 17:08:15 +0200 Subject: [PATCH 12/41] Fix Linux --- eng/Xunit3/Microsoft.Testing.Platform.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Xunit3/Microsoft.Testing.Platform.targets b/eng/Xunit3/Microsoft.Testing.Platform.targets index 8dd598feb4d..4ee9f1097ac 100644 --- a/eng/Xunit3/Microsoft.Testing.Platform.targets +++ b/eng/Xunit3/Microsoft.Testing.Platform.targets @@ -16,7 +16,7 @@ <_TestEnvironment>%(TestToRun.EnvironmentDisplay) <_TestAssembly>%(TestToRun.Identity) - <_TestAssembly>$([System.IO.Path]::ChangeExtension($(_TestAssembly), '.exe')) + <_TestAssembly Condition="'$(OS)'=='Windows_NT'">$([System.IO.Path]::ChangeExtension($(_TestAssembly), '.exe')) <_TestRuntime>%(TestToRun.TestRuntime) <_TestTimeout>%(TestToRun.TestTimeout) <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments) From 45fd3164a7781564a450a75e8bd99b3dece9ead9 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 17:45:42 +0200 Subject: [PATCH 13/41] Fix for Linux --- eng/Xunit3/Microsoft.Testing.Platform.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/Xunit3/Microsoft.Testing.Platform.targets b/eng/Xunit3/Microsoft.Testing.Platform.targets index 4ee9f1097ac..874d39c4323 100644 --- a/eng/Xunit3/Microsoft.Testing.Platform.targets +++ b/eng/Xunit3/Microsoft.Testing.Platform.targets @@ -17,6 +17,7 @@ <_TestEnvironment>%(TestToRun.EnvironmentDisplay) <_TestAssembly>%(TestToRun.Identity) <_TestAssembly Condition="'$(OS)'=='Windows_NT'">$([System.IO.Path]::ChangeExtension($(_TestAssembly), '.exe')) + <_TestAssembly Condition="'$(OS)'!='Windows_NT'">$(_TestAssembly.TrimEnd('.dll')) <_TestRuntime>%(TestToRun.TestRuntime) <_TestTimeout>%(TestToRun.TestTimeout) <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments) From e5458d1305fac721509e150f47b02252532286ed Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 18:34:47 +0200 Subject: [PATCH 14/41] Fix --- eng/Xunit3/Microsoft.Testing.Platform.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Xunit3/Microsoft.Testing.Platform.targets b/eng/Xunit3/Microsoft.Testing.Platform.targets index 874d39c4323..1111db9c39a 100644 --- a/eng/Xunit3/Microsoft.Testing.Platform.targets +++ b/eng/Xunit3/Microsoft.Testing.Platform.targets @@ -9,8 +9,8 @@ <_TestResultDirectory>$([System.IO.Path]::GetDirectoryName('%(TestToRun.ResultsTrxPath)')) <_TestResultTrxFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsTrxPath)')) - <_TestResultXmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsXmlFileName)')) - <_TestResultHtmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsHtmlFileName)')) + <_TestResultXmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsXmlPath)')) + <_TestResultHtmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsHtmlPath)')) From 519188db7b5cf89355eadef5159ae8fa16aae3bd Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 3 Apr 2025 19:27:09 +0200 Subject: [PATCH 15/41] Fix --- tests/helix/send-to-helix-endtoendtests.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helix/send-to-helix-endtoendtests.targets b/tests/helix/send-to-helix-endtoendtests.targets index 8fe033afd7d..1e9b2d70f33 100644 --- a/tests/helix/send-to-helix-endtoendtests.targets +++ b/tests/helix/send-to-helix-endtoendtests.targets @@ -21,7 +21,7 @@ Text="Could not find EndToEnd tests at %24(_E2ETestsArchivePath)=$(_E2ETestsArchivePath)" /> - <_TestRunCommandArguments Include="--filter-not-trait "(quarantined=true)&(scenario=$(_TestScenarioEnvVar))"" /> + <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true" --filter-trait "scenario=$(_TestScenarioEnvVar)"" /> From cb6cd28edc8e98de2872b50213d64f10f16e864a Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 11:41:48 +0200 Subject: [PATCH 16/41] Filter failing --- .github/workflows/run-tests.yml | 1 + eng/Testing.props | 2 +- tests/helix/send-to-helix-inner.proj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5b83abed356..e710686f33c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -226,6 +226,7 @@ jobs: --crashdump --results-directory ${{ github.workspace }}/testresults --show-live-output on + --filter-not-trait "category=failing" --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} diff --git a/eng/Testing.props b/eng/Testing.props index 6c2f2194028..375f67954f6 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -8,7 +8,7 @@ 10m <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crashdump - $(TestRunnerAdditionalArguments) --show-live-output on + $(TestRunnerAdditionalArguments) --show-live-output on --filter-not-trait "category=failing" $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(_BlameArgs) $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(_BlameArgs) diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 9b313e32f16..6f51021efcc 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -68,7 +68,7 @@ <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on --filter-not-trait "category=failing"" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> From 29087a65e6faa459c3b8479b7b89b13dfffc9c79 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 12:03:40 +0200 Subject: [PATCH 17/41] Fix --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e710686f33c..f278d9e701a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -226,7 +226,7 @@ jobs: --crashdump --results-directory ${{ github.workspace }}/testresults --show-live-output on - --filter-not-trait "category=failing" + --filter-not-trait "category=failing" --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} From 5f0f004f268cbe0ac9214aee398690a420f80e18 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 12:44:22 +0200 Subject: [PATCH 18/41] ignore exit code 8 --- tests/helix/send-to-helix-endtoendtests.targets | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/helix/send-to-helix-endtoendtests.targets b/tests/helix/send-to-helix-endtoendtests.targets index 1e9b2d70f33..94cbcc189f2 100644 --- a/tests/helix/send-to-helix-endtoendtests.targets +++ b/tests/helix/send-to-helix-endtoendtests.targets @@ -21,7 +21,13 @@ Text="Could not find EndToEnd tests at %24(_E2ETestsArchivePath)=$(_E2ETestsArchivePath)" /> - <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true" --filter-trait "scenario=$(_TestScenarioEnvVar)"" /> + + <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true" --filter-trait "scenario=$(_TestScenarioEnvVar)" --ignore-exit-code 8" /> From ce7e73525cc67539560e278262bc092bf71cc3ac Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 13:44:44 +0200 Subject: [PATCH 19/41] Fix extra dot --- tests/helix/send-to-helix-templatestests.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/helix/send-to-helix-templatestests.targets b/tests/helix/send-to-helix-templatestests.targets index 1c88d47dd23..f731f3b41c4 100644 --- a/tests/helix/send-to-helix-templatestests.targets +++ b/tests/helix/send-to-helix-templatestests.targets @@ -59,8 +59,8 @@ To fix that, append '.' to the name so only the test class with exactly that name is run. --> - %(PreCommands) $(_ShellCommandSeparator) set "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)." - %(PreCommands) $(_ShellCommandSeparator) export "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)." + %(PreCommands) $(_ShellCommandSeparator) set "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)" + %(PreCommands) $(_ShellCommandSeparator) export "TEST_ARGS=--filter-not-trait quarantined=true --filter-not-trait category=failing --filter-class %(Identity)" $(_TestRunCommand) $(_workItemTimeout) From e0b800c73166fcf7be073b436f1333b1100f5f62 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 14:32:42 +0200 Subject: [PATCH 20/41] Ignore exit code --- tests/helix/send-to-helix-inner.proj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 6f51021efcc..4497c7eae59 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -68,7 +68,12 @@ <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on --filter-not-trait "category=failing"" /> + + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on --filter-not-trait "category=failing" --ignore-exit-code 8" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> From c44896a7a1a974dc5fc0a8d5220a2a549a730fb6 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 4 Apr 2025 15:17:20 +0200 Subject: [PATCH 21/41] Fix duplicate --ignore-exit-code --- tests/helix/send-to-helix-endtoendtests.targets | 8 +------- tests/helix/send-to-helix-inner.proj | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/helix/send-to-helix-endtoendtests.targets b/tests/helix/send-to-helix-endtoendtests.targets index 94cbcc189f2..1e9b2d70f33 100644 --- a/tests/helix/send-to-helix-endtoendtests.targets +++ b/tests/helix/send-to-helix-endtoendtests.targets @@ -21,13 +21,7 @@ Text="Could not find EndToEnd tests at %24(_E2ETestsArchivePath)=$(_E2ETestsArchivePath)" /> - - <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true" --filter-trait "scenario=$(_TestScenarioEnvVar)" --ignore-exit-code 8" /> + <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true" --filter-trait "scenario=$(_TestScenarioEnvVar)"" /> diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 4497c7eae59..d4f04baad0d 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -69,7 +69,8 @@ <_TestBlameArguments Include="--crashdump-type Full" /> From f15a1c158bdc98c8737e8404ac2abe3575ac7090 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 4 Apr 2025 15:01:16 -0400 Subject: [PATCH 22/41] Fix playground tests on helix --- tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 3d3c8376a61..5f3171074c5 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -6,6 +6,10 @@ true true + + Exe + true From d3795eb67b6f0f26423959893cccc2d3de038f6d Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 5 Apr 2025 08:12:28 +0200 Subject: [PATCH 23/41] Move to RepoTesting.props --- Directory.Packages.props | 3 --- .../Aspire.Playground.Tests/Aspire.Playground.Tests.csproj | 4 ---- tests/Directory.Build.props | 2 -- tests/Shared/RepoTesting/Aspire.RepoTesting.props | 6 ++++++ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index b49c13c0428..9ccfa5de145 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,9 +10,6 @@ 1.0.0 8.0.6 - true - true - false diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 5f3171074c5..3d3c8376a61 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -6,10 +6,6 @@ true true - - Exe - true diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 4ec31d1bbcc..beb44b89dcd 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -14,8 +14,6 @@ $(ArtifactsTestResultsDir) - - Exe diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.props b/tests/Shared/RepoTesting/Aspire.RepoTesting.props index f4c225f2e54..4bf72ed654f 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.props +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.props @@ -14,6 +14,12 @@ Xunit3 + + true + true + false + Exe + From e440ddf88f2941247a508617eb14c28bf35f918a Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 5 Apr 2025 08:19:47 +0200 Subject: [PATCH 24/41] Fix results dir --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f278d9e701a..e45708d0fdf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -253,7 +253,7 @@ jobs: --report-trx --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump - --results-directory testresults + --results-directory ${{ github.workspace }}/testresults --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} From f33dc66e86e5a25326cd1ff4fd9d82c34faee1e3 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 5 Apr 2025 09:18:33 +0200 Subject: [PATCH 25/41] Fix --- tests/Shared/RepoTesting/Aspire.RepoTesting.targets | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index a70ba8e55b3..1e09dc25563 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -67,6 +67,11 @@ + + + + + From 688b6d63e7a2af9bc6d94a4535533e44916f3fec Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 5 Apr 2025 10:08:16 +0200 Subject: [PATCH 26/41] Progress --- .github/workflows/run-tests.yml | 1 - eng/Testing.props | 2 +- tests/Directory.Build.targets | 3 --- tests/Shared/RepoTesting/Aspire.RepoTesting.targets | 3 +++ tests/helix/send-to-helix-buildonhelixtests.targets | 3 ++- tests/helix/send-to-helix-inner.proj | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e45708d0fdf..042b0bad697 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -225,7 +225,6 @@ jobs: --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump --results-directory ${{ github.workspace }}/testresults - --show-live-output on --filter-not-trait "category=failing" --timeout ${{ inputs.testSessionTimeout }} ${{ inputs.extraTestArgs }} diff --git a/eng/Testing.props b/eng/Testing.props index 375f67954f6..6c77b86389b 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -8,7 +8,7 @@ 10m <_BlameArgs>--hangdump --hangdump-timeout $(BlameHangTimeout) --crashdump - $(TestRunnerAdditionalArguments) --show-live-output on --filter-not-trait "category=failing" + $(TestRunnerAdditionalArguments) --filter-not-trait "category=failing" $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(_BlameArgs) $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(_BlameArgs) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 1eb40349840..3512269f733 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -16,9 +16,6 @@ true true - - $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" --show-live-output on - $(TestingPlatformCommandLineArguments) --report-trx-filename "$(TrxFileNamePrefix)_$(TargetFramework)_$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss')).trx" diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index 1e09dc25563..e1880e4962b 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -41,6 +41,9 @@ true $(IntermediateOutputPath)Directory.Packages.Versions.props + + $(TestingPlatformCommandLineArguments) --filter-not-trait "category=failing" + $(TestingPlatformCommandLineArguments) --report-trx-filename "$(TrxFileNamePrefix)_$(TargetFramework)_$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss')).trx" diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index fee43b78578..75598beaec9 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -33,9 +33,10 @@ <_TestBlameArguments Remove="@(_TestBlameArguments)" /> <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> + <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath)" /> + <_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index d4f04baad0d..0887396d542 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -74,7 +74,7 @@ So, ignore exit code 8 (zero tests ran) https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-exit-codes --> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --show-live-output on --filter-not-trait "category=failing" --ignore-exit-code 8" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --filter-not-trait "category=failing" --ignore-exit-code 8" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> From a8b0cd6de6a1550d9f07c97c22765b01e70f71d0 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 5 Apr 2025 20:26:01 +0200 Subject: [PATCH 27/41] Fix duplicate command-line option --- tests/helix/send-to-helix-buildonhelixtests.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index 75598beaec9..19e0c189d19 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -33,7 +33,6 @@ <_TestBlameArguments Remove="@(_TestBlameArguments)" /> <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> - <_TestBlameArguments Include="--crashdump-type Full" /> <_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" /> From cc26956e2aa4c68bd656c4e2367f1597c9ccde38 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Mon, 7 Apr 2025 08:33:59 +0200 Subject: [PATCH 28/41] Missing report-trx --- eng/Xunit3/Microsoft.Testing.Platform.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Xunit3/Microsoft.Testing.Platform.targets b/eng/Xunit3/Microsoft.Testing.Platform.targets index 1111db9c39a..e58467d236d 100644 --- a/eng/Xunit3/Microsoft.Testing.Platform.targets +++ b/eng/Xunit3/Microsoft.Testing.Platform.targets @@ -23,7 +23,7 @@ <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments) <_TestRunner>$(_TestAssembly) - <_TestRunnerArgs>$(_TestRunnerAdditionalArguments) --results-directory "$(_TestResultDirectory)" --report-xunit --report-xunit-filename "$(_TestResultXmlFileName)" --report-xunit-html --report-xunit-html-filename "$(_TestResultHtmlFileName)" + <_TestRunnerArgs>$(_TestRunnerAdditionalArguments) --results-directory "$(_TestResultDirectory)" --report-xunit --report-xunit-filename "$(_TestResultXmlFileName)" --report-xunit-html --report-xunit-html-filename "$(_TestResultHtmlFileName)" --report-trx --report-trx-filename "$(_TestResultTrxFileName)" From d10e168d9a7c4c55f5dbd3d59f3dcef72d86fd3d Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 9 Apr 2025 12:02:13 +0200 Subject: [PATCH 29/41] Run executable --- .github/workflows/run-tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1e7bdc39f89..d36b19c1574 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -147,6 +147,12 @@ jobs: echo "TEST_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV echo "TEST_ASSEMBLY_NAME=$filenameWithoutExtension" >> $env:GITHUB_ENV + - name: Set executable extension (Windows) + if: inputs.os == 'windows-latest' + shell: pwsh + run: | + echo "TEST_EXECUTABLE_EXTENSION=.exe" >> $env:GITHUB_ENV + - name: Build test project if: ${{ ! inputs.requiresNugets }} env: @@ -220,7 +226,7 @@ jobs: TEST_LOG_PATH: ${{ github.workspace }}/artifacts/log/test-logs TestsRunningOutsideOfRepo: true run: > - dotnet exec ${{ env.TEST_ASSEMBLY_NAME }}.dll + ${{ env.TEST_ASSEMBLY_NAME }}${{ env.TEST_EXECUTABLE_EXTENSION }} --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump From c54564bcebe91abfdc5533ee1d1cc5fdfd82b10a Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 9 Apr 2025 12:03:32 +0200 Subject: [PATCH 30/41] Address review comments --- .github/workflows/run-tests.yml | 1 - eng/Testing.props | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d36b19c1574..3beb3f379f6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -246,7 +246,6 @@ jobs: # In this step, we are not using Arcade, but want to make sure that MSBuild is able to evaluate correctly. # So, we manually set NUGET_PACKAGES NUGET_PACKAGES: ${{ github.workspace }}/.packages - run: > ${{ env.DOTNET_SCRIPT }} test ${{ env.TEST_PROJECT_PATH }} /p:ContinuousIntegrationBuild=true diff --git a/eng/Testing.props b/eng/Testing.props index 34f664d6e36..50bb41f48db 100644 --- a/eng/Testing.props +++ b/eng/Testing.props @@ -20,7 +20,7 @@ $(TestRunnerAdditionalArguments) --filter-not-trait "category=failing" - $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(_BlameArgs) + $(TestRunnerAdditionalArguments) $(_NonQuarantinedTestRunAdditionalArgs) $(_BlameArgs) $(TestRunnerAdditionalArguments) $(_QuarantinedTestRunAdditionalArgs) $(_BlameArgs) From 8f778987c3bb502b0daef6534455b4f9383baf4c Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 9 Apr 2025 15:29:41 +0200 Subject: [PATCH 31/41] Revert "Run executable" This reverts commit d10e168d9a7c4c55f5dbd3d59f3dcef72d86fd3d. --- .github/workflows/run-tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3beb3f379f6..6ce8874ea20 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -147,12 +147,6 @@ jobs: echo "TEST_PROJECT_PATH=$projectPath" >> $env:GITHUB_ENV echo "TEST_ASSEMBLY_NAME=$filenameWithoutExtension" >> $env:GITHUB_ENV - - name: Set executable extension (Windows) - if: inputs.os == 'windows-latest' - shell: pwsh - run: | - echo "TEST_EXECUTABLE_EXTENSION=.exe" >> $env:GITHUB_ENV - - name: Build test project if: ${{ ! inputs.requiresNugets }} env: @@ -226,7 +220,7 @@ jobs: TEST_LOG_PATH: ${{ github.workspace }}/artifacts/log/test-logs TestsRunningOutsideOfRepo: true run: > - ${{ env.TEST_ASSEMBLY_NAME }}${{ env.TEST_EXECUTABLE_EXTENSION }} + dotnet exec ${{ env.TEST_ASSEMBLY_NAME }}.dll --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump From 4ba7d9a87571a48505e54d9cb5419f93d2f3a051 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 9 Apr 2025 15:29:59 +0200 Subject: [PATCH 32/41] dotnet dll --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6ce8874ea20..3d2300a9545 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -220,7 +220,7 @@ jobs: TEST_LOG_PATH: ${{ github.workspace }}/artifacts/log/test-logs TestsRunningOutsideOfRepo: true run: > - dotnet exec ${{ env.TEST_ASSEMBLY_NAME }}.dll + dotnet ${{ env.TEST_ASSEMBLY_NAME }}.dll --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump From 5201f074639a0ba4910736ff37d73bc45aaa7a41 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Wed, 9 Apr 2025 02:15:06 +1000 Subject: [PATCH 33/41] Introduce version selector for Aspire templates (#8625) * Introduce version selecto to aspire new * Update src/Aspire.Cli/Commands/NewCommand.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/Aspire.Cli/Commands/NewCommand.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: David Fowler Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Aspire.Cli/Commands/AddCommand.cs | 4 +-- src/Aspire.Cli/Commands/NewCommand.cs | 31 ++++++++++++------------ src/Aspire.Cli/NuGetPackageCache.cs | 22 +++++++++++++---- src/Aspire.Cli/Utils/InteractionUtils.cs | 18 ++++++++++++++ 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/Aspire.Cli/Commands/AddCommand.cs b/src/Aspire.Cli/Commands/AddCommand.cs index be68a9c02b6..291da3ad965 100644 --- a/src/Aspire.Cli/Commands/AddCommand.cs +++ b/src/Aspire.Cli/Commands/AddCommand.cs @@ -66,9 +66,9 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell var source = parseResult.GetValue("--source"); - var packages = await AnsiConsole.Status().StartAsync( + var packages = await InteractionUtils.ShowStatusAsync( "Searching for Aspire packages...", - context => _nuGetPackageCache.GetPackagesAsync(effectiveAppHostProjectFile.Directory!, prerelease, source, cancellationToken) + () => _nuGetPackageCache.GetIntegrationPackagesAsync(effectiveAppHostProjectFile.Directory!, prerelease, source, cancellationToken) ); var version = parseResult.GetValue("--version"); diff --git a/src/Aspire.Cli/Commands/NewCommand.cs b/src/Aspire.Cli/Commands/NewCommand.cs index 2b81943a465..44a0de26cec 100644 --- a/src/Aspire.Cli/Commands/NewCommand.cs +++ b/src/Aspire.Cli/Commands/NewCommand.cs @@ -4,7 +4,6 @@ using System.CommandLine; using System.Diagnostics; using Aspire.Cli.Utils; -using Semver; using Spectre.Console; namespace Aspire.Cli.Commands; @@ -43,6 +42,10 @@ public NewCommand(DotNetCliRunner runner, INuGetPackageCache nuGetPackageCache) var templateVersionOption = new Option("--version", "-v"); templateVersionOption.Description = "The version of the project templates to use."; Options.Add(templateVersionOption); + + var prereleaseOption = new Option("--prerelease"); + prereleaseOption.Description = "Include prerelease versions when searching for project templates."; + Options.Add(prereleaseOption); } private static async Task<(string TemplateName, string TemplateDescription, string? PathAppendage)> GetProjectTemplateAsync(ParseResult parseResult, CancellationToken cancellationToken) @@ -106,7 +109,7 @@ private static async Task GetOutputPathAsync(ParseResult parseResult, st return Path.GetFullPath(outputPath); } - private static async Task GetProjectTemplatesVersionAsync(ParseResult parseResult, CancellationToken cancellationToken) + private async Task GetProjectTemplatesVersionAsync(ParseResult parseResult, bool prerelease, string? source, CancellationToken cancellationToken) { if (parseResult.GetValue("--version") is { } version) { @@ -114,20 +117,15 @@ private static async Task GetProjectTemplatesVersionAsync(ParseResult pa } else { - version = await InteractionUtils.PromptForStringAsync( - "Project templates version:", - defaultValue: VersionHelper.GetDefaultTemplateVersion(), - validator: (string value) => { - if (SemVersion.TryParse(value, out var parsedVersion)) - { - return ValidationResult.Success(); - } - - return ValidationResult.Error("Invalid version format. Please enter a valid version."); - }, - cancellationToken); + var workingDirectory = new DirectoryInfo(Environment.CurrentDirectory); - return version; + var candidatePackages = await InteractionUtils.ShowStatusAsync( + "Searching for available project template versions...", + () => _nuGetPackageCache.GetTemplatePackagesAsync(workingDirectory, prerelease, source, cancellationToken) + ); + + var selectedPackage = await InteractionUtils.PromptForTemplatesVersionAsync(candidatePackages, cancellationToken); + return selectedPackage.Version; } } @@ -138,8 +136,9 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell var template = await GetProjectTemplateAsync(parseResult, cancellationToken); var name = await GetProjectNameAsync(parseResult, cancellationToken); var outputPath = await GetOutputPathAsync(parseResult, template.PathAppendage, cancellationToken); - var version = await GetProjectTemplatesVersionAsync(parseResult, cancellationToken); + var prerelease = parseResult.GetValue("--prerelease"); var source = parseResult.GetValue("--source"); + var version = await GetProjectTemplatesVersionAsync(parseResult, prerelease, source, cancellationToken); var templateInstallResult = await AnsiConsole.Status() .Spinner(Spinner.Known.Dots3) diff --git a/src/Aspire.Cli/NuGetPackageCache.cs b/src/Aspire.Cli/NuGetPackageCache.cs index 402c99a9f92..ec3a7de7c15 100644 --- a/src/Aspire.Cli/NuGetPackageCache.cs +++ b/src/Aspire.Cli/NuGetPackageCache.cs @@ -8,7 +8,8 @@ namespace Aspire.Cli; internal interface INuGetPackageCache { - Task> GetPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken); + Task> GetTemplatePackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken); + Task> GetIntegrationPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken); } internal sealed class NuGetPackageCache(ILogger logger, DotNetCliRunner cliRunner) : INuGetPackageCache @@ -17,7 +18,17 @@ internal sealed class NuGetPackageCache(ILogger logger, DotNe private const int SearchPageSize = 100; - public async Task> GetPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken) + public async Task> GetTemplatePackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken) + { + return await GetPackagesAsync(workingDirectory, "Aspire.ProjectTemplates", prerelease, source, cancellationToken); + } + + public async Task> GetIntegrationPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, string? source, CancellationToken cancellationToken) + { + return await GetPackagesAsync(workingDirectory, "Aspire.Hosting", prerelease, source, cancellationToken); + } + + internal async Task> GetPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, string? source, CancellationToken cancellationToken) { using var activity = _activitySource.StartActivity(); @@ -32,7 +43,7 @@ public async Task> GetPackagesAsync(DirectoryInfo work // This search should pick up Aspire.Hosting.* and CommunityToolkit.Aspire.Hosting.* var result = await cliRunner.SearchPackagesAsync( workingDirectory, - "Aspire.Hosting", + query, prerelease, SearchPageSize, skip, @@ -69,8 +80,9 @@ public async Task> GetPackagesAsync(DirectoryInfo work static bool IsOfficialOrCommunityToolkitPackage(string packageName) { - var isHostingOrCommunityToolkitNamespaced = packageName.StartsWith("Aspire.Hosting.", StringComparison.OrdinalIgnoreCase) || - packageName.StartsWith("CommunityToolkit.Aspire.Hosting.", StringComparison.OrdinalIgnoreCase); + var isHostingOrCommunityToolkitNamespaced = packageName.StartsWith("Aspire.Hosting.", StringComparison.Ordinal) || + packageName.StartsWith("CommunityToolkit.Aspire.Hosting.", StringComparison.Ordinal) || + packageName.Equals("Aspire.ProjectTemplates", StringComparison.Ordinal); var isExcluded = packageName.StartsWith("Aspire.Hosting.AppHost") || packageName.StartsWith("Aspire.Hosting.Sdk") || diff --git a/src/Aspire.Cli/Utils/InteractionUtils.cs b/src/Aspire.Cli/Utils/InteractionUtils.cs index cf517af303e..900fc5faa36 100644 --- a/src/Aspire.Cli/Utils/InteractionUtils.cs +++ b/src/Aspire.Cli/Utils/InteractionUtils.cs @@ -8,6 +8,24 @@ namespace Aspire.Cli.Utils; internal static class InteractionUtils { + public static async Task ShowStatusAsync(string statusText, Func> action) + { + return await AnsiConsole.Status() + .Spinner(Spinner.Known.Dots3) + .SpinnerStyle(Style.Parse("purple")) + .StartAsync(statusText, (context) => action()); + } + + public static async Task PromptForTemplatesVersionAsync(IEnumerable candidatePackages, CancellationToken cancellationToken) + { + return await PromptForSelectionAsync( + "Select a template version:", + candidatePackages, + (p) => $"{p.Version} ({p.Source})", + cancellationToken + ); + } + public static async Task PromptForStringAsync(string promptText, string? defaultValue = null, Func? validator = null, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(promptText, nameof(promptText)); From 7817820f9cb0284a02135a423172bb7f73ebcb53 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Wed, 9 Apr 2025 02:15:53 +1000 Subject: [PATCH 34/41] Error handling for GetCapabilitiesAsync connection issues (#8614) * Error out when GetCapabiltiesAsync is missing or unexpected exception occurs. * Update src/Aspire.Cli/DotNetCliRunner.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Backchannel/AppHostBackchannel.cs | 59 +++++++++++-------- src/Aspire.Cli/DotNetCliRunner.cs | 6 ++ 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/Aspire.Cli/Backchannel/AppHostBackchannel.cs b/src/Aspire.Cli/Backchannel/AppHostBackchannel.cs index c605bcf02e0..b745e380131 100644 --- a/src/Aspire.Cli/Backchannel/AppHostBackchannel.cs +++ b/src/Aspire.Cli/Backchannel/AppHostBackchannel.cs @@ -88,38 +88,49 @@ await rpc.InvokeWithCancellationAsync( public async Task ConnectAsync(Process process, string socketPath, CancellationToken cancellationToken) { - using var activity = _activitySource.StartActivity(); - - _process = process; - - if (_rpcTaskCompletionSource.Task.IsCompleted) + try { - throw new InvalidOperationException("Already connected to AppHost backchannel."); + using var activity = _activitySource.StartActivity(); + + _process = process; + + if (_rpcTaskCompletionSource.Task.IsCompleted) + { + throw new InvalidOperationException("Already connected to AppHost backchannel."); + } + + logger.LogDebug("Connecting to AppHost backchannel at {SocketPath}", socketPath); + var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); + var endpoint = new UnixDomainSocketEndPoint(socketPath); + await socket.ConnectAsync(endpoint, cancellationToken); + logger.LogDebug("Connected to AppHost backchannel at {SocketPath}", socketPath); + + var stream = new NetworkStream(socket, true); + var rpc = JsonRpc.Attach(stream, target); + + var capabilities = await rpc.InvokeWithCancellationAsync( + "GetCapabilitiesAsync", + Array.Empty(), + cancellationToken); + + if (!capabilities.Any(s => s == "baseline.v0")) + { + throw new AppHostIncompatibleException( + $"AppHost is incompatible with the CLI. The AppHost must be updated to a version that supports the baseline.v0 capability.", + "baseline.v0" + ); + } + + _rpcTaskCompletionSource.SetResult(rpc); } - - logger.LogDebug("Connecting to AppHost backchannel at {SocketPath}", socketPath); - var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); - var endpoint = new UnixDomainSocketEndPoint(socketPath); - await socket.ConnectAsync(endpoint, cancellationToken); - logger.LogDebug("Connected to AppHost backchannel at {SocketPath}", socketPath); - - var stream = new NetworkStream(socket, true); - var rpc = JsonRpc.Attach(stream, target); - - var capabilities = await rpc.InvokeWithCancellationAsync( - "GetCapabilitiesAsync", - Array.Empty(), - cancellationToken); - - if (!capabilities.Any(s => s == "baseline.v0")) + catch (RemoteMethodNotFoundException ex) { + logger.LogError(ex, "Failed to connect to AppHost backchannel. The AppHost must be updated to a version that supports the baseline.v0 capability."); throw new AppHostIncompatibleException( $"AppHost is incompatible with the CLI. The AppHost must be updated to a version that supports the baseline.v0 capability.", "baseline.v0" ); } - - _rpcTaskCompletionSource.SetResult(rpc); } public async Task GetPublishersAsync(CancellationToken cancellationToken) diff --git a/src/Aspire.Cli/DotNetCliRunner.cs b/src/Aspire.Cli/DotNetCliRunner.cs index e8d947d1f12..97d318fb952 100644 --- a/src/Aspire.Cli/DotNetCliRunner.cs +++ b/src/Aspire.Cli/DotNetCliRunner.cs @@ -486,6 +486,12 @@ private async Task StartBackchannelAsync(Process process, string socketPath, Tas throw; } + catch (Exception ex) + { + logger.LogError(ex, "An unexpected error occurred while trying to connect to the backchannel."); + backchannelCompletionSource.SetException(ex); + throw; + } } while (await timer.WaitForNextTickAsync(cancellationToken)); } From 4a3a75378d074e7ef4892376b85685b98f36d282 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 8 Apr 2025 13:16:08 -0500 Subject: [PATCH 35/41] Obsolete AddAzureContainerAppsInfrastructure (#8639) * Obsolete AddAzureContainerAppsInfrastructure This method is no longer meant to be used. Instead developers should be calling AddAzureContainerAppEnvironment. Covert the tests using this API to the new API * Fix volume output naming issue We weren't discriminating between volumes and bindmounts, which caused a cache collision. * Switch the prefix at the beginning --- .../AzureContainerAppContainerExtensions.cs | 2 +- .../AzureContainerAppEnvironmentResource.cs | 9 +- .../AzureContainerAppExecutableExtensions.cs | 2 +- .../AzureContainerAppExtensions.cs | 8 +- .../AzureContainerAppProjectExtensions.cs | 2 +- .../AzureResourcePreparer.cs | 2 +- .../AzureContainerAppsTests.cs | 434 +++++++++--------- .../AzureCosmosDBExtensionsTests.cs | 2 +- .../AzureFunctionsTests.cs | 8 +- .../AzurePostgresExtensionsTests.cs | 2 +- .../AzureRedisExtensionsTests.cs | 2 +- .../AzureResourcePreparerTests.cs | 6 +- .../AzureSqlExtensionsTests.cs | 2 +- .../AppContainersPublicApiTests.cs | 2 + .../RoleAssignmentTests.cs | 2 +- 15 files changed, 252 insertions(+), 233 deletions(-) diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppContainerExtensions.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppContainerExtensions.cs index d498c924883..4c64fd9e7c0 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppContainerExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppContainerExtensions.cs @@ -42,7 +42,7 @@ public static IResourceBuilder PublishAsAzureContainerApp(this IResourceBu return container; } - container.ApplicationBuilder.AddAzureContainerAppsInfrastructure(); + container.ApplicationBuilder.AddAzureContainerAppsInfrastructureCore(); container.WithAnnotation(new AzureContainerAppCustomizationAnnotation(configure)); diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs index 06336ef87ab..bbb42ba3778 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs @@ -80,8 +80,15 @@ IManifestExpressionProvider IAzureContainerAppEnvironment.GetSecretOutputKeyVaul IManifestExpressionProvider IAzureContainerAppEnvironment.GetVolumeStorage(IResource resource, ContainerMountAnnotation volume, int volumeIndex) { + var prefix = volume.Type switch + { + ContainerMountType.BindMount => "bindmounts", + ContainerMountType.Volume => "volumes", + _ => throw new NotSupportedException() + }; + // REVIEW: Should we use the same naming algorithm as azd? - var outputName = $"volumes_{resource.Name}_{volumeIndex}"; + var outputName = $"{prefix}_{resource.Name}_{volumeIndex}"; if (!VolumeNames.TryGetValue(outputName, out var volumeName)) { diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExecutableExtensions.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExecutableExtensions.cs index d63d5656fb6..f765d76d809 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExecutableExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExecutableExtensions.cs @@ -42,7 +42,7 @@ public static IResourceBuilder PublishAsAzureContainerApp(this IResourceBu return executable; } - executable.ApplicationBuilder.AddAzureContainerAppsInfrastructure(); + executable.ApplicationBuilder.AddAzureContainerAppsInfrastructureCore(); return executable.WithAnnotation(new AzureContainerAppCustomizationAnnotation(configure)); } diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs index 0d819811e5f..796e3184db4 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs @@ -28,7 +28,11 @@ public static class AzureContainerAppExtensions /// Adds the necessary infrastructure for Azure Container Apps to the distributed application builder. /// /// The distributed application builder. - public static IDistributedApplicationBuilder AddAzureContainerAppsInfrastructure(this IDistributedApplicationBuilder builder) + [Obsolete($"Use {nameof(AddAzureContainerAppEnvironment)} instead. This method will be removed in a future version.")] + public static IDistributedApplicationBuilder AddAzureContainerAppsInfrastructure(this IDistributedApplicationBuilder builder) => + AddAzureContainerAppsInfrastructureCore(builder); + + internal static IDistributedApplicationBuilder AddAzureContainerAppsInfrastructureCore(this IDistributedApplicationBuilder builder) { ArgumentNullException.ThrowIfNull(builder); @@ -52,7 +56,7 @@ public static IDistributedApplicationBuilder AddAzureContainerAppsInfrastructure /// public static IResourceBuilder AddAzureContainerAppEnvironment(this IDistributedApplicationBuilder builder, string name) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppsInfrastructureCore(); // Only support one temporarily until we can support multiple environments // and allowing each container app to be explicit about which environment it uses diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppProjectExtensions.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppProjectExtensions.cs index 2afb2e4002b..905535b0840 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppProjectExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppProjectExtensions.cs @@ -42,7 +42,7 @@ public static IResourceBuilder PublishAsAzureContainerApp(this IResourceBu return project; } - project.ApplicationBuilder.AddAzureContainerAppsInfrastructure(); + project.ApplicationBuilder.AddAzureContainerAppsInfrastructureCore(); project.WithAnnotation(new AzureContainerAppCustomizationAnnotation(configure)); diff --git a/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs b/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs index a6d47daccd7..ee405ac0cfa 100644 --- a/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs +++ b/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs @@ -85,7 +85,7 @@ private static void EnsureNoRoleAssignmentAnnotations(DistributedApplicationMode { if (resource.HasAnnotationOfType()) { - throw new InvalidOperationException("The application model does not support role assignments. Ensure you are using a publisher that supports role assignments, for example AddAzureContainerAppsInfrastructure."); + throw new InvalidOperationException("The application model does not support role assignments. Ensure you are using an environment that supports role assignments, for example AddAzureContainerAppEnvironment."); } } } diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs index d2c7508070a..9e51e46077e 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs @@ -25,7 +25,9 @@ public async Task AddContainerAppsInfrastructureAddsDeploymentTargetWithContaine { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); +#pragma warning disable CS0618 // Type or member is obsolete builder.AddAzureContainerAppsInfrastructure(); +#pragma warning restore CS0618 // Type or member is obsolete builder.AddContainer("api", "myimage"); @@ -101,7 +103,7 @@ public async Task AddDockerfileWithAppsInfrastructureAddsDeploymentTargetWithCon { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var directory = Directory.CreateTempSubdirectory(".aspire-test"); @@ -134,10 +136,10 @@ public async Task AddDockerfileWithAppsInfrastructureAddsDeploymentTargetWithCon "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -150,13 +152,13 @@ public async Task AddDockerfileWithAppsInfrastructureAddsDeploymentTargetWithCon @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -168,12 +170,12 @@ param api_containerimage string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -189,7 +191,7 @@ param api_containerimage string identity: { type: 'UserAssigned' userAssignedIdentities: { - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -203,7 +205,7 @@ public async Task AddContainerAppsInfrastructureAddsDeploymentTargetWithContaine { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddProject("api", launchProfileName: null) .WithHttpEndpoint(); @@ -233,10 +235,10 @@ public async Task AddContainerAppsInfrastructureAddsDeploymentTargetWithContaine "path": "api.module.bicep", "params": { "api_containerport": "{api.containerPort}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -248,19 +250,19 @@ public async Task AddContainerAppsInfrastructureAddsDeploymentTargetWithContaine """ @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - + param api_containerport string - param outputs_azure_container_apps_environment_default_domain string - - param outputs_azure_container_apps_environment_id string - - param outputs_azure_container_registry_endpoint string - - param outputs_azure_container_registry_managed_identity_id string - + param env_outputs_azure_container_apps_environment_default_domain string + + param env_outputs_azure_container_apps_environment_id string + + param env_outputs_azure_container_registry_endpoint string + + param env_outputs_azure_container_registry_managed_identity_id string + param api_containerimage string - + resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' location: location @@ -274,12 +276,12 @@ param api_containerimage string } registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -317,7 +319,7 @@ param api_containerimage string identity: { type: 'UserAssigned' userAssignedIdentities: { - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -331,7 +333,7 @@ public async Task AddExecutableResourceWithPublishAsDockerFileWithAppsInfrastruc { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("infra"); var env = builder.AddParameter("env"); @@ -370,10 +372,10 @@ public async Task AddExecutableResourceWithPublishAsDockerFileWithAppsInfrastruc "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "infra_outputs_azure_container_apps_environment_default_domain": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "infra_outputs_azure_container_apps_environment_id": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "infra_outputs_azure_container_registry_endpoint": "{infra.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "infra_outputs_azure_container_registry_managed_identity_id": "{infra.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}", "env": "{env.value}" } @@ -387,13 +389,13 @@ public async Task AddExecutableResourceWithPublishAsDockerFileWithAppsInfrastruc @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param infra_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param infra_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param infra_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param infra_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -407,12 +409,12 @@ param env string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: infra_outputs_azure_container_registry_endpoint + identity: infra_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: infra_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -434,7 +436,7 @@ param env string identity: { type: 'UserAssigned' userAssignedIdentities: { - '${outputs_azure_container_registry_managed_identity_id}': { } + '${infra_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -448,7 +450,7 @@ public async Task CanTweakContainerAppEnvironmentUsingPublishAsContainerAppOnExe { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddExecutable("api", "node.exe", Environment.CurrentDirectory) .PublishAsDockerFile(); @@ -477,10 +479,10 @@ public async Task CanTweakContainerAppEnvironmentUsingPublishAsContainerAppOnExe "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -493,13 +495,13 @@ public async Task CanTweakContainerAppEnvironmentUsingPublishAsContainerAppOnExe @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -511,12 +513,12 @@ param api_containerimage string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -532,7 +534,7 @@ param api_containerimage string identity: { type: 'UserAssigned' userAssignedIdentities: { - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -546,7 +548,7 @@ public async Task AddContainerAppsInfrastructureWithParameterReference() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var value = builder.AddParameter("value"); var minReplicas = builder.AddParameter("minReplicas"); @@ -587,8 +589,8 @@ public async Task AddContainerAppsInfrastructureWithParameterReference() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", "value": "{value.value}", "minReplicas": "{minReplicas.value}" } @@ -602,9 +604,9 @@ public async Task AddContainerAppsInfrastructureWithParameterReference() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string param value string @@ -617,7 +619,7 @@ param minReplicas string configuration: { activeRevisionsMode: 'Single' } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -648,7 +650,7 @@ public async Task AddContainerAppsEntrypointAndArgs() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithEntrypoint("/bin/sh") @@ -674,9 +676,9 @@ public async Task AddContainerAppsEntrypointAndArgs() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' @@ -685,7 +687,7 @@ param outputs_azure_container_apps_environment_id string configuration: { activeRevisionsMode: 'Single' } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -717,7 +719,7 @@ public async Task ProjectWithManyReferenceTypes() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var db = builder.AddAzureCosmosDB("mydb"); db.AddCosmosDatabase("cosmosdb", databaseName: "db"); @@ -800,10 +802,10 @@ public async Task ProjectWithManyReferenceTypes() "value0_value": "{value0.value}", "value1_value": "{value1.value}", "cs_connectionstring": "{cs.connectionString}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -846,13 +848,13 @@ param value1_value string @secure() param cs_connectionstring string - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -903,12 +905,12 @@ param api_containerimage string } registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -969,11 +971,11 @@ param api_containerimage string } { name: 'HTTP_EP' - value: 'http://api.internal.${outputs_azure_container_apps_environment_default_domain}' + value: 'http://api.internal.${env_outputs_azure_container_apps_environment_default_domain}' } { name: 'HTTPS_EP' - value: 'https://api.internal.${outputs_azure_container_apps_environment_default_domain}' + value: 'https://api.internal.${env_outputs_azure_container_apps_environment_default_domain}' } { name: 'INTERNAL_EP' @@ -989,11 +991,11 @@ param api_containerimage string } { name: 'HOST' - value: 'api.internal.${outputs_azure_container_apps_environment_default_domain}' + value: 'api.internal.${env_outputs_azure_container_apps_environment_default_domain}' } { name: 'HOSTANDPORT' - value: 'api.internal.${outputs_azure_container_apps_environment_default_domain}:80' + value: 'api.internal.${env_outputs_azure_container_apps_environment_default_domain}:80' } { name: 'SCHEME' @@ -1019,7 +1021,7 @@ param api_containerimage string type: 'UserAssigned' userAssignedIdentities: { '${api_identity_outputs_id}': { } - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -1192,7 +1194,7 @@ public async Task PublishAsContainerAppInfluencesContainerAppDefinition() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .PublishAsAzureContainerApp((module, c) => { @@ -1225,8 +1227,8 @@ public async Task PublishAsContainerAppInfluencesContainerAppDefinition() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" } } """; @@ -1238,9 +1240,9 @@ public async Task PublishAsContainerAppInfluencesContainerAppDefinition() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' @@ -1249,7 +1251,7 @@ param outputs_azure_container_apps_environment_id string configuration: { activeRevisionsMode: 'Single' } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -1276,7 +1278,7 @@ public async Task ConfigureCustomDomainMutatesIngress() var customDomain = builder.AddParameter("customDomain"); var certificateName = builder.AddParameter("certificateName"); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(targetPort: 1111) .PublishAsAzureContainerApp((module, c) => @@ -1308,8 +1310,8 @@ public async Task ConfigureCustomDomainMutatesIngress() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", "certificateName": "{certificateName.value}", "customDomain": "{customDomain.value}" } @@ -1323,9 +1325,9 @@ public async Task ConfigureCustomDomainMutatesIngress() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string param certificateName string @@ -1345,12 +1347,12 @@ param customDomain string { name: customDomain bindingType: (certificateName != '') ? 'SniEnabled' : 'Disabled' - certificateId: (certificateName != '') ? '${outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName}' : null + certificateId: (certificateName != '') ? '${env_outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName}' : null } ] } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -1378,7 +1380,7 @@ public async Task ConfigureDuplicateCustomDomainMutatesIngress() var initialCertificateName = builder.AddParameter("initialCertificateName"); var expectedCertificateName = builder.AddParameter("expectedCertificateName"); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(targetPort: 1111) .PublishAsAzureContainerApp((module, c) => @@ -1411,8 +1413,8 @@ public async Task ConfigureDuplicateCustomDomainMutatesIngress() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", "initialCertificateName": "{initialCertificateName.value}", "customDomain": "{customDomain.value}", "expectedCertificateName": "{expectedCertificateName.value}" @@ -1427,9 +1429,9 @@ public async Task ConfigureDuplicateCustomDomainMutatesIngress() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string param initialCertificateName string @@ -1451,12 +1453,12 @@ param expectedCertificateName string { name: customDomain bindingType: (expectedCertificateName != '') ? 'SniEnabled' : 'Disabled' - certificateId: (expectedCertificateName != '') ? '${outputs_azure_container_apps_environment_id}/managedCertificates/${expectedCertificateName}' : null + certificateId: (expectedCertificateName != '') ? '${env_outputs_azure_container_apps_environment_id}/managedCertificates/${expectedCertificateName}' : null } ] } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -1486,7 +1488,7 @@ public async Task ConfigureMultipleCustomDomainsMutatesIngress() var customDomain2 = builder.AddParameter("customDomain2"); var certificateName2 = builder.AddParameter("certificateName2"); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(targetPort: 1111) .PublishAsAzureContainerApp((module, c) => @@ -1519,8 +1521,8 @@ public async Task ConfigureMultipleCustomDomainsMutatesIngress() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", "certificateName1": "{certificateName1.value}", "customDomain1": "{customDomain1.value}", "certificateName2": "{certificateName2.value}", @@ -1536,9 +1538,9 @@ public async Task ConfigureMultipleCustomDomainsMutatesIngress() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string param certificateName1 string @@ -1562,17 +1564,17 @@ param customDomain2 string { name: customDomain1 bindingType: (certificateName1 != '') ? 'SniEnabled' : 'Disabled' - certificateId: (certificateName1 != '') ? '${outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName1}' : null + certificateId: (certificateName1 != '') ? '${env_outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName1}' : null } { name: customDomain2 bindingType: (certificateName2 != '') ? 'SniEnabled' : 'Disabled' - certificateId: (certificateName2 != '') ? '${outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName2}' : null + certificateId: (certificateName2 != '') ? '${env_outputs_azure_container_apps_environment_id}/managedCertificates/${certificateName2}' : null } ] } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -1596,7 +1598,7 @@ public async Task VolumesAndBindMountsAreTranslation() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithVolume("vol1", "/path1") @@ -1627,11 +1629,11 @@ public async Task VolumesAndBindMountsAreTranslation() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "api_volumes_0_storage": "{api.volumes.0.storage}", - "api_volumes_1_storage": "{api.volumes.1.storage}", - "api_bindmounts_0_storage": "{api.bindMounts.0.storage}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" + "env_outputs_volumes_api_0": "{env.outputs.volumes_api_0}", + "env_outputs_volumes_api_1": "{env.outputs.volumes_api_1}", + "env_outputs_bindmounts_api_0": "{env.outputs.bindmounts_api_0}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" } } """; @@ -1642,17 +1644,17 @@ public async Task VolumesAndBindMountsAreTranslation() """ @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - - param api_volumes_0_storage string - - param api_volumes_1_storage string - - param api_bindmounts_0_storage string - - param outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string - + param env_outputs_volumes_api_0 string + + param env_outputs_volumes_api_1 string + + param env_outputs_bindmounts_api_0 string + + param env_outputs_azure_container_apps_environment_default_domain string + + param env_outputs_azure_container_apps_environment_id string + resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' location: location @@ -1660,7 +1662,7 @@ param outputs_azure_container_apps_environment_id string configuration: { activeRevisionsMode: 'Single' } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -1689,24 +1691,24 @@ param outputs_azure_container_apps_environment_id string { name: 'v0' storageType: 'AzureFile' - storageName: api_volumes_0_storage + storageName: env_outputs_volumes_api_0 } { name: 'v1' storageType: 'AzureFile' - storageName: api_volumes_1_storage + storageName: env_outputs_volumes_api_1 } { name: 'bm0' storageType: 'AzureFile' - storageName: api_bindmounts_0_storage + storageName: env_outputs_bindmounts_api_0 } ] } } } """; - + output.WriteLine(bicep); Assert.Equal(expectedBicep, bicep); } @@ -1715,7 +1717,9 @@ public async Task SecretOutputHandling() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); +#pragma warning disable CS0618 // Type or member is obsolete builder.AddAzureContainerAppsInfrastructure(); +#pragma warning restore CS0618 // Type or member is obsolete var db = builder.AddAzureCosmosDB("mydb").WithAccessKeyAuthentication(); db.AddCosmosDatabase("db"); @@ -1951,7 +1955,7 @@ public async Task CanCustomizeWithProvisioningBuildOptions() var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); builder.Services.Configure(options => options.ProvisioningBuildOptions.InfrastructureResolvers.Insert(0, new MyResourceNamePropertyResolver())); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api1", "myimage"); @@ -1976,9 +1980,9 @@ public async Task CanCustomizeWithProvisioningBuildOptions() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api1 'Microsoft.App/containerApps@2024-03-01' = { name: 'api1-my' @@ -1987,7 +1991,7 @@ param outputs_azure_container_apps_environment_id string configuration: { activeRevisionsMode: 'Single' } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2024,7 +2028,7 @@ public async Task ExternalEndpointBecomesIngress() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint() @@ -2054,8 +2058,8 @@ public async Task ExternalEndpointBecomesIngress() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" } } """; @@ -2067,9 +2071,9 @@ public async Task ExternalEndpointBecomesIngress() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' @@ -2083,7 +2087,7 @@ param outputs_azure_container_apps_environment_id string transport: 'http' } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2107,7 +2111,7 @@ public async Task FirstHttpEndpointBecomesIngress() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(name: "one", targetPort: 8080) @@ -2137,8 +2141,8 @@ public async Task FirstHttpEndpointBecomesIngress() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" } } """; @@ -2150,9 +2154,9 @@ public async Task FirstHttpEndpointBecomesIngress() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' @@ -2172,7 +2176,7 @@ param outputs_azure_container_apps_environment_id string ] } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2196,7 +2200,7 @@ public async Task EndpointWithHttp2SetsTransportToH2() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint() @@ -2227,8 +2231,8 @@ public async Task EndpointWithHttp2SetsTransportToH2() "type": "azure.bicep.v0", "path": "api.module.bicep", "params": { - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}" } } """; @@ -2240,9 +2244,9 @@ public async Task EndpointWithHttp2SetsTransportToH2() @description('The location for the resource(s) to be deployed.') param location string = resourceGroup().location - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string resource api 'Microsoft.App/containerApps@2024-03-01' = { name: 'api' @@ -2256,7 +2260,7 @@ param outputs_azure_container_apps_environment_id string transport: 'http2' } } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2280,7 +2284,7 @@ public async Task ProjectUsesTheTargetPortAsADefaultPortForFirstHttpEndpoint() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddProject("api", launchProfileName: null) .WithHttpEndpoint() @@ -2311,10 +2315,10 @@ public async Task ProjectUsesTheTargetPortAsADefaultPortForFirstHttpEndpoint() "path": "api.module.bicep", "params": { "api_containerport": "{api.containerPort}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -2329,13 +2333,13 @@ public async Task ProjectUsesTheTargetPortAsADefaultPortForFirstHttpEndpoint() param api_containerport string - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -2352,12 +2356,12 @@ param api_containerimage string } registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2399,7 +2403,7 @@ param api_containerimage string identity: { type: 'UserAssigned' userAssignedIdentities: { - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -2413,7 +2417,7 @@ public async Task RoleAssignmentsWithAsExisting() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var storageName = builder.AddParameter("storageName"); var storageRG = builder.AddParameter("storageRG"); @@ -2453,10 +2457,10 @@ public async Task RoleAssignmentsWithAsExisting() "params": { "api_identity_outputs_id": "{api-identity.outputs.id}", "api_identity_outputs_clientid": "{api-identity.outputs.clientId}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -2499,13 +2503,13 @@ param api_identity_outputs_id string param api_identity_outputs_clientid string - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -2517,12 +2521,12 @@ param api_containerimage string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2557,7 +2561,7 @@ param api_containerimage string type: 'UserAssigned' userAssignedIdentities: { '${api_identity_outputs_id}': { } - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -2618,7 +2622,7 @@ public async Task RoleAssignmentsWithAsExistingCosmosDB() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var cosmosName = builder.AddParameter("cosmosName"); var cosmosRG = builder.AddParameter("cosmosRG"); @@ -2658,10 +2662,10 @@ public async Task RoleAssignmentsWithAsExistingCosmosDB() "api_identity_outputs_id": "{api-identity.outputs.id}", "api_identity_outputs_clientid": "{api-identity.outputs.clientId}", "cosmos_outputs_connectionstring": "{cosmos.outputs.connectionString}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -2706,13 +2710,13 @@ param api_identity_outputs_clientid string param cosmos_outputs_connectionstring string - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -2724,12 +2728,12 @@ param api_containerimage string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2768,7 +2772,7 @@ param api_containerimage string type: 'UserAssigned' userAssignedIdentities: { '${api_identity_outputs_id}': { } - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -2834,7 +2838,7 @@ public async Task RoleAssignmentsWithAsExistingRedis() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var redis = builder.AddAzureRedis("redis") .PublishAsExisting("myredis", "myRG"); @@ -2871,10 +2875,10 @@ public async Task RoleAssignmentsWithAsExistingRedis() "api_identity_outputs_id": "{api-identity.outputs.id}", "api_identity_outputs_clientid": "{api-identity.outputs.clientId}", "redis_outputs_connectionstring": "{redis.outputs.connectionString}", - "outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", - "outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", - "outputs_azure_container_registry_endpoint": "{.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", - "outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", + "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", + "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", + "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", + "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", "api_containerimage": "{api.containerImage}" } } @@ -2920,13 +2924,13 @@ param api_identity_outputs_clientid string param redis_outputs_connectionstring string - param outputs_azure_container_apps_environment_default_domain string + param env_outputs_azure_container_apps_environment_default_domain string - param outputs_azure_container_apps_environment_id string + param env_outputs_azure_container_apps_environment_id string - param outputs_azure_container_registry_endpoint string + param env_outputs_azure_container_registry_endpoint string - param outputs_azure_container_registry_managed_identity_id string + param env_outputs_azure_container_registry_managed_identity_id string param api_containerimage string @@ -2938,12 +2942,12 @@ param api_containerimage string activeRevisionsMode: 'Single' registries: [ { - server: outputs_azure_container_registry_endpoint - identity: outputs_azure_container_registry_managed_identity_id + server: env_outputs_azure_container_registry_endpoint + identity: env_outputs_azure_container_registry_managed_identity_id } ] } - environmentId: outputs_azure_container_apps_environment_id + environmentId: env_outputs_azure_container_apps_environment_id template: { containers: [ { @@ -2982,7 +2986,7 @@ param api_containerimage string type: 'UserAssigned' userAssignedIdentities: { '${api_identity_outputs_id}': { } - '${outputs_azure_container_registry_managed_identity_id}': { } + '${env_outputs_azure_container_registry_managed_identity_id}': { } } } } @@ -3045,7 +3049,7 @@ public async Task NonTcpHttpOrUdpSchemeThrows() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithEndpoint(scheme: "foo"); @@ -3064,7 +3068,7 @@ public async Task MultipleExternalEndpointsAreNotSupported() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(name: "ep1") @@ -3085,7 +3089,7 @@ public async Task ExternalNonHttpEndpointsAreNotSupported() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithEndpoint("ep1", e => e.IsExternal = true); @@ -3104,7 +3108,7 @@ public async Task HttpAndTcpEndpointsCannotHaveTheSameTargetPort() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(targetPort: 80) @@ -3124,7 +3128,7 @@ public async Task DefaultHttpIngressMustUsePort80() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpEndpoint(port: 8081); @@ -3143,7 +3147,7 @@ public async Task DefaultHttpsIngressMustUsePort443() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); builder.AddContainer("api", "myimage") .WithHttpsEndpoint(port: 8081); @@ -3178,7 +3182,9 @@ public async Task KnownParametersAreNotSetWhenUsingAzdResources() { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); +#pragma warning disable CS0618 // Type or member is obsolete builder.AddAzureContainerAppsInfrastructure(); +#pragma warning restore CS0618 // Type or member is obsolete var pg = builder.AddAzurePostgresFlexibleServer("pg") .WithPasswordAuthentication() diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs index 4c5475efbec..e9b5dbd176f 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureCosmosDBExtensionsTests.cs @@ -189,7 +189,7 @@ public async Task AddAzureCosmosDB(bool useAcaInfrastructure) if (useAcaInfrastructure) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); } var cosmos = builder.AddAzureCosmosDB("cosmos"); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureFunctionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureFunctionsTests.cs index cc5caa95897..1fcc0525a57 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureFunctionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureFunctionsTests.cs @@ -288,7 +288,7 @@ public async Task AddAzureFunctionsProject_CanGetStorageManifestSuccessfully() public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrastructure() { using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // hardcoded sha256 to make the storage name deterministic builder.Configuration["AppHost:Sha256"] = "634f8"; @@ -378,7 +378,7 @@ param principalId string public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrastructure_WithHostStorage() { using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // hardcoded sha256 to make the storage name deterministic var storage = builder.AddAzureStorage("my-own-storage").RunAsEmulator(); @@ -460,7 +460,7 @@ param principalId string public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrastructure_WithHostStorage_WithRoleAssignments() { using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // hardcoded sha256 to make the storage name deterministic var storage = builder.AddAzureStorage("my-own-storage").RunAsEmulator(); @@ -523,7 +523,7 @@ param principalId string public async Task MultipleAddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrastructure_WithHostStorage_WithRoleAssignments() { using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // hardcoded sha256 to make the storage name deterministic var storage = builder.AddAzureStorage("my-own-storage").RunAsEmulator(); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs index cc011572937..2d530ff2f1c 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzurePostgresExtensionsTests.cs @@ -24,7 +24,7 @@ public async Task AddAzurePostgresFlexibleServer(bool publishMode, bool useAcaIn if (useAcaInfrastructure) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // on ACA infrastructure, if there are no references to the postgres resource, // then there won't be any roles created. So add a reference here. diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureRedisExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureRedisExtensionsTests.cs index bc3d6481fda..4a6ffe33f3f 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureRedisExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureRedisExtensionsTests.cs @@ -25,7 +25,7 @@ public async Task AddAzureRedis(bool useAcaInfrastructure) if (useAcaInfrastructure) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); } var redis = builder.AddAzureRedis("redis-cache"); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs index d936b80dd07..d4d06b650b3 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureResourcePreparerTests.cs @@ -39,7 +39,7 @@ public async Task AppliesDefaultRoleAssignmentsInRunModeIfReferenced(bool addCon using var builder = TestDistributedApplicationBuilder.Create(operation); if (addContainerAppsInfra) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); } var storage = builder.AddAzureStorage("storage"); @@ -125,7 +125,7 @@ param principalId string public async Task AppliesRoleAssignmentsInRunMode(DistributedApplicationOperation operation) { using var builder = TestDistributedApplicationBuilder.Create(operation); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var storage = builder.AddAzureStorage("storage"); var blobs = storage.AddBlobs("blobs"); @@ -216,7 +216,7 @@ param principalId string public async Task FindsAzureReferencesFromArguments() { using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); var storage = builder.AddAzureStorage("storage"); var blobs = storage.AddBlobs("blobs"); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs index 0b00ea47faf..d352f1a6a80 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs @@ -26,7 +26,7 @@ public async Task AddAzureSqlServer(bool publishMode, bool useAcaInfrastructure) if (useAcaInfrastructure) { - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); // on ACA infrastructure, if there are no references to the resource, // then there won't be any roles created. So add a reference here. diff --git a/tests/Aspire.Hosting.Azure.Tests/PublicApiTests/AppContainersPublicApiTests.cs b/tests/Aspire.Hosting.Azure.Tests/PublicApiTests/AppContainersPublicApiTests.cs index c4385ae8c75..13be4479554 100644 --- a/tests/Aspire.Hosting.Azure.Tests/PublicApiTests/AppContainersPublicApiTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/PublicApiTests/AppContainersPublicApiTests.cs @@ -79,7 +79,9 @@ public void AddAzureContainerAppsInfrastructureShouldThrowWhenBuilderIsNull() var action = () => { +#pragma warning disable CS0618 // Type or member is obsolete builder.AddAzureContainerAppsInfrastructure(); +#pragma warning restore CS0618 // Type or member is obsolete }; var exception = Assert.Throws(action); diff --git a/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs b/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs index 699107183b2..693ec6e0e35 100644 --- a/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs @@ -469,7 +469,7 @@ private async Task RoleAssignmentTest( bool includePrincipalName = false) { var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish); - builder.AddAzureContainerAppsInfrastructure(); + builder.AddAzureContainerAppEnvironment("env"); configureBuilder(builder); From 42735e06f41d75569597088b20178fb88b98f893 Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Tue, 8 Apr 2025 11:37:29 -0700 Subject: [PATCH 36/41] Add error handling for package updates in workflow (#8390) --- .github/workflows/update-dependencies.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index efe58b870d5..fd812c4da37 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -31,7 +31,8 @@ jobs: run: dotnet tool install --global dotnet-outdated-tool - name: Update packages - run: dotnet outdated --no-restore -u ./Aspire.sln + continue-on-error: true + run: dotnet outdated --no-restore -u ./Aspire.sln || echo "Some dependencies could not be updated, but continuing workflow." - name: Revert all changes except Directory.Packages.props files run: | From d414db68c8a00b5cad31a1df862259362c1ac0ac Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Tue, 8 Apr 2025 11:56:14 -0700 Subject: [PATCH 37/41] Filter out tracing health endpoints in service defaults templates (#8643) * Filter out tracing health endpoints Fixes #8580 * Fix typo --- playground/TestShop/TestShop.AppHost/Program.cs | 6 ++++-- .../TestShop.ServiceDefaults/Extensions.cs | 14 +++++++++++--- .../Extensions.cs | 14 +++++++++++--- .../aspire-servicedefaults/9.2/Extensions.cs | 14 +++++++++++--- .../Extensions.cs | 14 +++++++++++--- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/playground/TestShop/TestShop.AppHost/Program.cs b/playground/TestShop/TestShop.AppHost/Program.cs index 401f728815b..9ea61680a14 100644 --- a/playground/TestShop/TestShop.AppHost/Program.cs +++ b/playground/TestShop/TestShop.AppHost/Program.cs @@ -62,14 +62,16 @@ .WithReference(basketCache) .WithReference(messaging).WaitFor(messaging); -builder.AddProject("frontend") +var frontend = builder.AddProject("frontend") .WithExternalHttpEndpoints() .WithReference(basketService) .WithReference(catalogService) .WithUrls(c => c.Urls.ForEach(u => u.DisplayText = $"Online store ({u.Endpoint?.EndpointName})")); +var _ = frontend.GetEndpoint("https").Exists ? frontend.WithHttpsHealthCheck("/health") : frontend.WithHttpHealthCheck("/health"); + builder.AddProject("orderprocessor", launchProfileName: "OrderProcessor") - .WithReference(messaging).WaitFor(messaging); + .WithReference(messaging).WaitFor(messaging); builder.AddProject("apigateway") .WithReference(basketService) diff --git a/playground/TestShop/TestShop.ServiceDefaults/Extensions.cs b/playground/TestShop/TestShop.ServiceDefaults/Extensions.cs index 5001ccebeac..5ec75c84763 100644 --- a/playground/TestShop/TestShop.ServiceDefaults/Extensions.cs +++ b/playground/TestShop/TestShop.ServiceDefaults/Extensions.cs @@ -14,6 +14,9 @@ namespace Microsoft.Extensions.Hosting; // To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { + private const string HealthEndpointPath = "/health"; + private const string AlivenessEndpointPath = "/alive"; + public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder { builder.ConfigureOpenTelemetry(); @@ -52,7 +55,12 @@ public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) w }) .WithTracing(tracing => { - tracing.AddAspNetCoreInstrumentation() + tracing + .AddAspNetCoreInstrumentation(tracing => + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) .AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); }); @@ -97,10 +105,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) if (app.Environment.IsDevelopment()) { // All health checks must pass for app to be considered ready to accept traffic after starting - app.MapHealthChecks("/health"); + app.MapHealthChecks(HealthEndpointPath); // Only health checks tagged with the "live" tag must pass for app to be considered alive - app.MapHealthChecks("/alive", new HealthCheckOptions + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") }); diff --git a/src/Aspire.ProjectTemplates/templates/aspire-empty/9.2/AspireApplication.1.ServiceDefaults/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-empty/9.2/AspireApplication.1.ServiceDefaults/Extensions.cs index 13151bf46d9..112c1281479 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-empty/9.2/AspireApplication.1.ServiceDefaults/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-empty/9.2/AspireApplication.1.ServiceDefaults/Extensions.cs @@ -15,6 +15,9 @@ namespace Microsoft.Extensions.Hosting; // To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { + private const string HealthEndpointPath = "/health"; + private const string AlivenessEndpointPath = "/alive"; + public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder { builder.ConfigureOpenTelemetry(); @@ -59,7 +62,12 @@ public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) w .WithTracing(tracing => { tracing.AddSource(builder.Environment.ApplicationName) - .AddAspNetCoreInstrumentation() + .AddAspNetCoreInstrumentation(tracing => + // Exclude health check requests from tracing + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); @@ -105,10 +113,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) if (app.Environment.IsDevelopment()) { // All health checks must pass for app to be considered ready to accept traffic after starting - app.MapHealthChecks("/health"); + app.MapHealthChecks(HealthEndpointPath); // Only health checks tagged with the "live" tag must pass for app to be considered alive - app.MapHealthChecks("/alive", new HealthCheckOptions + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") }); diff --git a/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/9.2/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/9.2/Extensions.cs index 13151bf46d9..112c1281479 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/9.2/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/9.2/Extensions.cs @@ -15,6 +15,9 @@ namespace Microsoft.Extensions.Hosting; // To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { + private const string HealthEndpointPath = "/health"; + private const string AlivenessEndpointPath = "/alive"; + public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder { builder.ConfigureOpenTelemetry(); @@ -59,7 +62,12 @@ public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) w .WithTracing(tracing => { tracing.AddSource(builder.Environment.ApplicationName) - .AddAspNetCoreInstrumentation() + .AddAspNetCoreInstrumentation(tracing => + // Exclude health check requests from tracing + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); @@ -105,10 +113,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) if (app.Environment.IsDevelopment()) { // All health checks must pass for app to be considered ready to accept traffic after starting - app.MapHealthChecks("/health"); + app.MapHealthChecks(HealthEndpointPath); // Only health checks tagged with the "live" tag must pass for app to be considered alive - app.MapHealthChecks("/alive", new HealthCheckOptions + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") }); diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.ServiceDefaults/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.ServiceDefaults/Extensions.cs index 13151bf46d9..112c1281479 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.ServiceDefaults/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.ServiceDefaults/Extensions.cs @@ -15,6 +15,9 @@ namespace Microsoft.Extensions.Hosting; // To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { + private const string HealthEndpointPath = "/health"; + private const string AlivenessEndpointPath = "/alive"; + public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder { builder.ConfigureOpenTelemetry(); @@ -59,7 +62,12 @@ public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) w .WithTracing(tracing => { tracing.AddSource(builder.Environment.ApplicationName) - .AddAspNetCoreInstrumentation() + .AddAspNetCoreInstrumentation(tracing => + // Exclude health check requests from tracing + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); @@ -105,10 +113,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) if (app.Environment.IsDevelopment()) { // All health checks must pass for app to be considered ready to accept traffic after starting - app.MapHealthChecks("/health"); + app.MapHealthChecks(HealthEndpointPath); // Only health checks tagged with the "live" tag must pass for app to be considered alive - app.MapHealthChecks("/alive", new HealthCheckOptions + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") }); From 5f89e7d21fadb07b7f4f100330cb9ac2741c993d Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Tue, 8 Apr 2025 13:21:06 -0600 Subject: [PATCH 38/41] Show neutral icon for container exiting with status code 0 (#8477) * Show neutral icon for container exiting with status code 0 * Show info/stop icons for all exited resources with status code 0 * Add finished test for custom resource, remove exit code expectation * update tests --- .../Extensions/ResourceViewModelExtensions.cs | 5 +++ .../Model/ResourceStateViewModel.cs | 2 +- .../Model/ResourceStateViewModelTests.cs | 39 +++++++++++-------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs b/src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs index d5ef389a857..625c9becfa9 100644 --- a/src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs +++ b/src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs @@ -22,6 +22,11 @@ public static bool IsFinishedState(this ResourceViewModel resource) return resource.KnownState is KnownResourceState.Finished; } + public static bool IsExitedState(this ResourceViewModel resource) + { + return resource.KnownState is KnownResourceState.Exited; + } + public static bool IsStopped(this ResourceViewModel resource) { return resource.KnownState is KnownResourceState.Exited or KnownResourceState.Finished or KnownResourceState.FailedToStart; diff --git a/src/Aspire.Dashboard/Model/ResourceStateViewModel.cs b/src/Aspire.Dashboard/Model/ResourceStateViewModel.cs index 02c51eaeb24..7882248f983 100644 --- a/src/Aspire.Dashboard/Model/ResourceStateViewModel.cs +++ b/src/Aspire.Dashboard/Model/ResourceStateViewModel.cs @@ -42,7 +42,7 @@ private static (Icon icon, Color color) GetStateIcon(ResourceViewModel resource) icon = new Icons.Filled.Size16.ErrorCircle(); color = Color.Error; } - else if (resource.IsFinishedState()) + else if (resource.IsFinishedState() || resource.IsExitedState()) { // Process completed successfully. icon = new Icons.Regular.Size16.RecordStop(); diff --git a/tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs b/tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs index f6475080a0d..2aba11ce4dc 100644 --- a/tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs +++ b/tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs @@ -15,45 +15,50 @@ namespace Aspire.Dashboard.Tests.Model; public class ResourceStateViewModelTests { - private const string ResourceType = "Container"; - [Theory] // Resource is no longer running [InlineData( - /* state */ KnownResourceState.Exited, null, null,null, - /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:{ResourceType}", "Warning", Color.Warning, "Exited")] + /* state */ "Container", KnownResourceState.Exited, null, null,null, + /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:Container", "RecordStop", Color.Info, "Exited")] + [InlineData( + /* state */ "Container", KnownResourceState.Exited, 3, null, null, + /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExitedUnexpectedly)}:Container+3", "ErrorCircle", Color.Error, "Exited")] + [InlineData( + /* state */ "Container", KnownResourceState.Exited, 0, null, null, + /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:Container", "RecordStop", Color.Info, "Exited")] [InlineData( - /* state */ KnownResourceState.Exited, 3, null, null, - /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExitedUnexpectedly)}:{ResourceType}+3", "ErrorCircle", Color.Error, "Exited")] + /* state */ "Container", KnownResourceState.Finished, 0, null, null, + /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:Container", "RecordStop", Color.Info, "Finished")] [InlineData( - /* state */ KnownResourceState.Finished, 0, null, null, - /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:{ResourceType}", "RecordStop", Color.Info, "Finished")] + /* state */ "CustomResource", KnownResourceState.Finished, null, null, null, + /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceExited)}:CustomResource", "RecordStop", Color.Info, "Finished")] [InlineData( - /* state */ KnownResourceState.Unknown, null, null, null, + /* state */ "Container", KnownResourceState.Unknown, null, null, null, /* expected output */ "Unknown", "CircleHint", Color.Info, "Unknown")] // Health checks [InlineData( - /* state */ KnownResourceState.Running, null, "Healthy", null, + /* state */ "Container", KnownResourceState.Running, null, "Healthy", null, /* expected output */ "Running", "CheckmarkCircle", Color.Success, "Running")] [InlineData( - /* state */ KnownResourceState.Running, null, "", null, + /* state */ "Container", KnownResourceState.Running, null, "", null, /* expected output */ $"Localized:{nameof(Columns.RunningAndUnhealthyResourceStateToolTip)}", "CheckmarkCircleWarning", Color.Warning, "Running (Unhealthy)")] [InlineData( - /* state */ KnownResourceState.Running, null, "Unhealthy", null, + /* state */ "Container", KnownResourceState.Running, null, "Unhealthy", null, /* expected output */ $"Localized:{nameof(Columns.RunningAndUnhealthyResourceStateToolTip)}", "CheckmarkCircleWarning", Color.Warning, "Running (Unhealthy)")] [InlineData( - /* state */ KnownResourceState.Running, null, "Healthy", "warning", + /* state */ "Container", KnownResourceState.Running, null, "Healthy", "warning", /* expected output */ "Running", "Warning", Color.Warning, "Running")] [InlineData( - /* state */ KnownResourceState.Running, null, "Healthy", "NOT_A_VALID_STATE_STYLE", + /* state */ "Container", KnownResourceState.Running, null, "Healthy", "NOT_A_VALID_STATE_STYLE", /* expected output */ "Running", "Circle", Color.Neutral, "Running")] [InlineData( - /* state */ KnownResourceState.Running, null, null, "info", + /* state */ "Container", KnownResourceState.Running, null, null, "info", /* expected output */ "Running", "Info", Color.Info, "Running")] [InlineData( - /* state */ KnownResourceState.RuntimeUnhealthy, null, null, null, + /* state */ "Container", KnownResourceState.RuntimeUnhealthy, null, null, null, /* expected output */ $"Localized:{nameof(Columns.StateColumnResourceContainerRuntimeUnhealthy)}", "Warning", Color.Warning, "Runtime unhealthy")] public void ResourceViewModel_ReturnsCorrectIconAndTooltip( + string resourceType, KnownResourceState state, int? exitCode, string? healthStatusString, @@ -76,7 +81,7 @@ public void ResourceViewModel_ReturnsCorrectIconAndTooltip( reportHealthStatus: healthStatus, createNullHealthReport: healthStatusString == "", stateStyle: stateStyle, - resourceType: ResourceType, + resourceType: resourceType, properties: propertiesDictionary); if (exitCode is not null) From ec6cacb672678a4a9fd9d9fa873010a759e675a2 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 8 Apr 2025 16:05:54 -0400 Subject: [PATCH 39/41] [tests] Correctly mark Aspire.Dashboard.Tests.Integration.Playwright.AppBarTests with RequiresPlaywright (#8647) --- .../Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs b/tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs index aa5a20b9532..f48b6b5d031 100644 --- a/tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs +++ b/tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs @@ -10,6 +10,7 @@ namespace Aspire.Dashboard.Tests.Integration.Playwright; +[RequiresPlaywright] public class AppBarTests : PlaywrightTestsBase { public AppBarTests(DashboardServerFixture dashboardServerFixture) From 5958a02a34b0dc5c966b9717a33aba892d2d933b Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 8 Apr 2025 16:54:02 -0400 Subject: [PATCH 40/41] [tests] Skip generating Directory.Packages.Versions.props for Test (#8621) .. Utility projects. --- tests/Shared/RepoTesting/Aspire.RepoTesting.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets index 90e4cb9d5e6..4f3c9834786 100644 --- a/tests/Shared/RepoTesting/Aspire.RepoTesting.targets +++ b/tests/Shared/RepoTesting/Aspire.RepoTesting.targets @@ -108,7 +108,7 @@ - + <_PackageVersionEvaluated Include="@(PackageVersion -> '<PackageVersion Include="%(Identity)" Version="%(Version)" />')" /> From ddf0755db214bcda00e43f5221ccd267ac629084 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 9 Apr 2025 10:52:32 -0400 Subject: [PATCH 41/41] Fix running playground tests on windows --- tests/Directory.Build.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 14020f40876..bf1b4461737 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -61,7 +61,8 @@ - + +