asimmon / ephemeral-mongo

EphemeralMongo is a set of three NuGet packages wrapping the binaries of MongoDB 4, 5 and 6 built for .NET Standard 2.0.
Apache License 2.0
103 stars 12 forks source link

ConnectionTimeout when running unit test twice #58

Closed mdhom closed 3 weeks ago

mdhom commented 3 weeks ago

Dear all,

I created a UnitTest that uses ephemeral-mongo for creating a mongo collection. When running the unit test first, it is completed successfully. After that first run, I can see in Activity Monitor that mongod is still running. When I attempt a second run, the unit test fails with a ConnectionTimeout:

System.TimeoutException : MongoDB connection availability took longer than the specified timeout of 10 seconds. Consider increasing the value of 'ConnectionTimeout'.
   at EphemeralMongo.MongodProcess.StartAndWaitForConnectionReadiness()
   at EphemeralMongo.MongodProcess.Start()
   at EphemeralMongo.MongoRunner.RunInternal()
   at EphemeralMongo.MongoRunner.Run(MongoRunnerOptions options)
   at MongoRunnerProvider.Get() in 

When I manually kill the mongod process, the unit test sucessfully runs again.

I used the MongoRunnerProvider from the provided gist. I run the unit tests in VS Code on Mac OS. NuGet dependencies used are

<PackageReference Include="EphemeralMongo.Core" Version="1.1.3" />
<PackageReference Include="EphemeralMongo6.runtime.linux-x64" Version="1.1.3" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<PackageReference Include="EphemeralMongo6.runtime.osx-x64" Version="1.1.3" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
<PackageReference Include="EphemeralMongo6.runtime.win-x64" Version="1.1.3" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
mdhom commented 3 weeks ago

Problem solved, sorry. We did not properly dispose the MongoRunnerWrapper.