Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency error running tests in parallel #8078

Open
1 task done
afscrome opened this issue Mar 14, 2025 · 0 comments
Open
1 task done

Concurrency error running tests in parallel #8078

afscrome opened this issue Mar 14, 2025 · 0 comments
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Comments

@afscrome
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a suite of 8 tests using DistributedApplicationTestingBuilder running in an Azure devops pipeline, and today one of these tests failed with the following error:

System.IO.IOException: The process cannot access the file 'C:\Users\AzDevOps\AppData\Local\Temp\aspire.toayd2p0.3lz\kubeconfig' because it is being used by another process.`

I do have NUnit test parallelization enabled, so I assume this is a concurrency issue. These build agents should have Windows Defender running in passive mode, so I also don't expect this to be a case of AV software interfering.

I haven't seen this error before, but today is also the first time I've started running these tests on a windows build agent, so I don't yet know if this is a rare event I was unlucky to encounter, or if this is going to be a common issue.

Expected Behavior

I expect to be able to run multiple test's in parallel.

Steps To Reproduce

Don't have exact repro steps, but I suspect this is a concurrency issue due to me running test in parallel - I believe

// nunit
[assembly: Parallelizable(ParallelScope.Fixtures)]

Exceptions (if any)

 fail: Microsoft.Extensions.Hosting.Internal.Host[11]
       Hosting failed to start
       System.IO.IOException: The process cannot access the file 'C:\Users\AzDevOps\AppData\Local\Temp\aspire.toayd2p0.3lz\kubeconfig' because it is being used by another process.
          at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
          at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
          at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
          at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
          at System.IO.FileInfo.OpenRead()
          at k8s.KubernetesClientConfiguration.LoadKubeConfigAsync(FileInfo kubeconfig, Boolean useRelativePaths)
          at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(FileInfo kubeconfig, String currentContext, String masterUrl, Boolean useRelativePaths)
          at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass33_0.<<EnsureKubernetesAsync>b__0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 552
       --- End of stack trace from previous location ---
          at Polly.ResiliencePipeline.<>c__10`1.<<ExecuteAsync>b__10_0>d.MoveNext()
       --- End of stack trace from previous location ---
          at Polly.Outcome`1.GetResultOrRethrow()
          at Polly.ResiliencePipeline.ExecuteAsync[TResult](Func`2 callback, CancellationToken cancellationToken)
          at Aspire.Hosting.Dcp.KubernetesService.EnsureKubernetesAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 543
          at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass28_0`1.<<ExecuteWithRetry>b__0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 439
       --- End of stack trace from previous location ---
          at Polly.ResiliencePipeline.<>c__10`1.<<ExecuteAsync>b__10_0>d.MoveNext()
       --- End of stack trace from previous location ---
          at Polly.Outcome`1.GetResultOrRethrow()
          at Polly.ResiliencePipeline.ExecuteAsync[TResult](Func`2 callback, CancellationToken cancellationToken)
          at Aspire.Hosting.Dcp.KubernetesService.ExecuteWithRetry[TResult](DcpApiOperationType operationType, String resourceType, Func`2 operation, Func`2 isRetryable, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 437
          at Aspire.Hosting.Dcp.DcpExecutor.CreateResourcesAsync[RT](CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 1392
          at Aspire.Hosting.Dcp.DcpExecutor.CreateServicesAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 590
          at Aspire.Hosting.Dcp.DcpExecutor.RunApplicationAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 126
          at Aspire.Hosting.Orchestrator.ApplicationOrchestrator.RunApplicationAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:line 177
          at Aspire.Hosting.Orchestrator.OrchestratorHostService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Orchestrator/OrchestratorHostService.cs:line 41
          at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
          at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)

.NET Version info

No response

Anything else?

No response

@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

1 participant