-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aspire.Hosting.Mongodb hangs / freezes in testing. #6871
Comments
Are you using rider? |
Yes |
Same as this #6695? Make sure your tooling is up to date and if it still persists file an issue on the rider aspire plugin. |
I have similar issue but not mongodb related. I use JetBrains Rider and .WaitForCompletion() never (sometime, randomly it does) completes. Project properly returns 0 but completition never triggers. It happens randomly, sometimes it passes sometimes not. I can't catch the bug. |
@filipbekic01 can you share the application? It's unclear what you are running into. |
Our DbMigrations app runs first in Aspire, ensuring migrations are applied before the Web app starts. However, ~50% of the time, the Web app waits indefinitely for migrations to finish. Keep in mind that migrations always return 0 when this bug happens, which means it executes successfully. Migrations app: using Sample;
namespace Sample.DatabaseMigrationsProject;
public class Program
{
public static async Task<int> Main(string[] args)
{
try
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// We run migrations here, they execute successfully.
using IHost app = builder.Build();
await app.StartAsync();
await app.StopAsync();
return 0; // It does return 0, checked several times.
}
catch (Exception ex)
{
Console.WriteLine($"Application encountered an error: {ex.Message}");
return 1;
}
}
} Aspire app: using Projects;
using Shared.Configuration;
namespace Dam.Aspire;
public class Program
{
public static async Task Main(string[] args)
{
IDistributedApplicationBuilder builder = DistributedApplication.CreateBuilder(args);
await builder.Configuration.SetupConfigurationAsync(builder.Environment);
// Postgre database
IResourceBuilder<ParameterResource> dbUser = builder.AddParameter("dbUser", "our_username", secret: true);
IResourceBuilder<ParameterResource> dbPass = builder.AddParameter("dbPass", "our_password", secret: true);
IResourceBuilder<PostgresServerResource> postgresEngine = builder.AddPostgres(
name: "postgres",
userName: dbUser,
password: dbPass
)
.WithDataVolume(name: "pgsql-volume")
.WithEndpoint(name: "postgres-endpoint", port: 5432, isProxied: false)
.WithLifetime(ContainerLifetime.Persistent);
IResourceBuilder<PostgresDatabaseResource> postgresDb = postgresEngine.AddDatabase("PostgresDb", "db_connection_string");
// Migrations
IResourceBuilder<ProjectResource> migrateAndSeed = builder.AddProject<Dam_MigrateAndSeed>("migrate-and-seed")
.WaitFor(postgresDb);
// Start web app
builder
.AddProject<Dam_UI_Web>("dam-ui-web")
.WaitForCompletion(migrateAndSeed);
await builder.Build().RunAsync();
}
} |
Its unclear if this is a related issue, I think you need to file a new one, with the entire runnable code sample. There might be a problem in SetupConfigurationAsync and that't not aspire logic. |
Method SetupConfigurationAsync reads JSON configuration files, quite trivial logic there. We can consider it as optional. Okay I'll try to provide runnable code here soon. |
Is there an existing issue for this?
Describe the bug
Env.
.NET 9
MacOs 15.1
Rider 2024.3
Application Stack
.net aspire orchestration
asp.net core api.
mongodb database.
Nunit Test project
As documentation My .net aspire project do not work properly in test. Test are hanging every time in app.StartAsync(). And i found exactly when.
This is my test
And this is my AppHost
but when i remove .WaitFor(mongodatabase) line it start to working correctly.
Expected Behavior
Distributed application start in tests
Steps To Reproduce
Create AppHost with Api
Install Aspire.Hosting.MongoDb.
Add reference to mongodb and invoce WaitFor(mongodb) in AppHost config
Create test project and create test NUnit
var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AppHost1>();
var app = await builder.BuildAsync();
await app.StartAsync();
Assert.Pass();
Exceptions (if any)
Test just hanging forever on this await app.StartAsync();
.NET Version info
.NET SDK:
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660
Runtime Environment:
OS Name: Mac OS X
OS Version: 15.1
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.100/
.NET workloads installed:
[maui]
Installation Source: SDK 9.0.100
Manifest Version: 9.0.0/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.0/WorkloadManifest.json
Install Type: FileBased
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.0
Architecture: arm64
Commit: 9d5a6a9aa4
.NET SDKs installed:
9.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Anything else?
No response
The text was updated successfully, but these errors were encountered: