coverlet coverage report resulting in Microsoft.VisualStudio.Coverage.VanguardException - azure

I'm trying to integrate Cobertura report generation in my azure pipeline. For that I've added coverlet.collector 3.0.3 in my .Net core test projects. Below is my yaml command for test run
- task: DotNetCoreCLI#2
displayName: Test
inputs:
command: test
projects: '**/*Test/*.csproj'
arguments: '--collect:"XPlat Code Coverage" --settings CodeCoverage.runsettings --logger trx'
publishTestResults: false
I use Reportgenerator task, to merge & publish coverage reports. This all works fine in one branch of my code ( an old branch, on which I started setting up pipeline a while back ). But when I'm trying to point to latest branch in the pipeline, I get error as below
Data collector 'Code Coverage' message: Data collector caught an exception of type 'Microsoft.VisualStudio.Coverage.VanguardException': 'Running event not received from CodeCoverage.exe. Check eventlogs for failure reason
I've checked almost everything in two branches, Microsoft.Net.Test.SDK, coverlet.collector, both are of identical version. I'm not sure what is making difference between 2 branches and what differences I should be looking for between 2 code branches, that could lead to such issue.
Full log in case of success and failure is added below.
Success(when using old branch)
C:\windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
"C:\Program Files\dotnet\dotnet.exe" test I:\Agent-Win-R_work\489\s\XXXX.Business.Test\XXXX.Business.Test.csproj "--collect:XPlat Code Coverage" --settings CodeCoverage.runsettings --logger trx
Test run for I:\Agent-Win-R_work\489\s\XXXX.Business.Test\bin\Debug\netcoreapp3.1\XXXXWeb.Business.Test.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Microsoft (R) Coverage Collection Tool Version 16.0.30319.3002
Copyright (c) Microsoft Corporation. All rights reserved.
Results File: I:\Agent-Win-R_work\489\s\XXXX.Business.Test\TestResults\SVCGIDETFSProdBld01_MP-GIDE-522C_2021-07-01_04_18_04.trx
Attachments:
I:\Agent-Win-R_work\489\s\XXXX.Business.Test\TestResults\5f62864f-6c2c-4188-ac02-0dc536b464b3\coverage.cobertura.xml
I:\Agent-Win-R_work\489\s\XXXX.Business.Test\TestResults\5f62864f-6c2c-4188-ac02-0dc536b464b3\SVCGIDETFSProdBld01_MP-GIDE-522C_2021-07-01.04_17_58.coverage
Test Run Successful.
Total tests: 6
Passed: 6
Total time: 3.8813 Seconds
Failure(when pointing to new branch)
C:\windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
"C:\Program Files\dotnet\dotnet.exe" test I:\Agent-Win-R_work\489\s\XXXX.Test\XXXXBusiness.Test.csproj "--collect:XPlat Code Coverage" --settings CodeCoverage.runsettings --logger trx
Test run for I:\Agent-Win-R_work\489\s\XXXX.Business.Test\bin\Debug\netcoreapp3.1\XXXXWeb.Business.Test.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Data collector 'Code Coverage' message: Data collector caught an exception of type 'Microsoft.VisualStudio.Coverage.VanguardException': 'Running event not received from CodeCoverage.exe. Check eventlogs for failure reason.'. More details: ..
Results File: I:\Agent-Win-R_work\489\s\XXXX.Business.Test\TestResults\SVCGIDETFSProdBld01_MP-GIDE-522C_2021-07-01_04_12_42.trx
Attachments:
I:\Agent-Win-R_work\489\s\XXXX.Business.Test\TestResults\3839c24a-e17d-4d0d-9953-359388d5a940\coverage.cobertura.xml
Test Run Failed.
Total tests: 6
Passed: 6
I also came across this issue thread : https://github.com/microsoft/azure-pipelines-agent/issues/2839 where user suspected it to be an agent upgrade issue, but that does not seems to be the case for me, as I'm able to run it successfully for one branch of code.
Any suggestion or guidance is appreciated.

As I raised this question with Coverlet team, I got a quick response from them. They noticed something that I totally missed.
Microsoft (R) Coverage Collection Tool Version 16.0.30319.3002
This was coming in my success log, which meant that Microsoft code coverage was running in parallel with Coverlet code coverage. They suspected we can get some odd errors if you have two code coverage collectors running at the same time, and that some timing issue between how tests are run in the two branches leads to the different behavior.
As soon as I disabled Microsoft code coverage in my .runsettings file, the issue got resolved
Earlier:
<DataCollector friendlyName="XPlat code coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Now
<DataCollector friendlyName="XPlat code coverage">

Related

GenerateEFSQLScripts fails when trying to publish to IIS using Web Deploy from TeamCity

Running into a total dead-end here.
I've created a Publish Profile for a .net6 application that we want to publish to IIS with Web Deploy. In the Entity Framework Migration section, the option to "Apply this migration on publish" is selected.
When manually clicking publish, everything works. However, we want to automate this in TeamCity using the .NET build runner. The publish step fails at:
Generating Entity Framework SQL Scripts...
Executing command: dotnet ef migrations script --no-build --idempotent --configuration Release --output "C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api\obj\Release\net6.0\PubTmp\EFSQLScripts\MySolution.Data.MyContext.sql" --context MySolution.Data.MyContext
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(221,5): error : Entity Framework SQL Script generation failed
Internal error message details: BuildMessage1 0 Text DefaultMessage ERROR 400682522803500 tags:'tc:parseServiceMessagesInside'
Error message is logged
Build FAILED.
I cannot find any specific error messages anywhere in any log. Looking in the Microsoft.NET.Sdk.Publish.TransformFiles.targets file shows that it's failing on GenerateEFSQLScripts - an MSBuild command that executes dotnet ef under the covers.
I thought this might be a case of dotnet ef not being installed on the build agent. But when I manually run the command myself from C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api, it succeeds, and the SQL scripts are successfully created.
I also thought it might just be a case of the command being run in the wrong directory (i.e. in the root MySolution folder rather than the MySolution.Api folder), but explicitly setting the working directly fails at the same point, with the same error.
Has anyone seen this before? Or could point me to where an actual error might be located?

QA Pipeline Run failing in Azure

I'm using Testcomplete as my automation tool. Our pipeline is in Azure and its newly created for QA runs. The test VM was set up in VMSS in Azure. I'm using TestExecute as my test runner. Testexecute is already installed in the VM. When i run the pipeline, I'm getting an error which says
</RunSettings>
**************** Starting test execution *********************
C:\a\_tool\VsTest\17.4.0-preview-20220726-02\x64\tools\net462\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "#C:\a\_temp\4hdijfnknda.tmp"
Microsoft (R) Test Execution Command Line Tool Version 17.4.0-preview-20220726-02 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
vstest.console.exe "C:\a\1\s\GrizzlyMatters.pjs"
/Settings:"C:\a\_temp\ro5un5cn0ip.tmp.runsettings"
/Logger:"trx"
/TestAdapterPath:"C:\a\1\s\TestCompleteAdapter"
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
##[error]Failed to get a list of tests from the "C:\a\1\s\GrizzlyMatters.pjs" file due to the following error: Unable to connect to TestExecute: it is running with different rights, or its state is incorrect. Please close it and try again.
No test is available in C:\a\1\s\GrizzlyMatters.pjs. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: C:\a\_temp\TestResults\AzDevOps_vmliaqa000008_2022-09-01_14_51_35.trx
##[error]Test Run Failed.
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: C:\a\_temp\TestResults\AzDevOps_vmliaqa000008_2022-09-01_14_51_35.trx
No Result Found to Publish 'C:\a\_temp\TestResults\AzDevOps_vmliaqa000008_2022-09-01_14_51_35.trx'.
Created test run: 2724386
Publishing test results: 0
Publishing test results to test run '2724386'.
TestResults To Publish 0, Test run id:2724386
Published test results: 0
Publishing Attachments: 1
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.205.0\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: VsTest - testAssemblies
I've researched everything possible to get a solution. I'm not sure what I need to do. I'm attaching the screenshot of the pipeline config and the error.
Screenshots
Pipeline config 1:
Pipeline config 2:
Pipeline config 3:
Pipeline Run Error:

Azure pipeline - ERROR:gpu_process_transport_factory.cc(1029) Lost UI shared context

