Skip to content
Merged
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
67 changes: 0 additions & 67 deletions playground/Stress/Stress.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;

#pragma warning disable ASPIREDOTNETTOOL
#pragma warning disable ASPIREINTERACTION001
#pragma warning disable ASPIREPERSISTENCE001 // Resource lifetime APIs are experimental.

var builder = DistributedApplication.CreateBuilder(args);
builder.Services.AddHttpClient();
Expand All @@ -19,10 +17,6 @@
var manualArgSource = builder.AddExecutable("manual-arg-source", "dotnet", Environment.CurrentDirectory)
.WithHttpEndpoint(targetPort: 8088);
var manualArgEndpoint = manualArgSource.GetEndpoint("http");
var stressEmptyProjectPath = new Projects.Stress_Empty().ProjectPath;
const string interactionContainerImage = "alpine";
const string interactionContainerEntrypoint = "/bin/sh";
string[] interactionContainerArgs = ["-c", "while true; do sleep 3600; done"];

manualArgSource.WithArgs("--dashboard-port")
.WithArgs(c => c.Args.Add(manualArgEndpoint.Property(EndpointProperty.Port)));
Expand All @@ -41,45 +35,6 @@
.WithArgs(c => c.Args.Add(manualArgEndpoint.Property(EndpointProperty.Port)))
.WithExplicitStart();

builder.AddExecutable("manual-environment-interaction", "dotnet", Environment.CurrentDirectory, "run", "--project", stressEmptyProjectPath, "--no-build")
.WithExplicitStart()
.WithEnvironment(context => PromptForEnvironmentValueAsync(
context,
"MANUAL_ENVIRONMENT_INTERACTION_VALUE",
"Explicit start executable environment callback",
"This prompt should only appear after manually starting the session-scoped executable."));

builder.AddExecutable("persistent-environment-interaction", "dotnet", Environment.CurrentDirectory, "run", "--project", stressEmptyProjectPath, "--no-build")
.WithPersistentLifetime()
.WithExplicitStart()
.WithEnvironment(context => PromptForEnvironmentValueAsync(
context,
"PERSISTENT_EXECUTABLE_ENVIRONMENT_INTERACTION_VALUE",
"Persistent executable environment callback",
"This prompt appears during startup because persistent executable resources are registered with DCP immediately."));

builder.AddContainer("manual-container-environment-interaction", interactionContainerImage)
.WithEntrypoint(interactionContainerEntrypoint)
.WithArgs(interactionContainerArgs)
.WithExplicitStart()
.WithEnvironment(context => PromptForEnvironmentValueAsync(
context,
"MANUAL_CONTAINER_ENVIRONMENT_INTERACTION_VALUE",
"Explicit start container environment callback",
"This prompt should only appear after manually starting the session-scoped container."));

builder.AddContainer("persistent-container-environment-interaction", interactionContainerImage)
.WithContainerName("stress-persistent-container-environment-interaction")
.WithEntrypoint(interactionContainerEntrypoint)
.WithArgs(interactionContainerArgs)
.WithPersistentLifetime()
.WithExplicitStart()
.WithEnvironment(context => PromptForEnvironmentValueAsync(
context,
"PERSISTENT_CONTAINER_ENVIRONMENT_INTERACTION_VALUE",
"Persistent container environment callback",
"This prompt appears during startup because persistent container resources are registered with DCP immediately."));

for (var i = 0; i < 2; i++)
{
var name = $"test-{i:0000}";
Expand Down Expand Up @@ -144,8 +99,6 @@
builder.AddExecutable("executableWithSingleArg", "dotnet", Environment.CurrentDirectory, "--version");
builder.AddExecutable("executableWithSingleEscapedArg", "dotnet", Environment.CurrentDirectory, "one two");
builder.AddExecutable("executableWithMultipleArgs", "dotnet", Environment.CurrentDirectory, "--version", "one two");
builder.AddExecutable("persistentExecutable", "dotnet", Environment.CurrentDirectory, "run", "--project", stressEmptyProjectPath, "--no-build")
.WithPersistentLifetime();

IResourceBuilder<IResource>? previousResourceBuilder = null;

Expand All @@ -171,23 +124,3 @@
builder.AddNoStatusResource("no-status-resource");

builder.Build().Run();

static async Task PromptForEnvironmentValueAsync(
EnvironmentCallbackContext context,
string environmentVariableName,
string title,
string message)
{
var interactionService = context.ExecutionContext.ServiceProvider.GetRequiredService<IInteractionService>();
var result = await interactionService.PromptInputAsync(
title: title,
message: message,
inputLabel: "Environment value",
placeHolder: "Value from WithEnvironment callback",
cancellationToken: context.CancellationToken);

if (!result.Canceled && result.Data.Value is { } value)
{
context.EnvironmentVariables[environmentVariableName] = value;
}
}
Loading