CommunityToolkit / Aspire

A community project with additional components and extensions for .NET Aspire
MIT License
233 stars 29 forks source link

SWA health checks #175

Closed aaronpowell closed 4 weeks ago

aaronpowell commented 1 month ago

Closes #74

Using the new WaitFor API in Aspire 9 means that if the app/api resources provide health checks then we will wait for them to be healthy before the SWA emulator starts, otherwise it will wait until the resource launches.

Then added the built-in WithHttpHealthCheck for the SWA emulator itself and pointing that at a known endpoint (/.auth/me) and once that's up we are healthy.

PR Checklist

Other information

aaronpowell commented 1 month ago

I'll have a play with it and test a few falling scenarios.

The SWA emulator is a proxy in front of other http endpoints, so we wait for them before the emulator starts.

aaronpowell commented 1 month ago

@Alirexaa I've had a play around with writing tests like that and I don't think they are going to give the best value to effort in writing and maintaining, at least not for SWA.

I have unit tests in the PR that assert that the WaitAnnotation is being added to the SwaResource for the app/api when you call their respective methods, which I think is the best approach here. If we try to write integration tests and simulate failing health checks, what we're really doing is testing how the health check system in Aspire works rather than just our integrations usage of it.

github-actions[bot] commented 1 month ago

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 6
CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps 100% 100% 28
CommunityToolkit.Aspire.Hosting.Deno 84% 75% 72
CommunityToolkit.Aspire.Hosting.Golang 94% 50% 16
CommunityToolkit.Aspire.Hosting.Java 98% 71% 58
CommunityToolkit.Aspire.Hosting.Meilisearch 61% 27% 94
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 90% 68% 92
CommunityToolkit.Aspire.Hosting.Ollama 52% 32% 154
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.OllamaSharp 92% 80% 30
Summary 78% (1118 / 1428) 56% (263 / 472) 618

Minimum allowed line rate is 60%