Skip to content

Fix deployment test race condition in agent init prompt handling#16703

Merged
mitchdenny merged 1 commit intomainfrom
fix/deployment-test-agent-init-race
May 3, 2026
Merged

Fix deployment test race condition in agent init prompt handling#16703
mitchdenny merged 1 commit intomainfrom
fix/deployment-test-agent-init-race

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

Description

Fixes two race conditions in deployment E2E test infrastructure that caused flaky failures in tests with multiple aspire add calls (e.g., AzureKeyVaultDeploymentTests, VnetStorageBlobInfraDeploymentTests, AksWithAzureResourcesDeploymentTests, TypeScriptVnetSqlServerInfraDeploymentTests).

Root cause

DeclineAgentInitPromptAsync was sending an Enter keypress after typing "n" to the [Y/n] agent init confirmation prompt. This created a race condition: if aspire init exited after reading "n" but before the Enter was delivered to the PTY, bash received the Enter and executed a phantom blank command, advancing CMDCOUNT by one. This desynced the test's SequenceCounter from bash's prompt counter, causing WaitForAspireAddCompletionAsync to match stale prompt text and return before aspire add finished. Subsequent commands (environment variable exports, additional aspire add calls) were then typed into the still-running aspire add process's stdin, meaning packages were never installed and deployments failed with CS1061 build errors.

Changes

  1. DeclineAgentInitPromptAsync: Remove Enter after typing "n". Spectre Console's [Y/n] confirmation prompt accepts single-character input — Enter is unnecessary and caused the phantom command race.

  2. WaitForAspireAddCompletionAsync: Remove addCompleted ("added to your AppHost project") and addFailed ("already exists in the project") text-based matching. These patterns persist on the terminal from prior aspire add runs, causing false matches for subsequent calls in the same test. Now relies solely on version-selection prompts and shell counter-based prompt detection.

Validation

Verified with a full deployment E2E test run: 37/37 tests passed (previously 4 failures).

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Two fixes for flaky deployment E2E tests:

1. DeclineAgentInitPromptAsync: Remove Enter after typing 'n' for the
   [Y/n] agent init prompt. Spectre Console accepts single-character
   input. The Enter was racing with aspire-init exit — if bash received
   the Enter, it executed a phantom blank command, advancing CMDCOUNT
   and desyncing the test counter from the shell counter. This caused
   WaitForAspireAddCompletionAsync to match stale prompts and return
   before aspire-add finished, so subsequent commands (env var exports)
   were typed into aspire-add's stdin.

2. WaitForAspireAddCompletionAsync: Remove addCompleted and addFailed
   text-based matching. These patterns ('added to your AppHost project'
   and 'already exists in the project') persist on the terminal from
   prior aspire-add runs, causing false matches for subsequent calls
   in the same test. Now relies solely on version-selection prompts
   and shell counter-based prompt detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 2, 2026 23:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16703

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16703"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Hex1b-based deployment E2E test automation against prompt/output races that could desync the test SequenceCounter from the bash prompt counter when multiple aspire add commands run in the same terminal session.

Changes:

  • Removes Enter submission after declining the agent-init [Y/n] prompt to avoid “phantom command” execution in bash.
  • Eliminates aspire add completion detection based on persisted terminal text, relying instead on counter-based shell prompt detection (and version-selection prompts).

@mitchdenny
Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

🚀 Deployment tests starting on PR #16703...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

🎬 CLI E2E Test Recordings — 75 recordings uploaded (commit 02a22fa)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LatestCliCanStartStableChannelAppHost ▶️ View Recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25264951789

@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 3, 2026 00:36 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Deployment E2E Tests passed — 33 passed, 0 failed, 0 cancelled

View test results and recordings

View workflow run

Test Result Recording
Deployment.EndToEnd-TypeScriptVnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCompactNamingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureLogAnalyticsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksVnetInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureContainerRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AppServiceReactDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureStorageDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksWithAzureResourcesDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AuthenticationTests ✅ Passed
Deployment.EndToEnd-AzureServiceBusDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-KubernetesGatewayTlsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptExpressDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-NspStorageKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterWithRedisHelmDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksVnetWithAzureResourcesDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksMultipleNodePoolsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-FrontDoorDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureEventHubsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaDeploymentErrorOutputTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCustomRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaExistingRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureAppConfigDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaManagedRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksBlazorRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureKeyVaultDeploymentTests ✅ Passed ▶️ View Recording

@mitchdenny mitchdenny merged commit c0639ac into main May 3, 2026
608 of 611 checks passed
@github-actions github-actions Bot added this to the 13.4 milestone May 3, 2026
@aspire-repo-bot
Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

This PR fixes an internal test infrastructure race condition in deployment E2E tests — it touches only test helper code, with no public API additions, no behavioral changes to user-facing features, and no configuration or CLI changes. The author also confirmed docs are not needed in the PR checklist.

Generated by PR Documentation Check for issue #16703 · ● 105.3K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants