Open SilverioMiranda opened 2 weeks ago
Hi, why do you think this is an issue? Why shouldn't it take that long for the port and service to be up and running? I think it might even take a bit longer until Cosmos DB is fully ready. The following test takes just as long:
docker network create nw0
# Image size is ~2.35 GB
# docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
# Image size is ~8 MB
# docker pull alpine:latest
$startTime = (Get-Date)
docker run --detach --network nw0 --net-alias cosmosdb --name cosmosdb --rm mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
docker run --rm --network nw0 alpine sh -c 'while ! nc -z cosmosdb 8081; do echo "Retrying..."; sleep 1; done'
$timeTaken = (Get-Date) - $startTime
Write-Output "Connection to Cosmos DB established in $($timeTaken.TotalSeconds) seconds."
a8c88f724c0340f59f2e58a648a9c5a53493a7acefe5c226c053711bb11b5849
711b4ba876eb576085e55f0b59e8dc21a6592ac4107b5a806fcb7de9b2d79709
Retrying...
Retrying...
Connection to Cosmos DB established in 103.8691404 seconds.
I don't believe this is a problem with Testcontainers. It seems more like an "issue" with the Cosmos DB Emulator.
It should be faster, right? When using it together with Microsoft Aspire running the emulator, it takes about 30 seconds to start and become available.
Could you please share a reproducer (in Aspire) that runs the emulator locally and attempts to read the account information, similar to what we're doing in our test? This would make it easier to compare.
I remember that we changed the wait strategy because the previous one indicated readiness too early and was not reliable: https://github.com/testcontainers/testcontainers-dotnet/pull/1109. The CLI example takes just as long. I'm curious what Aspire uses.
Testcontainers version
3.9.0
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host arch
x64
.NET version
8.0.304
Docker version
Docker info
What happened?
The call await _cosmosDbContainer.StartAsync(); consistently takes approximately 105,294 ms to complete.
This issue likely wasn't detected earlier because the test at CosmosDbContainerTest.cs#L18 is skipped during tests.
Here is the repository with the example experiencing this problem: https://github.com/SilverioMiranda/testcontainers-cosmosdb.
Relevant log output
No response
Additional information
https://github.com/SilverioMiranda/testcontainers-cosmosdb