From c2a3717561b473e316a4a65e73730423bccf96f3 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 16:10:15 +0000
Subject: [PATCH 1/8] Use DocumentDB Local for conformance tests
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.github/workflows/mevd.yml | 3 +-
.../AzureDocumentDB.ConformanceTests.csproj | 1 +
.../Support/DocumentDBTestStore.cs | 39 ++++++++++++++++---
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/mevd.yml b/.github/workflows/mevd.yml
index 5fb7471..392e301 100644
--- a/.github/workflows/mevd.yml
+++ b/.github/workflows/mevd.yml
@@ -155,10 +155,9 @@ jobs:
fail-fast: false
matrix:
provider: ${{ fromJson(needs.discover.outputs.all_providers) }}
- # AzureAISearch and AzureDocumentDB require cloud instances and can't run in CI.
+ # AzureAISearch requires a cloud instance and can't run in CI.
exclude:
- provider: AzureAISearch
- - provider: AzureDocumentDB
steps:
- uses: actions/checkout@v6
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj b/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj
index 03ee156..2e5e008 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj
@@ -15,6 +15,7 @@
+
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 8983043..e89895c 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
using CommunityToolkit.VectorData.AzureDocumentDB;
+using DotNet.Testcontainers.Builders;
+using DotNet.Testcontainers.Containers;
using MongoDB.Driver;
using VectorData.ConformanceTests.Support;
@@ -11,10 +13,24 @@ namespace AzureDocumentDB.ConformanceTests.Support;
public sealed class DocumentDBTestStore : TestStore
#pragma warning restore CA1001
{
+ private const string Username = "testuser";
+ private const string Password = "TestPassword123!";
+ private const ushort DocumentDBPort = 10260;
+
public static DocumentDBTestStore Instance { get; } = new();
+ private readonly IContainer _container = new ContainerBuilder()
+ .WithImage("ghcr.io/microsoft/documentdb/documentdb-local:latest")
+ .WithPortBinding(DocumentDBPort, assignRandomHostPort: true)
+ .WithEnvironment("USERNAME", Username)
+ .WithEnvironment("PASSWORD", Password)
+ .WithWaitStrategy(Wait.ForUnixContainer()
+ .UntilMessageIsLogged("=== DocumentDB is ready ==="))
+ .Build();
+
private MongoClient? _client;
private IMongoDatabase? _database;
+ private bool _useExternalInstance;
public MongoClient Client => this._client ?? throw new InvalidOperationException("Not initialized");
public IMongoDatabase Database => this._database ?? throw new InvalidOperationException("Not initialized");
@@ -30,17 +46,30 @@ private DocumentDBTestStore()
{
}
- protected override Task StartAsync()
+ protected override async Task StartAsync()
{
- if (string.IsNullOrWhiteSpace(DocumentDBTestEnvironment.ConnectionString))
+ string connectionString;
+ if (DocumentDBTestEnvironment.IsConnectionStringDefined)
+ {
+ connectionString = DocumentDBTestEnvironment.ConnectionString!;
+ this._useExternalInstance = true;
+ }
+ else
{
- throw new InvalidOperationException("Connection string is not configured, set the AzureDocumentDB:ConnectionString environment variable");
+ await this._container.StartAsync();
+ connectionString = $"mongodb://{Username}:{Password}@{this._container.Hostname}:{this._container.GetMappedPublicPort(DocumentDBPort)}/?tls=true&tlsAllowInvalidCertificates=true";
+ this._useExternalInstance = false;
}
- this._client = new MongoClient(DocumentDBTestEnvironment.ConnectionString);
+ this._client = new MongoClient(connectionString);
this._database = this._client.GetDatabase("VectorSearchTests");
this.DefaultVectorStore = new DocumentDBVectorStore(this._database);
+ }
- return Task.CompletedTask;
+ protected override Task StopAsync()
+ {
+ return this._useExternalInstance
+ ? Task.CompletedTask
+ : this._container.StopAsync();
}
}
From 6eddaaafeb347e403266512dbca8d6a6ff9b6159 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 16:13:06 +0000
Subject: [PATCH 2/8] Use supported Testcontainers builder constructor
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index e89895c..cc98965 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -19,8 +19,7 @@ public sealed class DocumentDBTestStore : TestStore
public static DocumentDBTestStore Instance { get; } = new();
- private readonly IContainer _container = new ContainerBuilder()
- .WithImage("ghcr.io/microsoft/documentdb/documentdb-local:latest")
+ private readonly IContainer _container = new ContainerBuilder("ghcr.io/microsoft/documentdb/documentdb-local:latest")
.WithPortBinding(DocumentDBPort, assignRandomHostPort: true)
.WithEnvironment("USERNAME", Username)
.WithEnvironment("PASSWORD", Password)
From 1f539038fbf710ff34529623545d0e4af128c48c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 17:29:09 +0000
Subject: [PATCH 3/8] Increase Azure DocumentDB container startup timeout
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index cc98965..9edba73 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -24,7 +24,7 @@ public sealed class DocumentDBTestStore : TestStore
.WithEnvironment("USERNAME", Username)
.WithEnvironment("PASSWORD", Password)
.WithWaitStrategy(Wait.ForUnixContainer()
- .UntilMessageIsLogged("=== DocumentDB is ready ==="))
+ .UntilMessageIsLogged("=== DocumentDB is ready ===", strategy => strategy.WithTimeout(TimeSpan.FromMinutes(5))))
.Build();
private MongoClient? _client;
From c900de38108d676a95b26b575c68bdd166ca0b8f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 18:00:03 +0000
Subject: [PATCH 4/8] Wait for MongoDB availability before using DocumentDB
tests
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 9edba73..4d63350 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -24,7 +24,7 @@ public sealed class DocumentDBTestStore : TestStore
.WithEnvironment("USERNAME", Username)
.WithEnvironment("PASSWORD", Password)
.WithWaitStrategy(Wait.ForUnixContainer()
- .UntilMessageIsLogged("=== DocumentDB is ready ===", strategy => strategy.WithTimeout(TimeSpan.FromMinutes(5))))
+ .UntilInternalTcpPortIsAvailable(DocumentDBPort, strategy => strategy.WithTimeout(TimeSpan.FromMinutes(5))))
.Build();
private MongoClient? _client;
From 2a921bf17c5a0c7ad24bd3fff2d5e0eeafd0b7b0 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 18:17:01 +0000
Subject: [PATCH 5/8] Restrict TLS bypass to local DocumentDB test container
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 35 ++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 4d63350..72b9e0d 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -1,9 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Net.Security;
+using System.Security.Authentication;
using CommunityToolkit.VectorData.AzureDocumentDB;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
+using MongoDB.Bson;
using MongoDB.Driver;
using VectorData.ConformanceTests.Support;
@@ -60,7 +63,15 @@ protected override async Task StartAsync()
this._useExternalInstance = false;
}
- this._client = new MongoClient(connectionString);
+ MongoClientSettings settings = MongoClientSettings.FromConnectionString(connectionString);
+ settings.SslSettings = new SslSettings
+ {
+ EnabledSslProtocols = SslProtocols.Tls12,
+ ServerCertificateValidationCallback = static (_, _, _, _) => true,
+ };
+
+ this._client = new MongoClient(settings);
+ await this.WaitForMongoServiceAsync(this._client, TimeSpan.FromMinutes(5));
this._database = this._client.GetDatabase("VectorSearchTests");
this.DefaultVectorStore = new DocumentDBVectorStore(this._database);
}
@@ -71,4 +82,26 @@ protected override Task StopAsync()
? Task.CompletedTask
: this._container.StopAsync();
}
+
+ private async Task WaitForMongoServiceAsync(MongoClient client, TimeSpan timeout)
+ {
+ DateTimeOffset deadline = DateTimeOffset.UtcNow.Add(timeout);
+ Exception? lastException = null;
+
+ while (DateTimeOffset.UtcNow < deadline)
+ {
+ try
+ {
+ await client.GetDatabase("admin").RunCommandAsync(new BsonDocument("ping", 1));
+ return;
+ }
+ catch (Exception ex)
+ {
+ lastException = ex;
+ await Task.Delay(TimeSpan.FromSeconds(2));
+ }
+ }
+
+ throw new TimeoutException($"Timed out waiting for the DocumentDB container to accept MongoDB connections. Last error: {lastException?.Message}", lastException);
+ }
}
From 80ee2173174616c6e066531c390fcb0fa498979b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 18 Aug 2026 18:27:19 +0000
Subject: [PATCH 6/8] Finalize DocumentDB readiness fix
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 72b9e0d..5010265 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -59,16 +59,19 @@ protected override async Task StartAsync()
else
{
await this._container.StartAsync();
- connectionString = $"mongodb://{Username}:{Password}@{this._container.Hostname}:{this._container.GetMappedPublicPort(DocumentDBPort)}/?tls=true&tlsAllowInvalidCertificates=true";
+ connectionString = $"mongodb://{Username}:{Password}@{this._container.Hostname}:{this._container.GetMappedPublicPort(DocumentDBPort)}/?tls=true";
this._useExternalInstance = false;
}
MongoClientSettings settings = MongoClientSettings.FromConnectionString(connectionString);
- settings.SslSettings = new SslSettings
+ if (!this._useExternalInstance)
{
- EnabledSslProtocols = SslProtocols.Tls12,
- ServerCertificateValidationCallback = static (_, _, _, _) => true,
- };
+ settings.SslSettings = new SslSettings
+ {
+ EnabledSslProtocols = SslProtocols.Tls12,
+ ServerCertificateValidationCallback = static (_, _, _, _) => true,
+ };
+ }
this._client = new MongoClient(settings);
await this.WaitForMongoServiceAsync(this._client, TimeSpan.FromMinutes(5));
From cc567df01b30bdaa6bd69255d552a6c9f3eff6a5 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 19 Aug 2026 08:53:02 +0000
Subject: [PATCH 7/8] Address review feedback: simplify DocumentDBTestStore
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestEnvironment.cs | 27 ----------
.../Support/DocumentDBTestStore.cs | 51 ++++++-------------
2 files changed, 16 insertions(+), 62 deletions(-)
delete mode 100644 MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs
deleted file mode 100644
index 404c7d1..0000000
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using Microsoft.Extensions.Configuration;
-
-namespace AzureDocumentDB.ConformanceTests.Support;
-
-#pragma warning disable CA1810 // Initialize all static fields when those fields are declared
-
-public static class DocumentDBTestEnvironment
-{
- public static readonly string? ConnectionString;
-
- public static bool IsConnectionStringDefined => ConnectionString is not null;
-
- static DocumentDBTestEnvironment()
- {
- var configuration = new ConfigurationBuilder()
- .AddJsonFile(path: "testsettings.json", optional: true)
- .AddJsonFile(path: "testsettings.development.json", optional: true)
- .AddEnvironmentVariables()
- .AddUserSecrets()
- .Build();
-
- ConnectionString = configuration["AzureDocumentDB:ConnectionString"];
- }
-}
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 5010265..306399e 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -32,17 +32,16 @@ public sealed class DocumentDBTestStore : TestStore
private MongoClient? _client;
private IMongoDatabase? _database;
- private bool _useExternalInstance;
- public MongoClient Client => this._client ?? throw new InvalidOperationException("Not initialized");
- public IMongoDatabase Database => this._database ?? throw new InvalidOperationException("Not initialized");
+ public MongoClient Client => _client ?? throw new InvalidOperationException("Not initialized");
+ public IMongoDatabase Database => _database ?? throw new InvalidOperationException("Not initialized");
public override string DefaultIndexKind => Microsoft.Extensions.VectorData.IndexKind.IvfFlat;
public override string DefaultDistanceFunction => Microsoft.Extensions.VectorData.DistanceFunction.CosineDistance;
public DocumentDBVectorStore GetVectorStore(DocumentDBVectorStoreOptions options)
- => new(this.Database, options);
+ => new(Database, options);
private DocumentDBTestStore()
{
@@ -50,41 +49,23 @@ private DocumentDBTestStore()
protected override async Task StartAsync()
{
- string connectionString;
- if (DocumentDBTestEnvironment.IsConnectionStringDefined)
- {
- connectionString = DocumentDBTestEnvironment.ConnectionString!;
- this._useExternalInstance = true;
- }
- else
- {
- await this._container.StartAsync();
- connectionString = $"mongodb://{Username}:{Password}@{this._container.Hostname}:{this._container.GetMappedPublicPort(DocumentDBPort)}/?tls=true";
- this._useExternalInstance = false;
- }
+ await _container.StartAsync();
+ string connectionString = $"mongodb://{Username}:{Password}@{_container.Hostname}:{_container.GetMappedPublicPort(DocumentDBPort)}/?tls=true";
MongoClientSettings settings = MongoClientSettings.FromConnectionString(connectionString);
- if (!this._useExternalInstance)
+ settings.SslSettings = new SslSettings
{
- settings.SslSettings = new SslSettings
- {
- EnabledSslProtocols = SslProtocols.Tls12,
- ServerCertificateValidationCallback = static (_, _, _, _) => true,
- };
- }
-
- this._client = new MongoClient(settings);
- await this.WaitForMongoServiceAsync(this._client, TimeSpan.FromMinutes(5));
- this._database = this._client.GetDatabase("VectorSearchTests");
- this.DefaultVectorStore = new DocumentDBVectorStore(this._database);
+ EnabledSslProtocols = SslProtocols.Tls12,
+ ServerCertificateValidationCallback = static (_, _, _, _) => true,
+ };
+
+ _client = new MongoClient(settings);
+ await WaitForMongoServiceAsync(_client, TimeSpan.FromMinutes(5));
+ _database = _client.GetDatabase("VectorSearchTests");
+ DefaultVectorStore = new DocumentDBVectorStore(_database);
}
- protected override Task StopAsync()
- {
- return this._useExternalInstance
- ? Task.CompletedTask
- : this._container.StopAsync();
- }
+ protected override Task StopAsync() => _container.StopAsync();
private async Task WaitForMongoServiceAsync(MongoClient client, TimeSpan timeout)
{
@@ -101,7 +82,7 @@ private async Task WaitForMongoServiceAsync(MongoClient client, TimeSpan timeout
catch (Exception ex)
{
lastException = ex;
- await Task.Delay(TimeSpan.FromSeconds(2));
+ await Task.Delay(TimeSpan.FromMilliseconds(200));
}
}
From 8733aa8bc57e92c7ab5c062350e623b24950c8e1 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 19 Aug 2026 09:26:12 +0000
Subject: [PATCH 8/8] Dispose MongoClient in StopAsync
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
---
.../Support/DocumentDBTestStore.cs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
index 306399e..5c91a77 100644
--- a/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
+++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs
@@ -65,7 +65,11 @@ protected override async Task StartAsync()
DefaultVectorStore = new DocumentDBVectorStore(_database);
}
- protected override Task StopAsync() => _container.StopAsync();
+ protected override Task StopAsync()
+ {
+ _client?.Dispose();
+ return _container.StopAsync();
+ }
private async Task WaitForMongoServiceAsync(MongoClient client, TimeSpan timeout)
{