Skip to content

Coverlet fails on concurrent runs #950

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

Closed
tkukushkin opened this issue Sep 14, 2020 · 8 comments
Closed

Coverlet fails on concurrent runs #950

tkukushkin opened this issue Sep 14, 2020 · 8 comments
Labels
waiting for customer Waiting for customer action

Comments

@tkukushkin
Copy link

Hello!

We write functional tests on python and want to collect coverage from our dotnet applications. Tests start several instances of same dll with different parameters. We used dotcover before and everything was fine. But with coverlet we get such error:

---> System.IO.IOException: The process cannot access the file '/Users/tkukushkin/Projects/builders-balance/Scheduler/bin/Debug/netcoreapp3.1/Scheduler.pdb' because it is being used by another process.
   at System.IO.FileStream.Init(FileMode mode, FileShare share, String originalPath)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at Coverlet.Core.Helpers.FileSystem.Copy(String sourceFileName, String destFileName, Boolean overwrite) in /_/src/coverlet.core/Helpers/FileSystem.cs:line 33
   at Coverlet.Core.Helpers.InstrumentationHelper.<>c__DisplayClass12_0.<RestoreOriginalModules>b__0() in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 245
   at Coverlet.Core.Helpers.RetryHelper.<>c__DisplayClass0_0.<Retry>b__0() in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 26
   at Coverlet.Core.Helpers.RetryHelper.Do[T](Func`1 action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 52
   --- End of inner exception stack trace ---
   at Coverlet.Core.Helpers.RetryHelper.Do[T](Func`1 action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 59
   at Coverlet.Core.Helpers.RetryHelper.Retry(Action action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 28
   at Coverlet.Core.Helpers.InstrumentationHelper.RestoreOriginalModules() in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 242
   at Coverlet.Core.Helpers.InstrumentationHelper.<.ctor>b__5_0(Object s, EventArgs e) in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 26
   at System.AppContext.OnProcessExit()
 ---> (Inner Exception #1) System.IO.IOException: The process cannot access the file '/Users/tkukushkin/Projects/builders-balance/Scheduler/bin/Debug/netcoreapp3.1/Scheduler.pdb' because it is being used by another process.
   at System.IO.FileStream.Init(FileMode mode, FileShare share, String originalPath)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at Coverlet.Core.Helpers.FileSystem.Copy(String sourceFileName, String destFileName, Boolean overwrite) in /_/src/coverlet.core/Helpers/FileSystem.cs:line 33
   at Coverlet.Core.Helpers.InstrumentationHelper.<>c__DisplayClass12_0.<RestoreOriginalModules>b__0() in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 245
   at Coverlet.Core.Helpers.RetryHelper.<>c__DisplayClass0_0.<Retry>b__0() in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 26
   at Coverlet.Core.Helpers.RetryHelper.Do[T](Func`1 action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 52<---

coverlet.console version: 1.7.0.0

@MarcoRossignoli MarcoRossignoli added the waiting for customer Waiting for customer action label Sep 14, 2020
@MarcoRossignoli
Copy link
Collaborator

Can you explain how you use coverlet command?Run parallel(on same test file) coverlet xxx won't work because file is instrumented and restored at every test run so you'll get concurrent access to same dll during instrumentation.

@tkukushkin
Copy link
Author

tkukushkin commented Sep 14, 2020

Dll is always the same.

coverlet <some-dll> --target dotnet --targetargs "exec <some-dll>" --include-test-assembly <other-options>

Maybe there is some workaround for our case?

@MarcoRossignoli
Copy link
Collaborator

mmm at the moment no...you need to run tasks in a sequential way. Or use some other way like collectors and run all different test project in parallel, are you running on .NET Framework or .NET Core?

We used dotcover before and everything was fine

I don't know ho dotcover works, just for curiosity can you attach dotcover run script?

@tkukushkin
Copy link
Author

We run .NET Core, but our dll is not test suite, we run real application under coverage, tests written on Python, one test can use several instances of application (for example one instance can be web, second instance can be rabbitmq consumer). After all we merge reports from all application runs in single report.

Our dotcover command:

dotcover.sh  dotnet --ReportType=DetailedXML --Output=detailed.xml <other options> -- exec <some-dll>

@MarcoRossignoli
Copy link
Collaborator

You could try something like that #781 (comment)
But with different copy of artifacts

@tkukushkin
Copy link
Author

What do you mean by "different copy of artifacts"?

@MarcoRossignoli
Copy link
Collaborator

Build one time...move artifacts in different folders fold1/fold2/fold3 and run in parallel coverlet fold1... coverlet fold2... etc... to avoid concurrent file access on instrumentation.

@tkukushkin
Copy link
Author

OK, I understand, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for customer Waiting for customer action
Projects
None yet
Development

No branches or pull requests

2 participants