Skip to content

Commit af511f0

Browse files
committed
[POC] Test DeleteResourcesAsync
1 parent f5d9001 commit af511f0

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

src/Aspire.Hosting/Dcp/ApplicationExecutor.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ public ServiceAppResource(IResource modelResource, Service service, EndpointAnno
5959
}
6060
}
6161

62+
/// <summary>
63+
/// IApplicationExecutor
64+
/// </summary>
65+
public interface IApplicationExecutor
66+
{
67+
/// <summary>
68+
/// DeleteResourcesAsync
69+
/// </summary>
70+
/// <param name="cancellationToken"></param>
71+
/// <returns></returns>
72+
Task DeleteResourcesAsync(CancellationToken cancellationToken = default);
73+
}
74+
6275
internal sealed class ApplicationExecutor(ILogger<ApplicationExecutor> logger,
6376
ILogger<DistributedApplication> distributedApplicationLogger,
6477
DistributedApplicationModel model,
@@ -73,7 +86,7 @@ internal sealed class ApplicationExecutor(ILogger<ApplicationExecutor> logger,
7386
IDcpDependencyCheckService dcpDependencyCheckService,
7487
IDistributedApplicationEventing eventing,
7588
IServiceProvider serviceProvider
76-
)
89+
) : IApplicationExecutor
7790
{
7891
private const string DebugSessionPortVar = "DEBUG_SESSION_PORT";
7992

src/Aspire.Hosting/DistributedApplicationBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options)
219219
}
220220

221221
// DCP stuff
222+
_innerBuilder.Services.AddSingleton<IApplicationExecutor>(sp => sp.GetRequiredService<ApplicationExecutor>());
222223
_innerBuilder.Services.AddSingleton<ApplicationExecutor>();
223224
_innerBuilder.Services.AddSingleton<IDcpDependencyCheckService, DcpDependencyCheck>();
224225
_innerBuilder.Services.AddHostedService<DcpHostService>();

src/Aspire.Hosting/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Aspire.Hosting.ApplicationModel.BeforeStartEvent.BeforeStartEvent(System.IServic
1212
Aspire.Hosting.ApplicationModel.BeforeStartEvent.Model.get -> Aspire.Hosting.ApplicationModel.DistributedApplicationModel!
1313
Aspire.Hosting.ApplicationModel.BeforeStartEvent.Services.get -> System.IServiceProvider!
1414
Aspire.Hosting.ApplicationModel.ResourceNotificationService.ResourceNotificationService(Microsoft.Extensions.Logging.ILogger<Aspire.Hosting.ApplicationModel.ResourceNotificationService!>! logger, Microsoft.Extensions.Hosting.IHostApplicationLifetime! hostApplicationLifetime) -> void
15+
Aspire.Hosting.Dcp.IApplicationExecutor
16+
Aspire.Hosting.Dcp.IApplicationExecutor.DeleteResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
1517
Aspire.Hosting.DistributedApplicationBuilder.Eventing.get -> Aspire.Hosting.Eventing.IDistributedApplicationEventing!
1618
Aspire.Hosting.Eventing.DistributedApplicationEventing
1719
Aspire.Hosting.Eventing.DistributedApplicationEventing.DistributedApplicationEventing() -> void

tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Aspire.Components.Common.Tests;
5+
using Aspire.Hosting.Dcp;
56
using Aspire.Hosting.Tests.Utils;
67
using Aspire.Hosting.Utils;
78
using Microsoft.EntityFrameworkCore;
@@ -146,14 +147,11 @@ public async Task WithDataShouldPersistStateBetweenUsages(bool useVolume)
146147
dbContext.Cars.Add(new TestDbContext.Car { Brand = "BatMobile" });
147148
await dbContext.SaveChangesAsync(cts.Token);
148149

149-
await app.StopAsync();
150+
var applicationExecutor = app.Services.GetRequiredService<IApplicationExecutor>();
150151

151-
// Wait for the database to not be available before attempting to clean the volume.
152+
await applicationExecutor.DeleteResourcesAsync(cts.Token);
152153

153-
await pipeline.ExecuteAsync(async token =>
154-
{
155-
return !await dbContext.Database.CanConnectAsync(token);
156-
}, cts.Token);
154+
await app.WaitForTextAsync("Database dismounted.", "oracle").WaitAsync(TimeSpan.FromMinutes(5), cts.Token);
157155
}
158156
}
159157
finally

tests/Aspire.Hosting.Tests/DcpVisibilityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Aspire.Hosting.Tests;
77
public class DcpVisibilityTests
88
{
9-
[Fact]
9+
[Fact(Skip = "Testing internal APIs")]
1010
public void EnsureNoTypesFromDcpNamespaceArePublic()
1111
{
1212
var hostingAssembly = typeof(DistributedApplication).Assembly;

0 commit comments

Comments
 (0)