-
Notifications
You must be signed in to change notification settings - Fork 388
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
Test's not working when using Coverlet Collector #1246
Comments
Seems to be the same issue as #1044 |
@daveMueller Thanks, I had a look at #1044 I don't think it's the same issue. we don't have any I/O in our projects under test. I'll take a copy of the source code and see if I can find where it's getting stuck over the weekend |
@kastroph one question, in your output above I see the table that we emit with msbuild integration and not with collectors and the instrumentation engine is the same so it's not clear to me why should work with msbuild and not with collectors, can you provide your full command line? LOGS/DUMP CONTAINS SENSITIVE INFORMATIONS LIKE KEYS ETC...SO DON'T ATTACH HERE. You can open dump with Visual Studio and log with notepad. If you're not able to find out where code hangs(you should see it in stacks) I can help but we need to find a way to share dump/logs and you have to trust me, in that case we can sync offline, DM me here https://twitter.com/MarcoRossignoli if needed. |
@MarcoRossignoli Thank you for showing an interest in my issue it is appreciated. I have attached log.txt file from: dotnet test --collect:"XPlat Code Coverage" --diag:log.txt. I have parsed out any identifying information. dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura works fine and outputs: Sorry I don't have a Twitter account :( |
@kastroph you should get 3 log files, one for main test driver one for host and one for data collector (where coverlet resides) I see only one file attached, is it the only file generated? We can use gitter. |
@MarcoRossignoli That's my bad! I have attached the missing file |
Not needed...looks like it hangs on collector during report generation...but from logs isn't possible understand where it stucks we need to get a dump. In log.datacollector.21-11-06_13-48-31_56943_5.txt after hit file deletion(second to last line) we expect generation of file but it stucks until parent process exits(I think when you stop with ctrl+c on console). You should run the test and when it hangs(some seconds) you should find a process called datacollector.exe as child of dotnet.exe that is the process for which to take the dump. After you should open in VS and take a look at stacks. A normal log should be something like
in your case
|
@MarcoRossignoli hmmmm I'm not finding a process for DataCollector. exe From the log, I think it must be throwing an exception then closing the PID |
Sry my fault you're using
|
@MarcoRossignoli The test host starts up then exits very quickly I took a dump file but it's only windows stuff in it |
you don't have to take the dump of testhost but of datacollector is another process, if you run in console and wait for hang you'll find the process there and you can take the dump because will be alive. vstest.console process(main driver) |
@MarcoRossignoli can you send a screenshot of what I should be looking for? I'm struggling to find it in Process Explorer |
Steps:
Wait for some seconds/minutes it should hang with console message above
This should bring you to the parent process(terminal) with some
That is the process for what to take the dump. Anyway if it's hanging it means that on of the dotnet.exe process under terminal is blocking and so you should be able to find the last one that is blocking the chain. If normal case all dotnet.exe processes will die after test ends. |
@MarcoRossignoli I have the process tree I'm a bit confused by step 3 sorry |
Double click on Right click on process(menu) -> Create Dump -> Create full dump |
Also that 6GB mem consumptions looks suspicious |
@MarcoRossignoli oh got this out of the console
|
You should remove the blame argument...blame collector took dump of test host but looks like your problem is on collector and not into test host(so after hang timeout fires blame collector tries to dump testhost but it's gone and will fail). So run the command line without --blame and took the dump manually for the last dotnet process in the chain that contains datacollector.dll |
It's probably from the sins of the project. I can make it use 40Gb if I try. The team I have taken over has poor knowledge of SOLID and best practices. I'm hoping to use Coverlet to encourage testing. Okay I think I have the dump |
Is there a way I can debug the collector in my test project? I think it's probably the only way we will get to the bottom of it. I'm not that familiar with the architecture. I suspect I'll need to see the stack trace of test runner |
'dotnet.exe' (Win32): Loaded 'C:\Program Files\dotnet\dotnet.exe'. |
Are you opening with Visual Studio? You should be able to see the threads/stacks and where are stuck, usually in hanging situation there is few(one?) actively running that is looping(if cpu is constantly above 0%) or waiting something(cpu is constantly close to 0%). if you set set COVERLET_DATACOLLECTOR_OUTOFPROC_DEBUG=1 and re-run the |
If you want to share dump with me we can talk on gitter and you can send me on onedrive authenticated link https://gitter.im/ clearly only in case you need it. |
Discussed off-line and after dump analysis looks like it's a perf issue, coverlet is stuck inside CalculateCoverage part coverlet/src/coverlet.core/Coverage.cs Line 392 in 32c57d6
Looks like the instrumented assembly is very big, first time that we have a perf issue during coverage calculation. Anyway we can improve here with a better data structure, dictionary or binary search. |
@MarcoRossignoli Thank you so much for your support today <3 I excluded the project that I thought would be a problem for performance. If you would like a one to one codeshare session I'm happy to authorise it to improve Coverlet |
Glad to see that we found the culprit! Thanks a lot for all the informations. |
Solution 1.81 GB |
Ok let me know if you're able to run it on your local to understand how many time is need. |
Excluding the web project Test Run Successful. only 2 seconds slower than just running the tests in the command line |
Ok let's try with the web project if possible. Only to understand if it's possible set a meaningful timeout on CI and on test platform(maybe it will timeout after a while I need to check). |
The web project is full of static references tends of thousands. If you build on an Intel i5 the build time is 30 minutes |
Ok got it...so it's definitely an edge case...looks like the perf issue is also on build. |
I definitely would not lose sleep over it unless you want a huge challenge. Software should not be designed this was in 2021! I'm migrating the code to Clean Acrutature so everything should have its own service class exposed by an interface. Done 5k lines 95k more to go |
Hi,
I'm trying to use the coverlet collector and it does not exit the tests. I have 85 tests that take about 35 seconds to run. But when I run
dotnet test --collect:"XPlat Code Coverage"
it runs forever I have to manually close the process. Coverlet is working fine.The project is in dot net 5.0.
Coverlet output
Calculating coverage result...
Generating report 'ERP.Service.xUnit.Test\coverage.json'
+-------------------------------+--------+--------+--------+
| Module | Line | Branch | Method |
+-------------------------------+--------+--------+--------+
| ERP.Core | 38.81% | 3.19% | 19.8% |
+-------------------------------+--------+--------+--------+
| ERP.Infrastructure | 0% | 0% | 0% |
+-------------------------------+--------+--------+--------+
| ERP.Repositories | 20.28% | 24.1% | 34.23% |
+-------------------------------+--------+--------+--------+
| ERP.Services | 38.02% | 23.25% | 32.46% |
+-----------------------------+--------+--------+--------+
| ERP.Services.xUnit.Test | 99.82% | 90.62% | 99% |
+-------------------------------+--------+--------+--------+
+---------+--------+--------+--------+
| | Line | Branch | Method |
+---------+--------+--------+--------+
| Total | 0.1% | 20.65% | 19.06% |
+---------+--------+--------+--------+
| Average | 39.38% | 28.23% | 37.09% |
+---------+--------+--------+--------+
Output for dotnet test --collect:"XPlat Code Coverage"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
The text was updated successfully, but these errors were encountered: