From d9cdc6505f5faec45c4f968dbb30ccf8812ed6b4 Mon Sep 17 00:00:00 2001 From: Alexander Zarei Date: Wed, 11 Feb 2026 00:34:07 -0800 Subject: [PATCH] fix: Remove obsolete ITextSearch vector store integration tests These tests were part of old MEVD integration tests removed in #13484. The fixtures they depend on were intentionally deleted as part of architectural cleanup. Coverage for vector stores continues via VectorData.ConformanceTests. ITextSearch interface testing continues via web connector tests. Resolves build failures from merge commit 948ffd6. --- .../AzureAISearchTextSearchTests.cs | 149 ------------------ .../InMemoryVectorStoreTextSearchTests.cs | 83 ---------- .../Memory/Qdrant/QdrantTextSearchTests.cs | 96 ----------- 3 files changed, 328 deletions(-) delete mode 100644 dotnet/src/IntegrationTests/Connectors/Memory/AzureAISearch/AzureAISearchTextSearchTests.cs delete mode 100644 dotnet/src/IntegrationTests/Connectors/Memory/InMemory/InMemoryVectorStoreTextSearchTests.cs delete mode 100644 dotnet/src/IntegrationTests/Connectors/Memory/Qdrant/QdrantTextSearchTests.cs diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/AzureAISearch/AzureAISearchTextSearchTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/AzureAISearch/AzureAISearchTextSearchTests.cs deleted file mode 100644 index 9280df1f513c..000000000000 --- a/dotnet/src/IntegrationTests/Connectors/Memory/AzureAISearch/AzureAISearchTextSearchTests.cs +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -#pragma warning disable CS0618 // ITextSearch is obsolete - -using System; -using System.Threading.Tasks; -using Azure.AI.OpenAI; -using Azure.Identity; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.Configuration; -using Microsoft.SemanticKernel.Connectors.AzureAISearch; -using Microsoft.SemanticKernel.Data; -using SemanticKernel.IntegrationTests.Data; -using SemanticKernel.IntegrationTests.TestSettings; -using Xunit; - -namespace SemanticKernel.IntegrationTests.Connectors.Memory.AzureAISearch; - -/// -/// Integration tests for using with . -/// -[Collection("AzureAISearchVectorStoreCollection")] -public class AzureAISearchTextSearchTests(AzureAISearchVectorStoreFixture fixture) : BaseVectorStoreTextSearchTests -{ - // If null, all tests will be enabled - private const string SkipReason = "Requires Azure AI Search Service instance up and running"; - - [Fact(Skip = SkipReason)] - public override async Task CanSearchAsync() - { - await base.CanSearchAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task CanGetTextSearchResultsAsync() - { - await base.CanGetTextSearchResultsAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task CanGetSearchResultsAsync() - { - await base.CanGetSearchResultsAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task UsingTextSearchWithAFilterAsync() - { - await base.UsingTextSearchWithAFilterAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task FunctionCallingUsingCreateWithSearchAsync() - { - await base.FunctionCallingUsingCreateWithSearchAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task FunctionCallingUsingCreateWithGetSearchResultsAsync() - { - await base.FunctionCallingUsingCreateWithGetSearchResultsAsync(); - } - - [Fact(Skip = SkipReason)] - public override async Task FunctionCallingUsingGetTextSearchResultsAsync() - { - await base.FunctionCallingUsingGetTextSearchResultsAsync(); - } - - /// - public override Task CreateTextSearchAsync() - { - if (this.VectorStore is null) - { - AzureOpenAIConfiguration? azureOpenAIConfiguration = this.Configuration.GetSection("AzureOpenAIEmbeddings").Get(); - Assert.NotNull(azureOpenAIConfiguration); - Assert.NotEmpty(azureOpenAIConfiguration.DeploymentName); - Assert.NotEmpty(azureOpenAIConfiguration.Endpoint); - - this.EmbeddingGenerator = new AzureOpenAIClient(new Uri(azureOpenAIConfiguration.Endpoint), new AzureCliCredential()) - .GetEmbeddingClient(azureOpenAIConfiguration.DeploymentName) - .AsIEmbeddingGenerator(); - - this.VectorStore = new AzureAISearchVectorStore(fixture.SearchIndexClient, new() { EmbeddingGenerator = this.EmbeddingGenerator }); - } - - var vectorSearch = this.VectorStore.GetCollection(fixture.TestIndexName); - var stringMapper = new HotelTextSearchStringMapper(); - var resultMapper = new HotelTextSearchResultMapper(); - - // TODO: Once OpenAITextEmbeddingGenerationService implements MEAI's IEmbeddingGenerator (#10811), configure it with the AzureAISearchVectorStore above instead of passing it here. - var result = new VectorStoreTextSearch(vectorSearch, this.EmbeddingGenerator!, stringMapper, resultMapper); - - return Task.FromResult(result); - } - - /// - public override string GetQuery() => "Find a great hotel"; - - /// - public override TextSearchFilter GetTextSearchFilter() => new TextSearchFilter().Equality("Rating", 3.6); - - /// - public override bool VerifySearchResults(object[] results, string query, TextSearchFilter? filter = null) - { - Assert.NotNull(results); - Assert.NotEmpty(results); - Assert.Equal(filter is null ? 4 : 2, results.Length); - foreach (var result in results) - { - Assert.NotNull(result); - Assert.IsType(result); - } - - return true; - } - - /// - /// String mapper which converts a Hotel to a string. - /// - protected sealed class HotelTextSearchStringMapper : ITextSearchStringMapper - { - /// - public string MapFromResultToString(object result) - { - if (result is AzureAISearchHotel hotel) - { - return $"{hotel.HotelName} {hotel.Description}"; - } - throw new ArgumentException("Invalid result type."); - } - } - - /// - /// Result mapper which converts a Hotel to a TextSearchResult. - /// - protected sealed class HotelTextSearchResultMapper : ITextSearchResultMapper - { - /// - public TextSearchResult MapFromResultToTextSearchResult(object result) - { - if (result is AzureAISearchHotel hotel) - { - return new TextSearchResult(value: hotel.Description) { Name = hotel.HotelName, Link = $"id://{hotel.HotelId}" }; - } - throw new ArgumentException("Invalid result type."); - } - } -} diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/InMemory/InMemoryVectorStoreTextSearchTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/InMemory/InMemoryVectorStoreTextSearchTests.cs deleted file mode 100644 index 29ccba90696b..000000000000 --- a/dotnet/src/IntegrationTests/Connectors/Memory/InMemory/InMemoryVectorStoreTextSearchTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -#pragma warning disable CS0618 // ITextSearch is obsolete - -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.Configuration; -using Microsoft.SemanticKernel.Connectors.InMemory; -using Microsoft.SemanticKernel.Data; -using OpenAI; -using SemanticKernel.IntegrationTests.Data; -using SemanticKernel.IntegrationTests.TestSettings; -using Xunit; - -namespace SemanticKernel.IntegrationTests.Connectors.Memory.InMemory; - -/// -/// Integration tests for using with . -/// -public class InMemoryVectorStoreTextSearchTests : BaseVectorStoreTextSearchTests -{ - /// - public override async Task CreateTextSearchAsync() - { - if (this.VectorStore is null) - { - OpenAIConfiguration? openAIConfiguration = this.Configuration.GetSection("OpenAIEmbeddings").Get(); - Assert.NotNull(openAIConfiguration); - Assert.NotNull(openAIConfiguration.ModelId); - Assert.NotNull(openAIConfiguration.ApiKey); - - this.EmbeddingGenerator = new OpenAIClient(openAIConfiguration.ApiKey) - .GetEmbeddingClient(openAIConfiguration.ModelId) - .AsIEmbeddingGenerator(); - - // Delegate which will create a record. - static DataModel CreateRecord(int index, string text, ReadOnlyMemory embedding) - { - var guid = Guid.NewGuid(); - return new() - { - Key = guid, - Text = text, - Link = $"noop://{guid}", - Tag = index % 2 == 0 ? "Even" : "Odd", - Embedding = embedding - }; - } - - this.VectorStore = new InMemoryVectorStore(); - await AddRecordsAsync(this.VectorStore, "records", this.EmbeddingGenerator, CreateRecord); - } - - var vectorSearch = this.VectorStore.GetCollection("records"); - var stringMapper = new DataModelTextSearchStringMapper(); - var resultMapper = new DataModelTextSearchResultMapper(); - - // TODO: Once OpenAITextEmbeddingGenerationService implements MEAI's IEmbeddingGenerator (#10811), configure it with the InMemoryVectorStore above instead of passing it here. - return new VectorStoreTextSearch(vectorSearch, this.EmbeddingGenerator!, stringMapper, resultMapper); - } - - /// - public override string GetQuery() => "What is the Semantic Kernel?"; - - /// - public override TextSearchFilter GetTextSearchFilter() => new TextSearchFilter().Equality("Tag", "Even"); - - /// - public override bool VerifySearchResults(object[] results, string query, TextSearchFilter? filter = null) - { - Assert.NotNull(results); - Assert.NotEmpty(results); - Assert.Equal(4, results.Length); - foreach (var result in results) - { - Assert.NotNull(result); - Assert.IsType(result); - } - - return true; - } -} diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/Qdrant/QdrantTextSearchTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/Qdrant/QdrantTextSearchTests.cs deleted file mode 100644 index 5f02d94c4022..000000000000 --- a/dotnet/src/IntegrationTests/Connectors/Memory/Qdrant/QdrantTextSearchTests.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -#pragma warning disable CS0618 // ITextSearch is obsolete - -using System; -using System.Threading.Tasks; -using Microsoft.SemanticKernel.Connectors.Qdrant; -using Microsoft.SemanticKernel.Data; -using SemanticKernel.IntegrationTests.Data; -using Xunit; -using static SemanticKernel.IntegrationTests.Connectors.Memory.Qdrant.QdrantVectorStoreFixture; - -namespace SemanticKernel.IntegrationTests.Connectors.Memory.Qdrant; - -/// -/// Integration tests for using with . -/// -[Collection("QdrantVectorStoreCollection")] -public class QdrantTextSearchTests(QdrantVectorStoreFixture fixture) : BaseVectorStoreTextSearchTests -{ - /// - public override Task CreateTextSearchAsync() - { - if (this.VectorStore is null) - { - this.EmbeddingGenerator = fixture.EmbeddingGenerator; - this.VectorStore = new QdrantVectorStore(fixture.QdrantClient, ownsClient: false, new QdrantVectorStoreOptions { EmbeddingGenerator = fixture.EmbeddingGenerator }); - } - - var options = new QdrantCollectionOptions - { - HasNamedVectors = true, - Definition = fixture.HotelVectorStoreRecordDefinition, - }; - using var collection = new QdrantCollection(fixture.QdrantClient, "namedVectorsHotels", ownsClient: false, options); - var stringMapper = new HotelInfoTextSearchStringMapper(); - var resultMapper = new HotelInfoTextSearchResultMapper(); - - var result = new VectorStoreTextSearch(collection, this.EmbeddingGenerator!, stringMapper, resultMapper); - - return Task.FromResult(result); - } - - /// - public override string GetQuery() => "Find a great hotel"; - - /// - public override TextSearchFilter GetTextSearchFilter() => new TextSearchFilter().Equality("HotelName", "My Hotel 11"); - - /// - public override bool VerifySearchResults(object[] results, string query, TextSearchFilter? filter = null) - { - Assert.NotNull(results); - Assert.NotEmpty(results); - Assert.Equal(filter is null ? 4 : 1, results.Length); - foreach (var result in results) - { - Assert.NotNull(result); - Assert.IsType(result); - } - - return true; - } - - /// - /// String mapper which converts a Hotel to a string. - /// - protected sealed class HotelInfoTextSearchStringMapper : ITextSearchStringMapper - { - /// - public string MapFromResultToString(object result) - { - if (result is HotelInfo hotel) - { - return $"{hotel.HotelName} {hotel.Description}"; - } - throw new ArgumentException("Invalid result type."); - } - } - - /// - /// Result mapper which converts a Hotel to a TextSearchResult. - /// - protected sealed class HotelInfoTextSearchResultMapper : ITextSearchResultMapper - { - /// - public TextSearchResult MapFromResultToTextSearchResult(object result) - { - if (result is HotelInfo hotel) - { - return new TextSearchResult(value: hotel.Description) { Name = hotel.HotelName, Link = $"id://{hotel.HotelId}" }; - } - throw new ArgumentException("Invalid result type."); - } - } -}