From e672c01eb4c283af0b56ad8721a69df03d55f086 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 19:40:05 -0400 Subject: [PATCH 1/6] Move FileUtil.cs to src/Shared --- .../Aspire.Hosting.Azure.csproj | 1 + .../Provisioners/BicepProvisioner.cs | 26 +------------------ .../Aspire.Hosting.Dapr.csproj | 1 + .../Shared}/FileUtil.cs | 2 +- .../Aspire.Components.Common.Tests.csproj | 2 ++ 5 files changed, 6 insertions(+), 26 deletions(-) rename {tests/Aspire.Components.Common.Tests => src/Shared}/FileUtil.cs (97%) diff --git a/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj b/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj index e9c3d39719d..8fff8882667 100644 --- a/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj +++ b/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs b/src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs index 30bf2cfc608..436564b3ba7 100644 --- a/src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs +++ b/src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs @@ -123,7 +123,7 @@ await notificationService.PublishUpdateAsync(resource, state => state with PopulateWellKnownParameters(resource, context); - if (FindFullPathFromPath("az") is not { } azPath) + if (FileUtil.FindFullPathFromPath("az") is not { } azPath) { throw new AzureCliNotOnPathException(); } @@ -395,30 +395,6 @@ private static async Task ExecuteCommand(ProcessSpec processSpec) } } - private static string? FindFullPathFromPath(string command) => FindFullPathFromPath(command, Environment.GetEnvironmentVariable("PATH"), Path.PathSeparator, File.Exists); - - private static string? FindFullPathFromPath(string command, string? pathVariable, char pathSeparator, Func fileExists) - { - Debug.Assert(!string.IsNullOrWhiteSpace(command)); - - if (OperatingSystem.IsWindows()) - { - command += ".cmd"; - } - - foreach (var directory in (pathVariable ?? string.Empty).Split(pathSeparator)) - { - var fullPath = Path.Combine(directory, command); - - if (fileExists(fullPath)) - { - return fullPath; - } - } - - return null; - } - internal static string GetChecksum(AzureBicepResource resource, JsonObject parameters) { // TODO: PERF Inefficient diff --git a/src/Aspire.Hosting.Dapr/Aspire.Hosting.Dapr.csproj b/src/Aspire.Hosting.Dapr/Aspire.Hosting.Dapr.csproj index b406de77120..1214100b794 100644 --- a/src/Aspire.Hosting.Dapr/Aspire.Hosting.Dapr.csproj +++ b/src/Aspire.Hosting.Dapr/Aspire.Hosting.Dapr.csproj @@ -12,6 +12,7 @@ + diff --git a/tests/Aspire.Components.Common.Tests/FileUtil.cs b/src/Shared/FileUtil.cs similarity index 97% rename from tests/Aspire.Components.Common.Tests/FileUtil.cs rename to src/Shared/FileUtil.cs index de2052565ff..25dc92b1041 100644 --- a/tests/Aspire.Components.Common.Tests/FileUtil.cs +++ b/src/Shared/FileUtil.cs @@ -3,7 +3,7 @@ using System.Diagnostics; -namespace Aspire.Components.Common.Tests; +namespace Aspire; internal static class FileUtil { diff --git a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj index 3302f811074..cdc62af78b7 100644 --- a/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj +++ b/tests/Aspire.Components.Common.Tests/Aspire.Components.Common.Tests.csproj @@ -6,6 +6,8 @@ + + From dfa0a7f146c12981b9be31842ac092a5d0d7ad57 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 20:34:49 -0400 Subject: [PATCH 2/6] trying dapr cli on helix --- ...DaprDistributedApplicationLifecycleHook.cs | 45 +------------------ tests/helix/send-to-helix-inner.proj | 10 +++++ 2 files changed, 11 insertions(+), 44 deletions(-) diff --git a/src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs b/src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs index 9e7c7ef4d05..2ff021867df 100644 --- a/src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs +++ b/src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs @@ -41,7 +41,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell var sideCars = new List(); var fileName = this._options.DaprPath - ?? GetDefaultDaprPath() + ?? FileUtil.FindFullPathFromPath("dapr") ?? throw new DistributedApplicationException("Unable to locate the Dapr CLI."); foreach (var resource in appModel.Resources) @@ -282,49 +282,6 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell return null; } - /// - /// Return the first verified dapr path - /// - static string? GetDefaultDaprPath() - { - foreach (var path in GetAvailablePaths()) - { - if (File.Exists(path)) - { - return path; - } - } - - return default; - - // Return all the possible paths for dapr - static IEnumerable GetAvailablePaths() - { - if (OperatingSystem.IsWindows()) - { - var pathRoot = Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.Windows)) ?? "C:"; - - // Installed windows paths: - yield return Path.Combine(pathRoot, "dapr", "dapr.exe"); - - yield break; - } - - // Add $HOME/dapr path: - var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - yield return Path.Combine(homePath, "dapr", "dapr"); - - // Linux & MacOS path: - yield return Path.Combine("/usr", "local", "bin", "dapr"); - - // MacOS Homebrew path: - if (OperatingSystem.IsMacOS() && Environment.GetEnvironmentVariable("HOMEBREW_PREFIX") is string homebrewPrefix) - { - yield return Path.Combine(homebrewPrefix, "bin", "dapr"); - } - } - } - public void Dispose() { if (_onDemandResourcesRootPath is not null) diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index ebcc638a185..6700a59bcb1 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -89,6 +89,16 @@ + + + + + + + + + + From 0b1191e3a0efd397518f967e3f71c5bcdfe6fbfe Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 20:39:59 -0400 Subject: [PATCH 3/6] use dapr --- tests/helix/send-to-helix-basictests.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/helix/send-to-helix-basictests.targets b/tests/helix/send-to-helix-basictests.targets index 1d060ef1265..d6baf07e8fc 100644 --- a/tests/helix/send-to-helix-basictests.targets +++ b/tests/helix/send-to-helix-basictests.targets @@ -4,6 +4,7 @@ $(TestArchiveTestsDir)**/*.zip $(BuildHelixWorkItemsDependsOn);BuildHelixWorkItemsForDefaultTests true + true From 103efa84634c99463332603d16d0fff17e4efe9d Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 21:38:29 -0400 Subject: [PATCH 4/6] fixy --- tests/Aspire.Playground.Tests/AppHostTests.cs | 5 +++++ tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj | 1 + tests/helix/send-to-helix-buildonhelixtests.targets | 1 + tests/helix/send-to-helix-inner.proj | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/Aspire.Playground.Tests/AppHostTests.cs b/tests/Aspire.Playground.Tests/AppHostTests.cs index c612c6c6288..e5af3c065fe 100644 --- a/tests/Aspire.Playground.Tests/AppHostTests.cs +++ b/tests/Aspire.Playground.Tests/AppHostTests.cs @@ -185,6 +185,11 @@ public static IList GetAllTestEndpoints() waitForTexts: [ new ("storage", "Azurite Table service is successfully listening") ]), + new TestEndpoints("Dapr.AppHost", + resourceEndpoints: new() { + { "servicea", ["/alive", "/health", "/weatherforecast"] }, + { "serviceb", ["/alive", "/health", "/weatherforecast"] }, + }), new TestEndpoints("MilvusPlayground.AppHost", resourceEndpoints: new() { { "apiservice", ["/alive", "/health", "/create", "/search"] } }, waitForTexts: [ diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 67930e243a9..4bf056f7958 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -49,6 +49,7 @@ + diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets index 1488f77ecb9..f41b3cd9dc9 100644 --- a/tests/helix/send-to-helix-buildonhelixtests.targets +++ b/tests/helix/send-to-helix-buildonhelixtests.targets @@ -4,6 +4,7 @@ $(BuildHelixWorkItemsDependsOn);BuildHelixWorkItemsForBuildOnHelixTests true true + true $(TestArchiveTestsDirForBuildOnHelixTests)**/*.zip diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 6700a59bcb1..4580b4f31f9 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -96,7 +96,7 @@ - + From 7257d5cb5a5757aa4affde2bd772a2d21685a7d9 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 22:11:55 -0400 Subject: [PATCH 5/6] add redis --- playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj | 1 + playground/dapr/Dapr.AppHost/Program.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj b/playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj index a1e326c62ec..79727e337e8 100644 --- a/playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj +++ b/playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj @@ -15,6 +15,7 @@ + diff --git a/playground/dapr/Dapr.AppHost/Program.cs b/playground/dapr/Dapr.AppHost/Program.cs index 32216d54c0b..d87860fcc85 100644 --- a/playground/dapr/Dapr.AppHost/Program.cs +++ b/playground/dapr/Dapr.AppHost/Program.cs @@ -1,5 +1,6 @@ var builder = DistributedApplication.CreateBuilder(args); +var redis = builder.AddRedis("redis", 6379); var stateStore = builder.AddDaprStateStore("statestore"); var pubSub = builder.AddDaprPubSub("pubsub"); From e667143b24166b681f66de966f8d1b1b22ba0c8a Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 23 Aug 2024 22:30:37 -0400 Subject: [PATCH 6/6] init dapr --- tests/helix/send-to-helix-inner.proj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 4580b4f31f9..1af5afc9e45 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -96,7 +96,9 @@ - + + +