1- import * as net from "node:net" ;
21import {
32 AbstractStartedContainer ,
43 GenericContainer ,
@@ -23,7 +22,7 @@ export class AzureCosmosDbEmulatorContainer extends GenericContainer {
2322 private explorerEnabled = DEFAULT_EXPLORER_ENABLED ;
2423 private portGenerator : PortGenerator ;
2524
26- constructor ( image = "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview " ) {
25+ constructor ( image = "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-EN20250228 " ) {
2726 super ( image ) ;
2827 this . portGenerator = new RandomUniquePortGenerator ( ) ;
2928 this . withWaitStrategy ( Wait . forLogMessage ( COSMOS_READY_LOG_MESSAGE ) ) ;
@@ -54,27 +53,6 @@ export class AzureCosmosDbEmulatorContainer extends GenericContainer {
5453
5554 return new StartedAzureCosmosDbEmulatorContainer ( await super . start ( ) , this . key , port , this . protocol ) ;
5655 }
57-
58- /**
59- * The mapped port has to be passed to CosmosDB as an environment variable.
60- * Since the mapped port would only be known after container creation, we need to find an available port ourselves
61- * before starting the container.
62- * @private
63- */
64- private async getFreePort ( ) : Promise < number > {
65- return new Promise ( ( resolve , reject ) => {
66- const server = net . createServer ( ) ;
67- server . listen ( 0 , ( ) => {
68- const address = server . address ( ) ;
69- if ( typeof address !== "string" && address ?. port ) {
70- server . close ( ( ) => resolve ( address . port ) ) ;
71- } else {
72- server . close ( ( ) => reject ( new Error ( "Failed to get available port from host" ) ) ) ;
73- }
74- } ) ;
75- server . on ( "error" , reject ) ;
76- } ) ;
77- }
7856}
7957
8058export class StartedAzureCosmosDbEmulatorContainer extends AbstractStartedContainer {
0 commit comments