what is the compatible in memory db for azure cosmos db
Asked Answered
U

2

15

I am integrated my spring boot application with azure CosmosDB-SQL API and for integration test cases i want to use in memory database but trying with H2 in memory it's not working

Urita answered 19/3, 2019 at 13:19 Comment(0)
O
2

In my previous project I used CosmosDB and MongoDriver. In the integration test I had to use in-memory DB so I used Mongo2Go. It has worked really good.

Ocampo answered 8/10, 2020 at 12:43 Comment(8)
Do you know if this has a java equivalent?Kizzie
@Kizzie I am not sure but what a bout this : learn.microsoft.com/en-us/azure/cosmos-db/… The downside of this approach is you have to install something on the local machine.Ocampo
Thanks! I've started using test containers. Works for my needs. testcontainers.org/modules/databases/mongodbKizzie
@peymangilmour how did you use CosmosClient with Mogo2Go? i am facing error "only https schemes are allowed"Crawley
@Crawley I use currently MongoDB.Driver version 2.13.0 and Mongo2Go version 2.2.16 in our integration test project. When you start Mongo2Go, Does the URL have Https?Ocampo
@peymangilmour no it starts with mongodb://localhostCrawley
@Crawley Probably using MongoClient is the key point. If you use Azure DevOps, please look at this link: learn.microsoft.com/en-us/azure/cosmos-db/tutorial-setup-ci-cdOcampo
@Crawley The other approach would be creating docker compose for both your application and container based-CosmosDB. Run it in your pipeline first and then run the integration test.Ocampo
E
1

Extended answer : For a NoSQL cosmosDb, there is none. , i.e. there is no class library letting you instantiate a noSQL CosmosDb in memory for tests purposes, like you would instantiate, let's say, a SQL server db entirely in-memory.

Howerver, like the comments say, you can run a "CosmosDb emulator" on a machine of your choice, and make your code use it as a fake CosmosDb.

That implies:

  • that you can install that emulator on your own machine if you run your test code locally,

OR

  • that you can devise a deployment strategy to a container running that emulator (Docker or similar) so that this emulator can be used, for example, in your CD/CI pipeline in case it has a testing step before deployment.
Elea answered 1/6, 2023 at 12:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.