-
Notifications
You must be signed in to change notification settings - Fork 390
Avoid double flush hit files for collectors #835
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
Avoid double flush hit files for collectors #835
Conversation
We're in the middle of repo move we don't have CI yet...I'd like to wait to merge. But if someone wants clone pack and test package could be great. |
Just built this locally and tried it out in dotnet/runtime and now I get IOExceptions constantly on every run:
|
Can you enable tracker logs it's not expected(if dll is used only by one session) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#enable-injected-tracker-log |
Ok the crashes don't repro for me anymore... Anyway here are the hitlogs: |
I need also the file near |
Sure: System.Text.RegularExpressions.dll_tracker.txt Actually the issue happened again for that run:
|
@ViktorHofer I cloned fresh repo of dotnet/runtime and ran
Updated |
These files are in the include directory which should be under artifacts/bin/testhost/net5.0.../shared/.../ |
Try add the env var here: https://github.com/dotnet/runtime/blob/5abde010ed0a53f196bba11cd18e839e9a0ce5fa/eng/testing/.runsettings#L21 and rebuild the test project. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@MarcoRossignoli wasn't the error before you re-run the actual error that you are trying to fix with this? |
Yes I have to investigate doesn't make sense, msbuild should not use that new flag, so I need to understand who is locking file and if we're locking ourselves |
@ViktorHofer maybe I found the issue, the fix on this PR should be ok, the problem is that in-process collectors is not inject by vstest you can show that using <RunSettings>
<RunConfiguration>
<ResultsDirectory>C:\\git\\coverlet\\Documentation\\Examples\\VSTest\\HelloWorld\\XUnitTestProject1\\TestResults</ResultsDirectory>
<TargetPlatform>X64</TargetPlatform>
<TargetFrameworkVersion>.NETCoreApp,Version=v3.1</TargetFrameworkVersion>
<TestAdaptersPaths>C:\\Users\\Marco\\.nuget\\packages\\coverlet.collector\\1.2.1\\build\\netstandard1.0\\</TestAdaptersPaths>
<DesignMode>False</DesignMode>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage" enabled="True" />
</DataCollectors>
</DataCollectionRunSettings>
<InProcDataCollectionRunSettings>
<InProcDataCollectors>
<InProcDataCollector assemblyQualifiedName="Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
friendlyName="XPlat Code Coverage"
enabled="True"
codebase="C:\\Users\\Marco\\.nuget\\packages\\coverlet.collector\\1.2.1\\build\\netstandard1.0\\coverlet.collector.dll" />
</InProcDataCollectors>
</InProcDataCollectionRunSettings>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="Console" uri="logger://microsoft/TestPlatform/ConsoleLogger/v1" assemblyQualifiedName="Microsoft.VisualStudio.TestPlatform.CommandLine.Internal.ConsoleLogger, vstest.console, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" codeBase="C:\\Program Files\\dotnet\\sdk\\3.1.201\\vstest.console.dll" enabled="True" />
</Loggers>
</LoggerRunSettings>
</RunSettings> In case of core runtime test <RunSettings>
<RunConfiguration>
<TestSessionTimeout>300000</TestSessionTimeout>
<ResultsDirectory>C:\\git\\runtime\\artifacts\\bin\\System.Text.RegularExpressions.Tests\\net5.0-Debug\\TestResults\\</ResultsDirectory>
<SolutionDirectory>.\\</SolutionDirectory>
<MaxCpuCount>0</MaxCpuCount>
<TargetPlatform>X64</TargetPlatform>
<DisableParallelization>false</DisableParallelization>
<DisableAppDomain>false</DisableAppDomain>
<TestCaseFilter>category!=OuterLoop&category!=failing</TestCaseFilter>
<DotNetHostPath>C:\\git\\runtime\\artifacts\\bin\\testhost\\net5.0-Windows_NT-Debug-x64\\dotnet.exe</DotNetHostPath>
<EnvironmentVariables>
<DEVPATH>C:\\git\\runtime\\artifacts\\bin\\testhost\\net5.0-Windows_NT-Debug-x64\\</DEVPATH>
</EnvironmentVariables>
<TargetFrameworkVersion>.NETCoreApp,Version=v5.0</TargetFrameworkVersion>
<InIsolation>true</InIsolation>
<TestAdaptersPaths>C:\\Users\\Marco\\.nuget\\packages\\coverlet.collector\\1.3.0-preview.16.g6316f5fc24\\build\\netstandard1.0\\;C:\\Users\\Marco\\.nuget\\packages\\microsoft.codecoverage\\16.5.0\\build\\netstandard1.0\\</TestAdaptersPaths>
<DesignMode>False</DesignMode>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="trx" enabled="True" />
<Logger friendlyName="html" enabled="True" />
<Logger friendlyName="console" assemblyQualifiedName="Microsoft.VisualStudio.TestPlatform.CommandLine.Internal.ConsoleLogger, vstest.console, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" codeBase="C:\\git\\runtime\\.dotnet\\sdk\\5.0.100-preview.5.20228.8\\vstest.console.dll" enabled="True">
<Configuration>
<Verbosity>Minimal</Verbosity>
</Configuration>
</Logger>
</Loggers>
</LoggerRunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage" enabled="true">
<Configuration>
<Include>[System.Text.RegularExpressions]*</Include>
<ExcludeByFile>C:\\git\\runtime\\src\\libraries\\Common\\src\\System\\SR.*,C:\\git\\runtime\\src\\libraries\\Common\\src\\System\\NotImplemented.cs</ExcludeByFile>
<IncludeDirectory>C:\\git\\runtime\\artifacts\\bin\\testhost\\net5.0-Windows_NT-Debug-x64\\shared\\Microsoft.NETCore.App\\5.0.0</IncludeDirectory>
<Format>opencover</Format>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>
<IncludeTestAssembly>false</IncludeTestAssembly>
</Configuration>
</DataCollector>
<DataCollector friendlyName="blame" enabled="true" />
</DataCollectors>
</DataCollectionRunSettings>
<RunSettingsDirectory>C:\\git\\runtime\\artifacts\\bin\\System.Text.RegularExpressions.Tests\\net5.0-Debug</RunSettingsDirectory>
</RunSettings> Can you tell which version of |
@ViktorHofer some step forward with this branch version and this command seems work, trying to understand what inside runsettings break in-proc collector injection.
reports seem stable but not perfect there are 2 seq point difference sometimes, I don't know why at the moment(I'm again on in-proc collector issue), could be related to some "non deterministic" path test? <Summary numSequencePoints="10603" visitedSequencePoints="10304" numBranchPoints="5022" visitedBranchPoints="4685" sequenceCoverage="97.18" branchCoverage="93.28" maxCyclomaticComplexity="5519" minCyclomaticComplexity="5519" visitedClasses="55" numClasses="55" visitedMethods="810" numMethods="820" />
<Summary numSequencePoints="10603" visitedSequencePoints="10306" numBranchPoints="5022" visitedBranchPoints="4686" sequenceCoverage="97.19" branchCoverage="93.3" maxCyclomaticComplexity="5519" minCyclomaticComplexity="5519" visitedClasses="55" numClasses="55" visitedMethods="810" numMethods="820" />
<Summary numSequencePoints="10603" visitedSequencePoints="10306" numBranchPoints="5022" visitedBranchPoints="4686" sequenceCoverage="97.19" branchCoverage="93.3" maxCyclomaticComplexity="5519" minCyclomaticComplexity="5519" visitedClasses="55" numClasses="55" visitedMethods="810" numMethods="820" />
<Summary numSequencePoints="10603" visitedSequencePoints="10304" numBranchPoints="5022" visitedBranchPoints="4685" sequenceCoverage="97.18" branchCoverage="93.28" maxCyclomaticComplexity="5519" minCyclomaticComplexity="5519" visitedClasses="55" numClasses="55" visitedMethods="810" numMethods="820" /> |
Fixes #736
When collectors was created we didn't take into account the ProcessExit callback. So sometime happens that in proc collector flush and meanwhile out of proc one try to load hits file when process exits of host process re-flush the file and so invalid concurrent access.
This PR add a boolean field called
FlushHitFile
defaulttrue
that will be set to false after in process collector flush. This new field is used insideUnloadModule
, in case of collectors usage we won't have double flush due to process exits callback.In my local test with tracking log enabled works as expected
Log before
DummyApp.dll_tracker_flushOnProcessExits.txt
Log after
DummyApp.dll_tracker_newVersion.txt
This is also compatible with netfx app domains, btw at the moment collectors does not support netfx.
cc: @ViktorHofer @abe545 @tonerdo