I have a pipeline on Azure that runs on a Windows 10 virtual machine that at some point calls a test task for an assembly (.dll) that tests functions for a Revit (3D modelling software) plugin.
In order to run the tests, the pipeline is simply running a command line task that starts RevitTestFramework, an open source application (https://github.com/DynamoDS/RevitTestFramework) used for this kind of testing.
Here are the relevant parts of my pipeline's yaml:
trigger:
- develop
pool: 'Default'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
# Some steps here
- task: CmdLine#2
inputs:
script: |
cd %ALLUSERSPROFILE%\RevitTestFramework\bin\AnyCPU\Debug
RevitTestFrameworkConsole.exe --dir %ALLUSERSPROFILE%\RevitTestFramework\bin\AnyCPU\Debug -a %ALLUSERSPROFILE%\RevitTestFramework\Tests\ModelEstablishment.IntegrationTests\bin\Debug\ModelEstablishment.IntegrationTests.dll -r %ALLUSERSPROFILE%\RevitTestFramework\Tests\results.xml -revit:"C:\Program Files\Autodesk\Revit 2020\Revit.exe" --continuous
Where %ALLUSERSPROFILE% is C:\ProgramData, but I also tried different folders (including C:) with the same result.
The very last line is the one that causes the issue. If it is a bit confusing, it is just summoning the program RevitTestFrameworkConsole.exe, which lives under the directory --dir and it has to test the assembly -a, spit out the results at -r, using the version of Revit specified at the path after -revit.
If I run this with my command line in Windows (not through the Azure pipeline) it runs perfectly:
But if it is Azure running it then it starts idling, repeating these lines until it cancels itself:
DevTools listening on ws://127.0.0.1:8088/devtools/browser/fa35cb10-8f4d-468f-9b0e-6457845ff8b2
Running C:\RevitTestFramework\bin\AnyCPU\Debug\RTF_Batch_Test.txt
[1202/180047.796:ERROR:gpu_process_transport_factory.cc(1029)] Lost UI shared context.
I've done my research but all I can find is that that error shouldn't be an actual error that breaks things and it usually happens when testing headless Chrome (which I'm far from doing).
Does anyone know what's going on here and how do I fix this?
UPDATE
By comparing the processes of manually running the command through the command line in the VM and what happens when Azure runs the same command, I've noticed that right after the line that says Running C:\ProgramData\RevitTestFramework\bin\AnyCPU\Debug\RTF_Batch_Test.txt (see screenshots) Revit is supposed to startup and run the tests. So I'm thinking that Azure's pipeline runs that command differently from what I do when I run the command on the same VM's command line.
Maybe this can help understanding the issue

Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName ''trx'

I'm having a issue with the Azure DevOps Pipeline Test Task, where I am trying to generate a .xml file from the Code Coverage Cobertura using the trx logger.
This is the following error that is generated: Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName ''trx'..
The command that I'm trying to run inside the Azure DevOps pipeline is (hiding project name for security reasons, replaced with: Mouse): "C:\Program Files\dotnet\dotnet.exe" test d:\a\1\s\src\Mouse.Tests\Mouse.Tests.csproj --logger 'trx;LogFileName=coverage.cobertura.xml' --results-directory d:\a\_temp /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura.
I'm consedering downloading the xUnit logger, as I made the tests in xUnit Framework.
However, I don't understand why this command does not work in Azure DevOps Pipeline...
YAML Section:
- task: DotNetCoreCLI#2
displayName: Run Tests
inputs:
command: custom
custom: test
arguments: $(Build.SourcesDirectory)\src\Mouse.Tests\Mouse.Tests.csproj --logger 'trx;LogFileName=coverage.cobertura.xml' --results-directory $(Agent.TempDirectory) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Raw Log File:
2020-01-29T18:26:25.2598092Z ##[section]Starting: Run Tests
2020-01-29T18:26:25.2731938Z ==============================================================================
2020-01-29T18:26:25.2731988Z Task : .NET Core
2020-01-29T18:26:25.2732016Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2020-01-29T18:26:25.2732058Z Version : 2.164.0
2020-01-29T18:26:25.2732104Z Author : Microsoft Corporation
2020-01-29T18:26:25.2732132Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2020-01-29T18:26:25.2732159Z ==============================================================================
2020-01-29T18:26:25.8444463Z [command]C:\windows\system32\chcp.com 65001
2020-01-29T18:26:25.8533851Z Active code page: 65001
2020-01-29T18:26:25.8670597Z [command]"C:\Program Files\dotnet\dotnet.exe" test d:\a\1\s\src\Mouse.Tests\Mouse.Tests.csproj --logger 'trx;LogFileName=coverage.cobertura.xml' --results-directory d:\a\_temp /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
2020-01-29T18:26:31.0179982Z
2020-01-29T18:26:31.1091798Z Welcome to .NET Core 3.1!
2020-01-29T18:26:31.1092168Z ---------------------
2020-01-29T18:26:31.1092336Z SDK Version: 3.1.101
2020-01-29T18:26:31.1092450Z
2020-01-29T18:26:31.1092645Z Telemetry
2020-01-29T18:26:31.1092791Z ---------
2020-01-29T18:26:31.1093287Z The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
2020-01-29T18:26:31.1093554Z
2020-01-29T18:26:31.1093755Z Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
2020-01-29T18:26:31.1093858Z
2020-01-29T18:26:31.1093970Z ----------------
2020-01-29T18:26:31.1094108Z Explore documentation: https://aka.ms/dotnet-docs
2020-01-29T18:26:31.1094382Z Report issues and find source on GitHub: https://github.com/dotnet/core
2020-01-29T18:26:31.1094484Z Find out what's new: https://aka.ms/dotnet-whats-new
2020-01-29T18:26:31.1094552Z Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
2020-01-29T18:26:31.1094584Z Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
2020-01-29T18:26:31.1095022Z Write your first app: https://aka.ms/first-net-core-app
2020-01-29T18:26:31.1095076Z --------------------------------------------------------------------------------------
2020-01-29T18:26:43.0935889Z Test run for d:\a\1\s\src\Mouse.Tests\bin\Debug\netcoreapp3.1\Mouse.Tests.dll(.NETCoreApp,Version=v3.1)
2020-01-29T18:26:43.4592444Z Microsoft (R) Test Execution Command Line Tool Version 16.3.0
2020-01-29T18:26:43.4592843Z Copyright (c) Microsoft Corporation. All rights reserved.
2020-01-29T18:26:43.4593019Z
2020-01-29T18:26:43.9392318Z Starting test execution, please wait...
2020-01-29T18:26:44.0028395Z Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName ''trx'.
2020-01-29T18:26:44.0527365Z ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
2020-01-29T18:26:44.0539503Z Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
2020-01-29T18:26:44.0539612Z Some commonly encountered changes are:
2020-01-29T18:26:44.0539670Z If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2020-01-29T18:26:44.0539944Z ##[error]Dotnet command failed with non-zero exit code on the following projects :
2020-01-29T18:26:44.0557864Z ##[section]Finishing: Run Tests

CruiseControl.net Project Fails with no errors, how to identify error?

Had cruise control.net (v1.8.5.0) up and running for about 6 months on 4 projects, no issues.
In the past week or so, one project reports a failure... even though it compiles correctly and no unit test errors are reported as they were previously on failures. None of similiar reports on SO or elsewhere describe or correct this problem.
Here is dashboard status:
BluePrint Failure Breakers : support2 Failing Tasks : NUnitTask
In the build report log where it would normally show which tests failed, it shows no failures just the unit startup message:
ProcessModel: Default DomainUsage: Single Execution
Runtime: net-3.5
Normally here for an nunit error the erroring test #s and names that failed and the nunit assert failure message. In a passing situation it would display xml for each test.
Can someone point me somewhere else what might be causing this or where else I might look to find out why?
When I run nunit manually on the same tests the cruise control service has checked out the build server, everything works fine.
I've tried restarting both the cruise control service and IIS, same result.
When I look in the ccnet.log file on the server, it doesn't report anything more specific than whats already in the build log above:
Done Building Project
"C:\Users\j\Documents\CIWork\BluePrint\BluePrint.sln" (Build
target(s)).
Build succeeded.
0 Error(s)
Time Elapsed 00:00:13.99
2017-01-20 18:50:36,869 [BluePrint:DEBUG] Running unit tests:
C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe
/xml=C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml
/nologo
C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe
2017-01-20 18:50:36,869 [BluePrint:DEBUG] Starting process [C:\Program
Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] in working directory
[C:\Program Files
(x86)\CruiseControl.NET\server\BluePrint\WorkingDirectory] with
arguments
[/xml=C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml
/nologo
C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe]
2017-01-20 18:50:36,953 [BluePrint:DEBUG] Not setting PriorityClass on
[C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] to default
Normal 2017-01-20 18:50:37,686 [20:DEBUG] [BluePrint C:\Program Files
(x86)\NUnit 2.6.3\bin\nunit-console.exe] ProcessModel: Default
DomainUsage: Single 2017-01-20 18:50:37,686 [20:DEBUG] [BluePrint
C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe] Execution
Runtime: net-3.5
My configuration has not changed in 6months, here's the relevant task from ccnet.config:
<nunit>
<path>C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe</path>
<outputfile>C:\Users\j\Documents\CIWork\BluePrint\logs\LatestTests.BluePrint.xml</outputfile>
<assemblies>
<assembly>C:\Users\j\Documents\CIWork\BluePrint\Tests\bin\x64\Release\TestBluePrint.exe</assembly>
</assemblies>
</nunit>
As I was posting this I recalled that one of these tests downloaded a fair amount of data from internet and cached it. Running it from the console worked, but running it from system account as service must've been slower to exceeded default cruisecontrol timeout.
Weird that no timeout error was in the log. However copying the cached files from the admin account to systemprofile account fixed it. Will also see if the nunit test can be modified to automatically time itself out.

Resources