Skip to content

Add cosmos db emulator module#934

Merged
cristianrgreco merged 7 commits intotestcontainers:mainfrom
mrtnsch:add-cosmos-db-emulator-module
Mar 17, 2025
Merged

Add cosmos db emulator module#934
cristianrgreco merged 7 commits intotestcontainers:mainfrom
mrtnsch:add-cosmos-db-emulator-module

Conversation

@mrtnsch
Copy link
Copy Markdown
Contributor

@mrtnsch mrtnsch commented Mar 16, 2025

This adds support for the Azure Cosmos DB emulator. Unlike the existing module for Java, .NET, and Python, this implementation uses the new Linux emulator. The old emulator is very slow and cumbersome to work with, and using the new linux-based one seems like a decent tradeoff to make.

The container requires the mapped port to be passed as an env var. I have found a solution to achieve this, but it seems quite hacky to me. I'm very open to other ideas to solve this problem.

The port has to be passed, because CosmosDB provides redirects to the individual write/read endpoints. Those redirects then target the port passed in the env var, defaulting to 8081. The Azure Cosmos SDK client follows these redirects by default, leading to an ECONREFUSED if the port in the env is different than the mapped port.

This could be avoided by disabling endpoint discovery in the client like this:

const cosmosClient = new CosmosClient({
      endpoint: container.getEndpoint(),
      key: container.getKey(),
      connectionPolicy: {
        enableEndpointDiscovery: false,
      },
    });

However, this would force users of this testcontainer to specify different configurations depending on whether their client is running in prod or dev/test.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 16, 2025

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit ff68ca0
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-node/deploys/67d87c76bbe85a00084d02a9
😎 Deploy Preview https://deploy-preview-934--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Mar 17, 2025
@mrtnsch mrtnsch force-pushed the add-cosmos-db-emulator-module branch from 2a5254b to ff68ca0 Compare March 17, 2025 19:48
@cristianrgreco cristianrgreco merged commit 2af2d69 into testcontainers:main Mar 17, 2025
242 checks passed
vaernion pushed a commit to Arbeidstilsynet/brevgen2 that referenced this pull request Dec 3, 2025
….21.0

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [testcontainers](https://github.com/testcontainers/testcontainers-node) | devDependencies | minor | [`10.20.0` -> `10.21.0`](https://renovatebot.com/diffs/npm/testcontainers/10.20.0/10.21.0) |

---

### Release Notes

<details>
<summary>testcontainers/testcontainers-node (testcontainers)</summary>

### [`v10.21.0`](https://github.com/testcontainers/testcontainers-node/releases/tag/v10.21.0)

[Compare Source](testcontainers/testcontainers-node@v10.20.0...v10.21.0)

#### Changes

#### 🚀 Features

-   Add ability to set command flags to Gcloud emulators [@&#8203;digital88](https://github.com/digital88) ([#&#8203;926](testcontainers/testcontainers-node#926))
-   Update resource reaper version [@&#8203;loikg](https://github.com/loikg) ([#&#8203;933](testcontainers/testcontainers-node#933))
-   Add cosmos db emulator module [@&#8203;mrtnsch](https://github.com/mrtnsch) ([#&#8203;934](testcontainers/testcontainers-node#934))
-   Add ability to copy archives into containers [@&#8203;zacaj](https://github.com/zacaj) ([#&#8203;932](testcontainers/testcontainers-node#932))

#### 🐛 Bug Fixes

-   Do not replace user-provided Localstack `LAMBDA_DOCKER_FLAGS` [@&#8203;florian-nguyen](https://github.com/florian-nguyen) ([#&#8203;935](testcontainers/testcontainers-node#935))

#### 🧹 Maintenance

-   Upgrade linting libraries [@&#8203;prenaissance](https://github.com/prenaissance) ([#&#8203;931](testcontainers/testcontainers-node#931))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!".

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Related work items: #30372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Backward compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants