testcontainers / testcontainers/testcontainers-python
cosmosdb: CosmosDBNoSQLEndpointContainer doesn't work with vnext-preview emulator image
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 2.3k
- Forks
- 386
- Merge moyen
- 4 h 40 min
- PR mergées (30 j)
- 1
Description
The CosmosDBNoSQLEndpointContainer was built for the standard Cosmos DB emulator image (latest tag). It does not work with the vnext-preview image (mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview), which is the newer Linux-native emulator
Both images serve the same NoSQL API, but vnext has different runtime behavior that breaks assumptions in the current module.
What breaks
-
vnext defaults to HTTP — the standard image defaults to HTTPS, which is what
urland_wait_until_readyhardcode. vnext needs--protocol httpspassed as a command to opt into HTTPS. There is no way to configure this through the module. -
No Data Explorer on vnext —
_wait_until_ready()pollshttps://localhost:8081/_explorer/index.htmlas a readiness signal. vnext returns 400 on that path, so the check loops for 120s and times out. -
No PEM certificate on vnext —
start()calls_download_cert()looking for a file at the legacy Windows-style path inside the container. vnext does not write a cert there, so this raisesdocker.errors.NotFound. -
503s during startup are not retried — After the container is up, vnext returns
CosmosHttpResponseError(503, "pgcosmos extension is still starting") for a few seconds before it can serve queries._wait_for_query_successonly catchesServiceRequestError(connection-level errors), so it does not retry on 503. -
Endpoint discovery returns internal port — The emulator advertises
https://127.0.0.1:8081in its discovery response regardless of how ports are mapped. Usingbind_ports=Falsecauses the SDK to connect to the wrong port after discovery. Related: https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/160
Current workaround
I wrote a subclass that overrides start(), _wait_until_ready(), and _wait_for_query_success() — it passes --protocol https as a command, skips the cert download and explorer check, and catches 503s during readiness polling. It works but depends on the internal class hierarchy, which makes it fragile.
Suggestion
Some ideas:
- Add a
protocolparameter (http/https) to control the URL scheme and pass the right startup command for vnext. - Make
_wait_until_ready()skip the explorer URL check when it returns 400 or is not available. Relying on_wait_for_query_successalone is sufficient. - Make
_download_cert()optional or catchNotFoundgracefully — for vnext there is no cert to download. - Add
CosmosHttpResponseErrorto the retry decorator in_wait_for_query_success.
Alternatively, a dedicated vnext-aware container class would keep things clean.
Versions
- testcontainers 4.14.2
- Python 3.13
- Image:
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par CosmosDBNoSQLEndpointContainer.start(), _wait_until_ready(), _download_cert() et _wait_for_query_success(), puis reproduisez les échecs indiqués avec l’image vnext-preview. Comparez son comportement en matière de protocole, de disponibilité, de certificats, de nouvelles tentatives et de découverte des endpoints avec celui de l’image standard. Le travail est terminé lorsque le conteneur prend en charge l’image vnext-preview sans la sous-classe de contournement, tout en conservant le comportement de l’image standard.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- azure, docker, python
- Domaine
- backend, databases
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 52/100