-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Testcontainer for CosmosDB Emulator #549
Testcontainer for CosmosDB Emulator #549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution and pull request 🙏.
I have added some suggestions (or questions). I did not review CosmosDbHttpHandler
incl. the tests. I will do that at the end. Please consider to fix the code smells (warnings) too, thanks.
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
Thanks for the thourough review! Will get back to this later this week hopefully. |
…iners-dotnet into feature/cosmosdb-testcontainer
Still WIP but improved a bit to model it after the recent work on the Azurite container. I came to the conclusion that it's kinda nuts to implement the client stuff in the container, can just let the user take care of that :). |
0b183b3
to
dad2dc9
Compare
@Yeseh You are not connecting the output consumer. Add: .WithOutputConsumer(configuration.OutputConsumer). Also add a this.OutputConsumer = Consume.RedirectStdoutAndStderrToStream(new MemoryStream(), new MemoryStream()); If you want I can help out with this. |
Ah that makes a lot of sense. Be my guest with helping, i'm massively short on time atm :) |
Ok. I currently have a working CosmosDbFixture which can be used to fix this. One thing to note is that the host is not always "localhost" depending on where docker is running. I can fork your repo or you can give me access to your witchevey you prefer. |
@Yeseh Did some quick changes to make the test work. I think the mongo api should be separated into some subclass. Messy with all properties. |
@ktjn Thanks a lot! Definitely agree on the mongo part. Think the best route is a separate testcontainer altogether, because of all the differences. What do you think? |
Yes, at least do the sql mode first. Btw, I saw the build was stuck. It might have to do with "localhost" and running on linux. I guess we should try to remove the cosmosdb client dependency and go for a pure http based test as well? |
It's getting stuck at: I works fine on windows and wsl. I'll setup a linux vm and will try it there. |
…eseh/testcontainers-dotnet into feature/cosmosdb-testcontainer
The test still works on a linux vm. Added a 5 min timeout so it doesn't run forever. Might need to add some logging to understand the problem. |
Do you need any help? Let me know if I should take a look at something. |
Thanks. No, just wanted to understand why the container didn't start correctly. But when adding some debug everything ran ok. I want a clean working baseline before I help @Yeseh clean this up. |
@HofmeisterAn Can you please stop the build? my task.delay hack did fail the test but the wait strategy is still running? Can I set a timeout for the tests until this problem is found? |
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
Ok, so I tried setting the ip of the host. Took me a while to figure out that the values wren't actually used(fix this now at least). Still the get accountinfo works but the database operation times out. Any idea @JonasBenz? |
Did some more investigation. The url rewriter is by far the most efficeient way to get the cosmos emulator running in docker. |
So setting the IP of the docker host as environment variable AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE like @HofmeisterAn suggested here did not work?: #549 (comment) If the Or providing both |
…eseh/testcontainers-dotnet into feature/cosmosdb-testcontainer
Done. |
@HofmeisterAn I guess this PR is ready for review. |
👏 I will do it in the next days. I hope it is not urgent. |
src/Testcontainers/Builders/TestcontainersBuilderCosmosDbExtension.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Fixtures/Containers/Unix/Modules/Databases/CosmosDbFixture.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Show resolved
Hide resolved
src/Testcontainers/Builders/TestcontainersBuilderCosmosDbExtension.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have just a few more small suggestions / improvements.
src/Testcontainers/Configurations/Modules/Databases/CosmosDbTestcontainerConfiguration.cs
Show resolved
Hide resolved
src/Testcontainers/Containers/Modules/Databases/CosmosDbTestcontainer.cs
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs
Outdated
Show resolved
Hide resolved
Maybe for fixing the tests when the emulator is stable. |
Then I will create a separate issue. Other than that the Cosmos DB Emulator is done? |
Yes! |
I seem to be on the right track, so I'm opening a PR for some feedback.
General solution direction is to use a custom HttpClientHandler to query the database using the REST API instead of using the CosmosDB client SDK.
Here's my current view of the TODOs: