Skip to content

Commit 898d03d

Browse files
committed
Improved check for container cleanup
1 parent f835dab commit 898d03d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public async Task CreateStartAndStopAspireProject()
2020
{
2121
var repoRoot = CliE2ETestHelpers.GetRepoRoot();
2222
var installMode = CliE2ETestHelpers.DetectDockerInstallMode(repoRoot);
23+
var projectSuffix = Guid.NewGuid().ToString("N")[..6];
24+
var projectName = $"StarterApp_{projectSuffix}";
2325

2426
var workspace = TemporaryWorkspace.Create(output);
2527

@@ -37,10 +39,10 @@ public async Task CreateStartAndStopAspireProject()
3739
await auto.InstallAspireCliInDockerAsync(installMode, counter);
3840

3941
// Create a new project using aspire new
40-
await auto.AspireNewAsync("AspireStarterApp", counter);
42+
await auto.AspireNewAsync(projectName, counter);
4143

4244
// Navigate to the AppHost directory
43-
await auto.TypeAsync("cd AspireStarterApp/AspireStarterApp.AppHost");
45+
await auto.TypeAsync($"cd {projectName}/{projectName}.AppHost");
4446
await auto.EnterAsync();
4547
await auto.WaitForSuccessPromptAsync(counter);
4648

@@ -58,9 +60,8 @@ public async Task CreateStartAndStopAspireProject()
5860

5961
await auto.ClearScreenAsync(counter);
6062

61-
// Ensure application container is cleaned up (zero containers running)
62-
// We expect one container left because the test is running in a container itself
63-
await auto.ExecuteCommandUntilOutputAsync(counter, "docker ps --all --format json | wc -l", "1", timeout: TimeSpan.FromMinutes(2));
63+
// Ensure the test-specific Docker network is cleaned up (which signifies end of container cleanup)
64+
await auto.ExecuteCommandUntilOutputAsync(counter, $"docker network ls --format json | grep -i -- '{projectName}' | wc -l", "0", timeout: TimeSpan.FromMinutes(2));
6465

6566
// Exit the shell
6667
await auto.TypeAsync("exit");

0 commit comments

Comments
 (0)