question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`dotnet test` hangs when running integration tests with `UseWebpackDevMiddleware` in Azure DevOps

See original GitHub issue

Description

Running the dotnet test task in Azure DevOps Pipelines on a test assembly that is running integration tests (via Microsoft.AspNetCore.Mvc.Testing) while also using UseWebpackDevMiddleware causes the test run to hang forever.

To Reproduce

  1. Create a new ASP.NET Core SPA website (which uses UseWebpackDevMiddleware)
  2. Create a unit test project that uses Microsoft.AspNetCore.Mvc.Testing to execute an integration test
  3. Create an Azure DevOps Pipeline that builds and runs tests via dotnet build and dotnet test (I am using the Visual Studio 2019 on Windows 2019 build agent)
  4. Run the pipeline and notice that when it gets to dotnet test, the test run hangs after logging the following:
Starting test execution, please wait...
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {5653a870-1f93-4b30-b7d2-29fd94a34191} with creation date 2019-05-23 17:34:18Z, activation date 2019-05-23 17:34:18Z, and expiration date 2019-08-21 17:34:18Z.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {02253cc1-903b-43b6-909a-61faccc67c88} with creation date 2019-05-23 17:34:18Z, activation date 2019-05-23 17:34:18Z, and expiration date 2019-08-21 17:34:18Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\key-5653a870-1f93-4b30-b7d2-29fd94a34191.xml'.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\key-02253cc1-903b-43b6-909a-61faccc67c88.xml'.

Expected behavior

The test run should not hang due to the use of UseWebpackDevMiddleware.

Additional context

  • I am using Azure DevOps Pipeline
  • I am using version 2.2.300 of the dotnet SDK
  • All of my packages are up to date (with no prerelease packages being used)
  • The test run executes fine via Visual Studio and CLI locally
  • I have tried using an agent hosted on a VM and the issue still occurs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SidShetyecommented, Aug 28, 2019

Another issue is using code like

result = SomeAsyncMethodAsync(arg).Result;

in your test code. It basically comes from blocking in a multi-threaded scenario. Switching to the proper multi-threaded async/await pattern like

result = await SomeAsyncMethodAsync(arg);

gets things working again. Probably also why @axthosarouris 's work-around works, since it effectively disables multi-threading, masking this test code design problem.

Discovered this is older tests written back when async/await was new …

1reaction
ChristopherHawscommented, Aug 27, 2019

We ended up switching to UseReactDevelopmentServer since UserWebpackDevMiddleware is being deprecated. The issue does not happen with UseReactDevelopmentServer. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Howto resolve .net test hangs on "Starting test execution ...
I am trying to execute dotnet test from the command line on our Jenkins build server, but it just hangs on: Starting test...
Read more >
Tracking down a hanging xUnit test in CI: building a custom ...
In this post I describe how we tracked down a hanging xUnit test by building a custom XuniTestFramework implementation.
Read more >
UI test run hanging after results publish. : r/azuredevops
Azure Hosted agent just hangs at this step, had worked previously for ... any tests that interact with dcom components or that run...
Read more >
Test published output with dotnet vstest - .NET
You can run tests on already published output by using the dotnet vstest command. This will work on xUnit, MSTest, and NUnit tests....
Read more >
Untitled
`dotnet test` hangs when running integration tests with ... - GitHub Running Jest tests in a Docker container in an Azure Devops pipeline...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found