Skip to content

AuxiliaryBackchannelService concurrency error with parallel tests #13761

@afscrome

Description

@afscrome

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When running DistributedApplicationBuilder tests in parallel, I'm seeing a variety of concurrency errors related to AuxiliaryBackchannelService.

Expected Behavior

No response

Steps To Reproduce

The tests I'm seeing this on are fairly simple - here is one such example.

    [Fact]
    public async Task ExecutableDoesNotExist()
    {
        using var cts = DefaultCancellationTokenSource();
        await using var builder = DistributedApplicationTestingBuilder.Create();

        var container = builder.AddExecutable("exe", "does-not-exist", "");
        AddFakeLogging(container);

        await using var app = builder.Build();
        await app.StartAsync(cts.Token);
        await app.ResourceNotifications.WaitForResourceAsync(container.Resource.Name, KnownResourceStates.FailedToStart, cts.Token);

        //await Task.Delay(1_000);

        var snapshot = app.Services.GetFakeLogCollector().GetSnapshot();
        Assert.True(snapshot.Any());
        Assert.Contains("[sys] Failed to start a process: Cmd = does-not-exist, Args = [], Error = exec: \"does-not-exist\": executable file not found in %PATH%", snapshot[1].Message);
        Assert.Contains("[sys] Failed to start Executable: Error = exec: \"does-not-exist\": executable file not found in %PATH%", snapshot[2].Message);
    }

Exceptions (if any)

One run got

 fail: Aspire.Hosting.Backchannel.AuxiliaryBackchannelService[0]
      Error in auxiliary backchannel service
      System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
         at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
         at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
         at System.Net.Sockets.Socket.Bind(EndPoint localEP)
         at Aspire.Hosting.Backchannel.AuxiliaryBackchannelService.ExecuteAsync(CancellationToken stoppingToken) in /_/src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelService.cs:line 58

Another run got:

    fail: Aspire.Hosting.Backchannel.AuxiliaryBackchannelService[0]
      Error in auxiliary backchannel service
      System.UnauthorizedAccessException: Access to the path 'C:\Users\alex\.aspire\cli\backchannels\aux.sock.3e9ac6a75f625ccc' is denied.
         at System.IO.FileSystem.DeleteFile(String fullPath)
         at Aspire.Hosting.Backchannel.AuxiliaryBackchannelService.ExecuteAsync(CancellationToken stoppingToken) in /_/src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelService.cs:line 52
warn: Aspire.Hosting.Backchannel.AuxiliaryBackchannelService[0]
      Failed to delete socket file: C:\Users\alex\.aspire\cli\backchannels\aux.sock.3e9ac6a75f625ccc
      System.UnauthorizedAccessException: Access to the path 'C:\Users\alex\.aspire\cli\backchannels\aux.sock.3e9ac6a75f625ccc' is denied.
         at System.IO.FileSystem.DeleteFile(String fullPath)
         at Aspire.Hosting.Backchannel.AuxiliaryBackchannelService.ExecuteAsync(CancellationToken stoppingToken) in /_/src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelService.cs:line 100

.NET Version info

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-testingIssues pertaining to the APIs in Aspire.Hosting.Testingarea-cli

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions