Skip to content

Commit 91da4a0

Browse files
Fix deployment E2E nightly failures (#16072)
* Fix deployment E2E tests for issue 16057 * Handle optional init prompts in deployment tests
1 parent ed74706 commit 91da4a0

File tree

6 files changed

+175
-27
lines changed

6 files changed

+175
-27
lines changed

tests/Aspire.Deployment.EndToEnd.Tests/AcaCompactNamingUpgradeDeploymentTests.cs

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,107 @@ private async Task UpgradeFromGaToDevDoesNotDuplicateStorageAccountsCore(Cancell
9898

9999
// Step 5: Create single-file AppHost with GA CLI
100100
output.WriteLine("Step 5: Creating single-file AppHost with GA CLI...");
101+
var waitingForLanguageSelectionPrompt = new CellPatternSearcher()
102+
.Find("Which language would you like to use?");
103+
var waitingForTemplateVersionPrompt = new CellPatternSearcher()
104+
.Find("NuGet.config");
105+
var waitingForAgentInitPrompt = new CellPatternSearcher()
106+
.Find("configure AI agent environments");
107+
var waitingForSuccessPrompt = new CellPatternSearcher()
108+
.FindPattern(counter.Value.ToString())
109+
.RightText(" OK] $ ");
110+
101111
await auto.TypeAsync("aspire init");
102112
await auto.EnterAsync();
103-
await auto.WaitAsync(TimeSpan.FromSeconds(5));
104-
await auto.EnterAsync();
105-
await auto.WaitUntilTextAsync("Aspire initialization complete", timeout: TimeSpan.FromMinutes(2));
106-
await auto.DeclineAgentInitPromptAsync(counter);
113+
114+
var initState = "success";
115+
await auto.WaitUntilAsync(s =>
116+
{
117+
if (waitingForLanguageSelectionPrompt.Search(s).Count > 0)
118+
{
119+
initState = "language";
120+
return true;
121+
}
122+
123+
if (waitingForTemplateVersionPrompt.Search(s).Count > 0)
124+
{
125+
initState = "template-version";
126+
return true;
127+
}
128+
129+
if (waitingForAgentInitPrompt.Search(s).Count > 0)
130+
{
131+
initState = "agent-init";
132+
return true;
133+
}
134+
135+
if (waitingForSuccessPrompt.Search(s).Count > 0)
136+
{
137+
initState = "success";
138+
return true;
139+
}
140+
141+
return false;
142+
}, timeout: TimeSpan.FromMinutes(2), description: "language prompt, template version prompt, agent init prompt, or init success prompt");
143+
144+
if (initState == "language")
145+
{
146+
await auto.EnterAsync();
147+
148+
await auto.WaitUntilAsync(s =>
149+
{
150+
if (waitingForTemplateVersionPrompt.Search(s).Count > 0)
151+
{
152+
initState = "template-version";
153+
return true;
154+
}
155+
156+
if (waitingForAgentInitPrompt.Search(s).Count > 0)
157+
{
158+
initState = "agent-init";
159+
return true;
160+
}
161+
162+
if (waitingForSuccessPrompt.Search(s).Count > 0)
163+
{
164+
initState = "success";
165+
return true;
166+
}
167+
168+
return false;
169+
}, timeout: TimeSpan.FromMinutes(2), description: "template version prompt, agent init prompt, or init success prompt");
170+
}
171+
172+
if (initState == "template-version")
173+
{
174+
await auto.EnterAsync();
175+
176+
await auto.WaitUntilAsync(s =>
177+
{
178+
if (waitingForAgentInitPrompt.Search(s).Count > 0)
179+
{
180+
initState = "agent-init";
181+
return true;
182+
}
183+
184+
if (waitingForSuccessPrompt.Search(s).Count > 0)
185+
{
186+
initState = "success";
187+
return true;
188+
}
189+
190+
return false;
191+
}, timeout: TimeSpan.FromMinutes(2), description: "agent init prompt or init success prompt");
192+
}
193+
194+
if (initState == "agent-init")
195+
{
196+
await auto.DeclineAgentInitPromptAsync(counter);
197+
}
198+
else
199+
{
200+
await auto.WaitForSuccessPromptAsync(counter);
201+
}
107202

108203
// Step 6: Add ACA package using GA CLI (uses GA NuGet packages)
109204
output.WriteLine("Step 6: Adding Azure Container Apps package (GA)...");

tests/Aspire.Deployment.EndToEnd.Tests/AcaManagedRedisDeploymentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private async Task DeployStarterWithManagedRedisToAzureContainerAppsCore(Cancell
7575
.Find($"Enter the project name ({workspace.WorkspaceRoot.Name}): ");
7676

7777
var waitingForOutputPathPrompt = new CellPatternSearcher()
78-
.Find("Enter the output path:");
78+
.Find("Enter the output path");
7979

8080
var waitingForUrlsPrompt = new CellPatternSearcher()
8181
.Find("Use *.dev.localhost URLs");

tests/Aspire.Deployment.EndToEnd.Tests/AcrPurgeTaskDeploymentTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@ private async Task DeployPythonStarterWithPurgeTaskCore(CancellationToken cancel
7474
await auto.PrepareEnvironmentAsync(workspace, counter);
7575

7676
// Step 2: Set up CLI environment (in CI)
77+
// Python apphosts need the full bundle because
78+
// the prebuilt AppHost server is required for aspire new with Python templates.
7779
if (DeploymentE2ETestHelpers.IsRunningInCI)
7880
{
79-
output.WriteLine("Step 2: Using pre-installed Aspire CLI from local build...");
80-
await auto.SourceAspireCliEnvironmentAsync(counter);
81+
var prNumber = DeploymentE2ETestHelpers.GetPrNumber();
82+
if (prNumber > 0)
83+
{
84+
output.WriteLine($"Step 2: Installing Aspire bundle from PR #{prNumber}...");
85+
await auto.InstallAspireBundleFromPullRequestAsync(prNumber, counter);
86+
}
87+
await auto.SourceAspireBundleEnvironmentAsync(counter);
8188
}
8289

8390
// Step 3: Create Python FastAPI project using aspire new
@@ -95,7 +102,7 @@ private async Task DeployPythonStarterWithPurgeTaskCore(CancellationToken cancel
95102
await auto.TypeAsync("aspire add Aspire.Hosting.Azure.AppContainers");
96103
await auto.EnterAsync();
97104

98-
if (DeploymentE2ETestHelpers.IsRunningInCI)
105+
if (DeploymentE2ETestHelpers.IsRunningInCI && DeploymentE2ETestHelpers.GetPrNumber() <= 0)
99106
{
100107
await auto.WaitUntilTextAsync("(based on NuGet.config)", timeout: TimeSpan.FromSeconds(60));
101108
await auto.EnterAsync();

tests/Aspire.Deployment.EndToEnd.Tests/AppServicePythonDeploymentTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,17 @@ private async Task DeployPythonFastApiTemplateToAzureAppServiceCore(Cancellation
7676
await auto.PrepareEnvironmentAsync(workspace, counter);
7777

7878
// Step 2: Set up CLI environment (in CI)
79+
// Python apphosts need the full bundle because
80+
// the prebuilt AppHost server is required for aspire new with Python templates.
7981
if (DeploymentE2ETestHelpers.IsRunningInCI)
8082
{
81-
output.WriteLine("Step 2: Using pre-installed Aspire CLI from local build...");
82-
await auto.SourceAspireCliEnvironmentAsync(counter);
83+
var prNumber = DeploymentE2ETestHelpers.GetPrNumber();
84+
if (prNumber > 0)
85+
{
86+
output.WriteLine($"Step 2: Installing Aspire bundle from PR #{prNumber}...");
87+
await auto.InstallAspireBundleFromPullRequestAsync(prNumber, counter);
88+
}
89+
await auto.SourceAspireBundleEnvironmentAsync(counter);
8390
}
8491

8592
// Step 3: Create Python FastAPI project using aspire new with interactive prompts

tests/Aspire.Deployment.EndToEnd.Tests/PythonFastApiDeploymentTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,17 @@ private async Task DeployPythonFastApiTemplateToAzureContainerAppsCore(Cancellat
7676
await auto.PrepareEnvironmentAsync(workspace, counter);
7777

7878
// Step 2: Set up CLI environment (in CI)
79+
// Python apphosts need the full bundle because
80+
// the prebuilt AppHost server is required for aspire new with Python templates.
7981
if (DeploymentE2ETestHelpers.IsRunningInCI)
8082
{
81-
output.WriteLine("Step 2: Using pre-installed Aspire CLI from local build...");
82-
await auto.SourceAspireCliEnvironmentAsync(counter);
83+
var prNumber = DeploymentE2ETestHelpers.GetPrNumber();
84+
if (prNumber > 0)
85+
{
86+
output.WriteLine($"Step 2: Installing Aspire bundle from PR #{prNumber}...");
87+
await auto.InstallAspireBundleFromPullRequestAsync(prNumber, counter);
88+
}
89+
await auto.SourceAspireBundleEnvironmentAsync(counter);
8390
}
8491

8592
// Step 3: Create Python FastAPI project using aspire new with interactive prompts

tests/Aspire.Deployment.EndToEnd.Tests/TypeScriptVnetSqlServerInfraDeploymentTests.cs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,60 @@ private async Task DeployTypeScriptVnetSqlServerInfrastructureCore(CancellationT
8686
// Step 3: Create TypeScript AppHost using aspire init
8787
output.WriteLine("Step 3: Creating TypeScript AppHost with aspire init...");
8888

89-
var waitingForNuGetConfigPrompt = new CellPatternSearcher()
89+
var waitingForTemplateVersionPrompt = new CellPatternSearcher()
9090
.Find("NuGet.config");
91-
var waitingForInitComplete = new CellPatternSearcher()
92-
.Find("Aspire initialization complete");
91+
var waitingForAgentInitPrompt = new CellPatternSearcher()
92+
.Find("configure AI agent environments");
93+
var waitingForSuccessPrompt = new CellPatternSearcher()
94+
.FindPattern(counter.Value.ToString())
95+
.RightText(" OK] $ ");
9396

9497
await auto.TypeAsync("aspire init --language typescript");
9598
await auto.EnterAsync();
9699

97-
// NuGet.config prompt may or may not appear depending on environment.
98-
await auto.WaitUntilAsync(
99-
s => waitingForNuGetConfigPrompt.Search(s).Count > 0
100-
|| waitingForInitComplete.Search(s).Count > 0,
101-
timeout: TimeSpan.FromMinutes(2),
102-
description: "NuGet.config prompt or init completion");
103-
await auto.EnterAsync(); // Dismiss NuGet.config prompt if present
100+
var sawTemplateVersionPrompt = false;
101+
var sawAgentInitPrompt = false;
102+
await auto.WaitUntilAsync(s =>
103+
{
104+
if (waitingForTemplateVersionPrompt.Search(s).Count > 0)
105+
{
106+
sawTemplateVersionPrompt = true;
107+
return true;
108+
}
104109

105-
await auto.WaitUntilAsync(
106-
s => waitingForInitComplete.Search(s).Count > 0,
107-
timeout: TimeSpan.FromMinutes(2),
108-
description: "aspire initialization complete");
110+
if (waitingForAgentInitPrompt.Search(s).Count > 0)
111+
{
112+
sawAgentInitPrompt = true;
113+
return true;
114+
}
115+
116+
return waitingForSuccessPrompt.Search(s).Count > 0;
117+
}, timeout: TimeSpan.FromMinutes(2), description: "template version prompt, agent init prompt, or init success prompt");
118+
119+
if (sawTemplateVersionPrompt)
120+
{
121+
await auto.EnterAsync();
109122

110-
await auto.DeclineAgentInitPromptAsync(counter);
123+
await auto.WaitUntilAsync(s =>
124+
{
125+
if (waitingForAgentInitPrompt.Search(s).Count > 0)
126+
{
127+
sawAgentInitPrompt = true;
128+
return true;
129+
}
130+
131+
return waitingForSuccessPrompt.Search(s).Count > 0;
132+
}, timeout: TimeSpan.FromMinutes(2), description: "agent init prompt or init success prompt");
133+
}
134+
135+
if (sawAgentInitPrompt)
136+
{
137+
await auto.DeclineAgentInitPromptAsync(counter);
138+
}
139+
else
140+
{
141+
await auto.WaitForSuccessPromptAsync(counter);
142+
}
111143

112144
// Step 4a: Add Aspire.Hosting.Azure.AppContainers
113145
output.WriteLine("Step 4a: Adding Azure Container Apps hosting package...");

0 commit comments

Comments
 (0)