Skip to content

Commit aee52a7

Browse files
Taking Damian's changes from 8.1 update (#393)
Taking changes from #238 * Add ContainerBuild to Endpoints test * Minor PR feedback --------- Co-authored-by: Damian Edwards <[email protected]>
1 parent d5c8f40 commit aee52a7

23 files changed

+113
-816
lines changed

for.dependabot.only.sln

-10
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ContainerBuild", "Container
205205
EndProject
206206
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ContainerBuild.AppHost", "ContainerBuild.AppHost", "{822059E3-B561-4329-A3B0-7361B99010C2}"
207207
EndProject
208-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ContainerBuild.ServiceDefaults", "ContainerBuild.ServiceDefaults", "{A2BD5B68-6077-4D6B-8424-5681CB727EDA}"
209-
EndProject
210208
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBuild.AppHost", "samples\ContainerBuild\ContainerBuild.AppHost\ContainerBuild.AppHost.csproj", "{6CBC58E6-D989-4CA3-A2CF-B76E57D00DCA}"
211209
EndProject
212-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBuild.ServiceDefaults", "samples\ContainerBuild\ContainerBuild.ServiceDefaults\ContainerBuild.ServiceDefaults.csproj", "{81A46F67-0529-4FFD-8E07-FF908DC16ACB}"
213-
EndProject
214210
Global
215211
GlobalSection(SolutionConfigurationPlatforms) = preSolution
216212
Debug|Any CPU = Debug|Any CPU
@@ -393,10 +389,6 @@ Global
393389
{6CBC58E6-D989-4CA3-A2CF-B76E57D00DCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
394390
{6CBC58E6-D989-4CA3-A2CF-B76E57D00DCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
395391
{6CBC58E6-D989-4CA3-A2CF-B76E57D00DCA}.Release|Any CPU.Build.0 = Release|Any CPU
396-
{81A46F67-0529-4FFD-8E07-FF908DC16ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
397-
{81A46F67-0529-4FFD-8E07-FF908DC16ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
398-
{81A46F67-0529-4FFD-8E07-FF908DC16ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
399-
{81A46F67-0529-4FFD-8E07-FF908DC16ACB}.Release|Any CPU.Build.0 = Release|Any CPU
400392
EndGlobalSection
401393
GlobalSection(SolutionProperties) = preSolution
402394
HideSolutionNode = FALSE
@@ -501,9 +493,7 @@ Global
501493
{9FFD7691-545A-44CF-8F36-1D9B815B246A} = {AA612AC9-EF29-469A-A9AA-EEC4E689F68E}
502494
{974F9511-3C06-4603-AE52-614DC0E4B259} = {D5E0613C-C510-43CD-A1FD-32A3DF107114}
503495
{822059E3-B561-4329-A3B0-7361B99010C2} = {974F9511-3C06-4603-AE52-614DC0E4B259}
504-
{A2BD5B68-6077-4D6B-8424-5681CB727EDA} = {974F9511-3C06-4603-AE52-614DC0E4B259}
505496
{6CBC58E6-D989-4CA3-A2CF-B76E57D00DCA} = {822059E3-B561-4329-A3B0-7361B99010C2}
506-
{81A46F67-0529-4FFD-8E07-FF908DC16ACB} = {A2BD5B68-6077-4D6B-8424-5681CB727EDA}
507497
EndGlobalSection
508498
GlobalSection(ExtensibilityGlobals) = postSolution
509499
SolutionGuid = {87311815-2079-44E3-BA47-CC1B54811047}

samples/AspireShop/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The app also includes a class library project, **AspireShop.ServiceDefaults**, t
2727

2828
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
2929
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
30-
- **Optional** [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
30+
- **Optional** [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
3131

3232
## Running the app
3333

samples/AspireWithJavaScript/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The app consists of four services:
2727
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
2828
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
2929
- [Node.js](https://nodejs.org) - at least version 20.7.0
30-
- **Optional** [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
30+
- **Optional** [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
3131

3232
## Running the app
3333

samples/AspireWithNode/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The app consists of two services:
2525
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
2626
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
2727
- [Node.js](https://nodejs.org) - at least version 20.9.0
28-
- **Optional** [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
28+
- **Optional** [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
2929

3030
## Running the app
3131

samples/ClientAppsIntegration/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The app is based on the Aspire Starter App template, with the following addition
2727

2828
- A Windows OS supported by .NET 8 (e.g. Windows 10/11)
2929
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
30-
- [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
30+
- [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
3131

3232
## Running the app
3333

samples/ContainerBuild/ContainerBuild.ServiceDefaults/ContainerBuild.ServiceDefaults.csproj

-22
This file was deleted.

samples/ContainerBuild/ContainerBuild.ServiceDefaults/Extensions.cs

-111
This file was deleted.

samples/ContainerBuild/ContainerBuild.sln

-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ VisualStudioVersion = 17.8.0.0
44
MinimumVisualStudioVersion = 17.8.0.0
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBuild.AppHost", "ContainerBuild.AppHost\ContainerBuild.AppHost.csproj", "{45D01DF6-369D-4C4F-84B9-D7328885485E}"
66
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerBuild.ServiceDefaults", "ContainerBuild.ServiceDefaults\ContainerBuild.ServiceDefaults.csproj", "{514937E6-47F0-4A2A-9CC3-E75C8EC09456}"
8-
EndProject
97
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ginapp", "ginapp", "{84E36F54-79F1-4438-8D0D-834B36EFAB8D}"
108
ProjectSection(SolutionItems) = preProject
119
ginapp\Dockerfile = ginapp\Dockerfile
@@ -23,10 +21,6 @@ Global
2321
{45D01DF6-369D-4C4F-84B9-D7328885485E}.Debug|Any CPU.Build.0 = Debug|Any CPU
2422
{45D01DF6-369D-4C4F-84B9-D7328885485E}.Release|Any CPU.ActiveCfg = Release|Any CPU
2523
{45D01DF6-369D-4C4F-84B9-D7328885485E}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{514937E6-47F0-4A2A-9CC3-E75C8EC09456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{514937E6-47F0-4A2A-9CC3-E75C8EC09456}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{514937E6-47F0-4A2A-9CC3-E75C8EC09456}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{514937E6-47F0-4A2A-9CC3-E75C8EC09456}.Release|Any CPU.Build.0 = Release|Any CPU
3024
EndGlobalSection
3125
GlobalSection(SolutionProperties) = preSolution
3226
HideSolutionNode = FALSE

samples/DatabaseContainers/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The app consists of an API service:
3232

3333
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
3434
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
35-
- **Optional** [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
35+
- **Optional** [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
3636

3737
## Running the app
3838

samples/VolumeMount/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The app also includes a standard class library project, **VolumeMount.ServiceDef
2424

2525
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
2626
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
27-
- **Optional** [Visual Studio 2022 17.9 Preview](https://visualstudio.microsoft.com/vs/preview/)
27+
- **Optional** [Visual Studio 2022 17.10](https://visualstudio.microsoft.com/vs/preview/)
2828

2929
## Running the app
3030

tests/SamplesIntegrationTests/AppHostTests.cs

+13-41
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ public async Task AppHostRunsCleanly(string appHostPath)
1919
var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostPath, testOutput);
2020
await using var app = await appHost.BuildAsync();
2121

22-
var appHostLogs = app.GetAppHostLogs();
23-
var resourceLogs = app.GetResourceLogs();
22+
await app.StartAsync();
23+
await app.WaitForResources().WaitAsync(TimeSpan.FromSeconds(30));
2424

25-
await app.StartAsync(waitForResourcesToStart: true);
26-
27-
EnsureNoErrors(appHostLogs, appHostPath);
28-
resourceLogs.EnsureNoErrors(ShouldAssertErrorsForResource);
25+
app.EnsureNoErrorsLogged();
2926

3027
await app.StopAsync();
3128
}
@@ -42,18 +39,16 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
4239
var projects = appHost.Resources.OfType<ProjectResource>();
4340
await using var app = await appHost.BuildAsync();
4441

45-
var appHostLogs = app.GetAppHostLogs();
46-
var resourceLogs = app.GetResourceLogs();
47-
48-
await app.StartAsync(waitForResourcesToStart: true);
42+
await app.StartAsync();
43+
await app.WaitForResources().WaitAsync(TimeSpan.FromSeconds(30));
4944

5045
if (testEndpoints.WaitForResources?.Count > 0)
5146
{
5247
// Wait until each resource transitions to the required state
5348
var timeout = TimeSpan.FromMinutes(5);
5449
foreach (var (ResourceName, TargetState) in testEndpoints.WaitForResources)
5550
{
56-
await app.WaitForResource(ResourceName, TargetState, new CancellationTokenSource(timeout).Token);
51+
await app.WaitForResource(ResourceName, TargetState).WaitAsync(timeout);
5752
}
5853
}
5954

@@ -75,10 +70,10 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
7570
.ConfigureHttpClient(client => client.Timeout = Timeout.InfiniteTimeSpan)
7671
.AddStandardResilienceHandler(resilience =>
7772
{
78-
resilience.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(300);
73+
resilience.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(120);
7974
resilience.AttemptTimeout.Timeout = TimeSpan.FromSeconds(60);
8075
resilience.Retry.MaxRetryAttempts = 30;
81-
resilience.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(300);
76+
resilience.CircuitBreaker.SamplingDuration = resilience.AttemptTimeout.Timeout * 2;
8277
});
8378
});
8479

@@ -105,37 +100,11 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
105100
}
106101
}
107102

108-
EnsureNoErrors(appHostLogs, appHostPath);
109-
resourceLogs.EnsureNoErrors(ShouldAssertErrorsForResource);
103+
app.EnsureNoErrorsLogged();
110104

111105
await app.StopAsync();
112106
}
113107

114-
private static bool ShouldAssertErrorsForResource(IResource resource)
115-
{
116-
return resource
117-
is
118-
// Container resources tend to write to stderr for various reasons so only assert projects and executables
119-
(ProjectResource or ExecutableResource)
120-
// Node resources tend to have npm modules that write to stderr so ignore them
121-
and not NodeAppResource
122-
// Dapr resources write to stderr about deprecated --components-path flag
123-
&& !resource.Name.EndsWith("-dapr-cli");
124-
}
125-
126-
private static void EnsureNoErrors(LoggerLogStore appHostLogs, string appHostPath)
127-
{
128-
var appHostName = Path.GetFileNameWithoutExtension(appHostPath);
129-
130-
// Container resources tend to write to stderr for various reasons.
131-
// Only assert errors for the app host and skip resources. Resources will be checked separately
132-
// in the resourceLogs above.
133-
// See also https://github.com/dotnet/aspire/issues/5094
134-
135-
appHostLogs.EnsureNoErrors(categoryName
136-
=> !categoryName.StartsWith($"{appHostName}.Resources.", StringComparison.Ordinal));
137-
}
138-
139108
public static TheoryData<string> AppHostAssemblies()
140109
{
141110
var appHostAssemblies = GetSamplesAppHostAssemblyPaths();
@@ -169,14 +138,17 @@ public static TheoryData<TestEndpoints> TestEndpoints() =>
169138
new TestEndpoints("ClientAppsIntegration.AppHost", new() {
170139
{ "apiservice", ["/alive", "/health", "/weatherforecast"] }
171140
}),
141+
new TestEndpoints("ContainerBuild.AppHost", new() {
142+
{ "ginapp", ["/"] }
143+
}),
172144
new TestEndpoints("DatabaseContainers.AppHost", new() {
173145
{ "apiservice", ["/alive", "/health", "/todos", "/todos/1", "/catalog", "/catalog/1", "/addressbook", "/addressbook/1"] }
174146
}),
175147
new TestEndpoints("DatabaseMigrations.AppHost", new() {
176148
{ "api", ["/alive", "/health", "/"] }
177149
})
178150
{
179-
WaitForResources = [new("migration", "Finished")]
151+
WaitForResources = [new("migration", KnownResourceStates.Finished)]
180152
},
181153
new TestEndpoints("HealthChecksUI.AppHost", new() {
182154
{ "apiservice", ["/alive", "/health", "/weatherforecast"] },

0 commit comments

Comments
 (0)