title: TFS build Run Functional Tests task: "DistributedTests: Test run '[run#]' is in 'InProgress' state."
body: <p>I working on a new non-XAML TFS build. My objective is to build the test project on our build agent VM, copy the test binaries to our test agent VM and execute our Selenium web UI tests from the test agent VM.</p>
  
  <p>My build definition process looks like this:</p>
  
  <ul>
  <li>Get Sources</li>
  <li>NuGet Installer</li>
  <li>MSBuild (builds test project)</li>
  <li>Windows Machine Copy (copies test project bin folder contents to test agent VM)</li>
  <li>Visual Studio Test Agent Deployment (deploy test agent to test agent VM)</li>
  <li>Run Functional Tests</li>
  </ul>
  
  <p>At this point, when I kick off a build, all steps as far as and including Visual Studio Test Agent Deployment are completing successfully. </p>
  
  <p>However, when the Run Functional tests task begins execution, we are seeing the following console output:</p>
  
  <blockquote>
    <p>Preparing task execution handler.</p>
    
    <p>Executing the powershell script:
    D:\tfsbuild-2_work_tasks\RunVisualStudioTestsusingTestAgent_d353d6a2-e361-4a8f-8d8c-123bebb71028\1.0.52\RunDistributedTests.ps1</p>
    
    <p>DistributedTests: Environment WinRm Protocol HTTP.</p>
    
    <p>DistributedTests: Creating run for selected test assemblies with
    following parameters</p>
    
    <p>DistributedTests: SourceFilter: ***Test*.dll TestCaseFilter: </p>
    
    <p>DistributedTests: Run title: [Run Title]</p>
    
    <p>DistributedTests: is automated: True</p>
    
    <p>DistributedTests: test settings id : [test settings id]</p>
    
    <p>DistributedTests: build location: [TestProjectLocation]</p>
    
    <p>DistributedTests: build id: [build id]</p>
    
    <p>DistributedTests: test configuration mapping: </p>
    
    <p>DistributedTests: Test Run with Id [run#] Queued</p>
    
    <p>DistributedTests: Test run '[run#]' is in 'InProgress' state</p>
  </blockquote>
  
  <p>The Run Functional Tests task continues to attempt execution until time-out, showing DistributedTests: Test run '[run#]' is in 'InProgress' state in the TFS console output.</p>
  
  <p>The DTAExecutionHost.exe log file shows the following entries for each corresponding console output:</p>
  
  <blockquote>
    <p>DTAExecutionHost.exe Information: 0 :
    TestExecutionServiceCommandQueueListener.DispatchAsync : Getting
    Command for Test Agent 19
        DateTime=2018-07-19T14:36:27.6387445Z</p>
    
    <p>Web method running: [<a href="https://.../test/Agents/19/Commands/0]" rel="nofollow noreferrer">https://.../test/Agents/19/Commands/0]</a>
    (GET)0[test]</p>
    
    <p>Web method response: [<a href="https://.../test/Agents/19/Commands/0]" rel="nofollow noreferrer">https://.../test/Agents/19/Commands/0]</a>
    (GET)0[test] 153 ms</p>
    
    <p>DTAExecutionHost.exe Information: 0 :
    TestExecutionServiceCommandQueueListener:DispatchAsync Command
    Microsoft.TeamFoundation.Test.WebApi.TestExecutionServiceCommand
    received.
        DateTime=2018-07-19T14:36:27.7794911Z</p>
    
    <p>DTAExecutionHost.exe Information: 0 :
    TestExecutionServiceCommandQueueListener.DispatchAsync :
    TestExecutionCommand received with None. Retrying it.
        DateTime=2018-07-19T14:36:27.7794911Z</p>
    
    <p>DTAExecutionHost.exe Information: 0 :
    TestExecutionServiceCommandQueueListener.DispatchAsync : Queue not
    found. Delaying for 50000 milliseconds.
        DateTime=2018-07-19T14:36:27.7794911Z</p>
  </blockquote>
  
  <p>In my Visual Studio Test Agent Deployment task, selected protocol is HTTP, the Run UI tests checkbox is ticked, Update test agent checkbox is unticked.</p>
  
  <p>During Visual Studio Test Agent Deployment task, blank DTAExecutionHost.exe console window opens on the test agent VM; this window remains open for the duration of the test run attempt.</p>
  
  <p>All tests in the project are discovered and execute as expected in Visual Studio on local machine.</p>
  
  <p>I have read a number of blogs, posts, discussion threads on this issue in recent days but have so far been unable to find a resolution to the problem. Please assist; any and all insights and suggestions welcome.</p>
  
  <p><strong>UPDATE: 21 August 2018</strong></p>
  
  <p>This issue persists. Answer provided below appeared to fix problem but issue returned, intermittently at first (I have had successful executions), now timing out on test execution step for every build.</p>
  
  <p>I've unmarked the answer below as correct.</p>