Skip to content

Commit 6be38ef

Browse files
author
Oleksii Sokol
committed
test
1 parent f031e9b commit 6be38ef

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ManagedCode.Database.Tests/TestContainers/CosmosTestContainer.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,25 @@ public CosmosTestContainer()
3232
.WithImage("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator")
3333
.WithName(containerName)
3434
.WithExposedPort(8081)
35+
.WithExposedPort(10250)
36+
.WithExposedPort(10251)
37+
.WithExposedPort(10252)
38+
.WithExposedPort(10253)
39+
.WithExposedPort(10254)
40+
.WithExposedPort(10255)
3541
.WithPortBinding(8081, 8081)
3642
.WithPortBinding(10250, 10250)
3743
.WithPortBinding(10251, 10251)
3844
.WithPortBinding(10252, 10252)
3945
.WithPortBinding(10253, 10253)
4046
.WithPortBinding(10254, 10254)
4147
.WithPortBinding(10255, 10255)
42-
.WithEnvironment("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", "2")
48+
.WithEnvironment("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", "1")
4349
.WithEnvironment("AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE", "127.0.0.1")
44-
.WithEnvironment("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "true")
50+
.WithEnvironment("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "false")
4551
.WithCleanUp(false)
4652
.WithWaitStrategy(Wait.ForUnixContainer()
47-
.UntilPortIsAvailable(8081))
53+
.UntilPortIsAvailable(privatePort))
4854
.Build();
4955

5056
_dockerClient = new DockerClientConfiguration().CreateClient();
@@ -60,7 +66,7 @@ public string GenerateId()
6066

6167
public async Task InitializeAsync()
6268
{
63-
ushort publicPort = 0;
69+
ushort publicPort = privatePort;
6470

6571
try
6672
{
@@ -92,12 +98,13 @@ public async Task InitializeAsync()
9298
}
9399
}
94100

101+
var database = $"db{Guid.NewGuid().ToString("N")}";
95102

96103
_database = new CosmosDatabase(new CosmosOptions
97104
{
98105
ConnectionString =
99106
$"AccountEndpoint=https://localhost:{publicPort}/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
100-
DatabaseName = "database",
107+
DatabaseName = database,
101108
CollectionName = $"testContainer",
102109
AllowTableCreation = true,
103110
CosmosClientOptions = new CosmosClientOptions()

0 commit comments

Comments
 (0)