Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playground/dapr/Dapr.AppHost/Dapr.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Dapr" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Redis" />

<ProjectReference Include="..\ServiceA\DaprServiceA.csproj" />
<ProjectReference Include="..\ServiceB\DaprServiceB.csproj" />
Expand Down
1 change: 1 addition & 0 deletions playground/dapr/Dapr.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var builder = DistributedApplication.CreateBuilder(args);

var redis = builder.AddRedis("redis", 6379);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dapr CLI usually spins this up.

var stateStore = builder.AddDaprStateStore("statestore");
var pubSub = builder.AddDaprPubSub("pubsub");

Expand Down
1 change: 1 addition & 0 deletions src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="..\Aspire.Hosting\Dcp\Process\ProcessResult.cs" Link="Provisioning\Utils\ProcessResult.cs" />
<Compile Include="..\Aspire.Hosting\Dcp\Process\ProcessSpec.cs" Link="Provisioning\Utils\ProcessSpec.cs" />
<Compile Include="..\Aspire.Hosting\Dcp\Process\ProcessUtil.cs" Link="Provisioning\Utils\ProcessUtil.cs" />
<Compile Include="..\Shared\FileUtil.cs" Link="Shared\FileUtil.cs" />
<Compile Include="..\Shared\Cosmos\CosmosConstants.cs" Link="Shared\CosmosConstants.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -395,30 +395,6 @@ private static async Task<bool> 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<string, bool> 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
Expand Down
1 change: 1 addition & 0 deletions src/Aspire.Hosting.Dapr/Aspire.Hosting.Dapr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="$(SharedDir)FileUtil.cs" Link="Utils\FileUtil.cs" />
<Compile Include="$(SharedDir)Utf8JsonWriterExtensions.cs" Link="Utils\Utf8JsonWriterExtensions.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
var sideCars = new List<ExecutableResource>();

var fileName = this._options.DaprPath
?? GetDefaultDaprPath()
?? FileUtil.FindFullPathFromPath("dapr")
?? throw new DistributedApplicationException("Unable to locate the Dapr CLI.");

foreach (var resource in appModel.Resources)
Expand Down Expand Up @@ -282,49 +282,6 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
return null;
}

/// <summary>
/// Return the first verified dapr path
/// </summary>
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<string> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Diagnostics;

namespace Aspire.Components.Common.Tests;
namespace Aspire;

internal static class FileUtil
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="$(SharedDir)FileUtil.cs" />

<PackageReference Include="JsonSchema.Net" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
Expand Down
5 changes: 5 additions & 0 deletions tests/Aspire.Playground.Tests/AppHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ public static IList<TestEndpoints> 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: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<!-- Only `dotnet run` startup checked -->
<ProjectReference Include="$(PlaygroundSourceDir)mongo/Mongo.AppHost/Mongo.AppHost.csproj" />

<ProjectReference Include="$(PlaygroundSourceDir)dapr/Dapr.AppHost/Dapr.AppHost.csproj" />
<ProjectReference Include="$(PlaygroundSourceDir)mysql/MySqlDb.AppHost/MySqlDb.AppHost.csproj" />
<ProjectReference Include="$(PlaygroundSourceDir)nats/Nats.AppHost/Nats.AppHost.csproj" />
<ProjectReference Include="$(PlaygroundSourceDir)seq/Seq.AppHost/Seq.AppHost.csproj" />
Expand Down
1 change: 1 addition & 0 deletions tests/helix/send-to-helix-basictests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<WorkItemArchiveWildCard>$(TestArchiveTestsDir)**/*.zip</WorkItemArchiveWildCard>
<BuildHelixWorkItemsDependsOn>$(BuildHelixWorkItemsDependsOn);BuildHelixWorkItemsForDefaultTests</BuildHelixWorkItemsDependsOn>
<NeedsDcpPathOverride>true</NeedsDcpPathOverride>
<NeedsDapr>true</NeedsDapr>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/helix/send-to-helix-buildonhelixtests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<BuildHelixWorkItemsDependsOn>$(BuildHelixWorkItemsDependsOn);BuildHelixWorkItemsForBuildOnHelixTests</BuildHelixWorkItemsDependsOn>
<NeedsWorkload>true</NeedsWorkload>
<NeedsPlaywright>true</NeedsPlaywright>
<NeedsDapr>true</NeedsDapr>

<WorkItemArchiveWildCard>$(TestArchiveTestsDirForBuildOnHelixTests)**/*.zip</WorkItemArchiveWildCard>

Expand Down
12 changes: 12 additions & 0 deletions tests/helix/send-to-helix-inner.proj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export PLAYWRIGHT_BROWSERS_PATH=$HELIX_CORRELATION_PAYLOAD/playwright-deps" />
</ItemGroup>

<ItemGroup Condition="'$(NeedsDapr)' == 'true'">
<HelixCorrelationPayload Condition="'$(OS)' != 'Windows_NT'" Include="dapr" Uri="https://github.com/dapr/cli/releases/download/v1.14.1/dapr_linux_amd64.tar.gz" Destination="dapr-cli" />
<HelixCorrelationPayload Condition="'$(OS)' == 'Windows_NT'" Include="dapr" Uri="https://github.com/dapr/cli/releases/download/v1.14.1/dapr_windows_amd64.zip" Destination="dapr-cli" />

<HelixPreCommand Condition="'$(OS)' == 'Windows_NT'" Include="set PATH=%HELIX_CORRELATION_PAYLOAD%\dapr-cli%3B%PATH%" />
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export PATH=$HELIX_CORRELATION_PAYLOAD/dapr-cli:$PATH" />

<HelixPreCommand Include="dapr init" />
<HelixPreCommand Include="dapr --version" />
<HelixPreCommand Include="dapr ps" />
</ItemGroup>

<ItemGroup Condition="'$(NeedsWorkload)' == 'true'">
<HelixPreCommand Condition="'$(OS)' == 'Windows_NT'" Include="set PATH=%HELIX_CORRELATION_PAYLOAD%\dotnet-latest%3B%PATH%" />
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export PATH=$HELIX_CORRELATION_PAYLOAD/dotnet-latest:$PATH" />
Expand Down