-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Azure Cosmos DB: Introduce CosmosDBEmulatorContainer #4303
Conversation
Fixes #4283 |
d5fb4d8
to
2c5d092
Compare
237ed74
to
03c8825
Compare
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.
Hi @okohub,
thanks a lot for this module, this will be a great addition and it is very much appreciated!
I have some general remarks, afterwards, it would be good, if someone with more CosmosDB background looks at it as well.
modules/azure/src/main/java/org/testcontainers/containers/Base64Helper.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/Base64Helper.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/Constants.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/KeyStoreUtils.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
Thanks for the quick turnover @okohub, this looks much better, great work! |
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
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.
LGTM now, thanks a lot.
Maybe @bsideup can have a final look as well.
modules/azure/src/main/java/org/testcontainers/containers/CosmosDBEmulatorContainer.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
ok so, why not have both :) I added a KeyStoreUtils as before I did, with ssl disabled okhttp. Now we can also build key store from downloaded pem file. I kept both buildKeyStore methods to give flexibility to developer. We can also describe both methods in documentations by the way. |
modules/azure/src/test/java/org/testcontainers/containers/CosmosDBEmulatorContainerTest.java
Outdated
Show resolved
Hide resolved
I was going to suggest adding a quick bit of code to make sure we cleanup our system properties within our tests, as I have the fear that one day some tests within our wider test suite could break after the trust store modifications. When trying out a quick patch locally, I encountered something very surprising: the tests now fail.
This obviously worked previously, and doesn't happen when using the For the first time it seems that we can't pin an image to a specific version, which is quite alarming from a reproduceability perspective. Clearly the real CosmosDB service is itself evolving, but not being able to pin the version used in testing will be a headache. Is there any possibility that I'm wrong? Can we somehow pin the image and not have it expire? |
5787c9b
to
ad523d9
Compare
@bsideup I added Junit TemporaryFolder rule, I didn't know that thank you. @rnorth I checked latest tags here: https://mcr.microsoft.com/v2/cosmosdb/linux/azure-cosmos-emulator/tags/list and re-read documents here https://docs.microsoft.com/en-us/azure/cosmos-db/linux-emulator but I didn't see a way to workaround expire problem. Looks like all emulators have 164 days to expire after they built. May be we should ask it to @JonathanGiles
|
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.
It's a shame that we have to use a :latest
image for our tests, but I don't think this should be a blocker. LGTM, thanks for your hard work!
Ohoh, this is unfortunate:
We need to work out a way to prevent the |
@rnorth on a second thought (after the review)... Does it mean our users will have to use :latest as well? 🥲 |
We can see that the I was going to say: with this in mind I'm inclined to merge and then revisit japicmp's resolution of new modules if/when necessary. However, I realise that this will also break |
@bsideup yes it does indeed 😬 The slight silver lining compared to modules for 'self hosted' services is that the real prod cloud service is ever-evolving. However, being unable to pin versions and have repeatable tests does add quite a bit of displeasure. |
Hey @JonathanGiles! Is there absolutely nothing that can be done to stop CosmosDB Docker images from "expiring"? |
@rnorth after reading again your review, this sentence drew my attention
May be we can cover test method with try/finally and set parameters to default state. Something like that: String defaultTrustStore = null;
String defaultTrustStorePassword = null;
String defaultTrustStoreType = null;
try {
defaultTrustStore = getprop
defaultTrustStorePassword = getprop
defaultTrustStoreType = getprop
//do some serious thing
} finally {
if (defaultTrustStore != null) {
setprop defaultTrustStore
}
//and others
} |
@okohub thanks for remembering! I'll add a suggested change, which I think reduces the amount of noise inside the test method. |
Actually please could you have a look at this commit and use that? |
@rnorth Of course! I will give it a try, btw I want to squash these commit flood to single one. Is it ok? |
@okohub Sure, if you want! We will squash before merging anyway, so you only need to squash commits if it helps you. |
08a40b1
to
ed45e7a
Compare
@rnorth thanks! Also I added your prop suggestion and rebased into one commit. |
Merged, thanks a lot @okohub for your patience and your commitment to getting this PR merged, much appreciated 🙇 |
hi @okohub do you have an example of a working project using this container with the latest version of the image? |
Check the code example in our docs, which are executed as part of our CI: |
Azure Cosmos DB is a fully managed NoSQL database service for modern app development. I want to introduce it as a test container. Azure Cosmos DB has its own emulator and docker image provided by Microsoft.
The critical point in implementing this container is mandatory SSL connection. Azure Java SDK (https://github.com/Azure/azure-sdk-for-java) has no option to override SSL check, so I added some configurable KeyStore codes to prepare SSL context properly instead of overriding it via reflection or something else.
Please feel free to guide me about contributing this emulator at its best.
Default docker image - Checked
Module dependencies - Checked
API - Checked
Documentation (don't know what can I do extra?)