From e8aa1c9af406d77cc12f10f2e75d34f6d24a4b6d Mon Sep 17 00:00:00 2001 From: Alireza Baloochi Date: Thu, 17 Apr 2025 11:37:32 +0330 Subject: [PATCH 1/4] Add display name for Qdrant's HTTP and GRPC endpoints --- .../QdrantBuilderExtensions.cs | 6 +++-- .../QdrantFunctionalTests.cs | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs index 1441ada4c2a..d7b010de79f 100644 --- a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs +++ b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs @@ -86,7 +86,9 @@ public static IResourceBuilder AddQdrant(this IDistributed context.EnvironmentVariables[EnableStaticContentEnvVarName] = "0"; } }) - .WithHealthCheck(healthCheckKey); + .WithHealthCheck(healthCheckKey) + .WithUrlForEndpoint(QdrantServerResource.PrimaryEndpointName, c => c.DisplayText = "Qdrant (GRPC)") + .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)"); } /// @@ -179,7 +181,7 @@ private static QdrantClient CreateQdrantClient(string? connectionString) { throw new InvalidOperationException("Endpoint is unavailable"); } - + var client = new QdrantClient(endpoint, key); return client; } diff --git a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs index 557fc56f6c8..90976780340 100644 --- a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs +++ b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs @@ -219,6 +219,32 @@ await pipeline.ExecuteAsync(async token => } } + [Fact] + [RequiresDocker] + public async Task AddQudantWithDefaultsAddsUrlAnnotations() + { + using var builder = TestDistributedApplicationBuilder.Create(); + + var qdrant = builder.AddQdrant("qdrant"); + + var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + builder.Eventing.Subscribe((e, ct) => + { + tcs.SetResult(); + return Task.CompletedTask; + }); + + var app = await builder.BuildAsync(); + await app.StartAsync(); + await tcs.Task; + + var urls = qdrant.Resource.Annotations.OfType(); + Assert.Single(urls, u => u.Endpoint!.EndpointName == "grpc" && u.DisplayText == "Qdrant (GRPC)"); + Assert.Single(urls, u => u.Endpoint!.EndpointName == "http" && u.DisplayText == "Qdrant (HTTP)"); + + await app.StopAsync(); + } + [Fact] [RequiresDocker] public async Task VerifyWaitForOnQdrantBlocksDependentResources() From 030fd22acc215e8ddbd15cd5316f6aaba4e35c31 Mon Sep 17 00:00:00 2001 From: Alireza Baloochi Date: Thu, 17 Apr 2025 12:31:26 +0330 Subject: [PATCH 2/4] fix typo --- tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs index 90976780340..b2aaf83de29 100644 --- a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs +++ b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs @@ -221,7 +221,7 @@ await pipeline.ExecuteAsync(async token => [Fact] [RequiresDocker] - public async Task AddQudantWithDefaultsAddsUrlAnnotations() + public async Task AddQdrantWithDefaultsAddsUrlAnnotations() { using var builder = TestDistributedApplicationBuilder.Create(); From f18ad37fe7bdada5e88f4076080ce1b5783cc745 Mon Sep 17 00:00:00 2001 From: Alireza Baloochi Date: Thu, 17 Apr 2025 20:48:33 +0330 Subject: [PATCH 3/4] Display GRPC port only in details and add qdant dashbord url to urls --- src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs | 11 +++++++++-- .../QdrantFunctionalTests.cs | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs index d7b010de79f..92332f59149 100644 --- a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs +++ b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs @@ -87,8 +87,15 @@ public static IResourceBuilder AddQdrant(this IDistributed } }) .WithHealthCheck(healthCheckKey) - .WithUrlForEndpoint(QdrantServerResource.PrimaryEndpointName, c => c.DisplayText = "Qdrant (GRPC)") - .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)"); + .WithUrlForEndpoint(QdrantServerResource.PrimaryEndpointName, c => + { + c.DisplayText = "Qdrant (GRPC)"; + // https://github.com/dotnet/aspire/issues/8809 + c.DisplayLocation = UrlDisplayLocation.DetailsOnly; + }) + .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)") + .WithUrl(ReferenceExpression.Create($"{qdrant.HttpEndpoint.Property(EndpointProperty.Url)}/dashboard"), "Qdrant Dashboard"); + } /// diff --git a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs index b2aaf83de29..afc88984056 100644 --- a/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs +++ b/tests/Aspire.Hosting.Qdrant.Tests/QdrantFunctionalTests.cs @@ -239,8 +239,9 @@ public async Task AddQdrantWithDefaultsAddsUrlAnnotations() await tcs.Task; var urls = qdrant.Resource.Annotations.OfType(); - Assert.Single(urls, u => u.Endpoint!.EndpointName == "grpc" && u.DisplayText == "Qdrant (GRPC)"); - Assert.Single(urls, u => u.Endpoint!.EndpointName == "http" && u.DisplayText == "Qdrant (HTTP)"); + Assert.Single(urls, u => u.Endpoint?.EndpointName == "grpc" && u.DisplayText == "Qdrant (GRPC)" && u.DisplayLocation == UrlDisplayLocation.DetailsOnly); + Assert.Single(urls, u => u.Endpoint?.EndpointName == "http" && u.DisplayText == "Qdrant (HTTP)"); + Assert.Single(urls, u => u.DisplayText == "Qdrant Dashboard" && u.Url.EndsWith("/dashboard")); await app.StopAsync(); } From 9c12468cf1469812a48037119a07f2ee47584f9c Mon Sep 17 00:00:00 2001 From: Alireza Baloochi Date: Fri, 18 Apr 2025 10:34:36 +0330 Subject: [PATCH 4/4] Address PR feedback --- src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs index 92332f59149..6490136c23e 100644 --- a/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs +++ b/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs @@ -94,8 +94,7 @@ public static IResourceBuilder AddQdrant(this IDistributed c.DisplayLocation = UrlDisplayLocation.DetailsOnly; }) .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)") - .WithUrl(ReferenceExpression.Create($"{qdrant.HttpEndpoint.Property(EndpointProperty.Url)}/dashboard"), "Qdrant Dashboard"); - + .WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, e => new ResourceUrlAnnotation() { Url = "/dashboard", DisplayText = "Qdrant Dashboard" }); } ///