This is a migrated thread and some comments may be shown as answers.

The agent process was stopped while the test was running

3 Answers 312 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pavel
Top achievements
Rank 1
Pavel asked on 25 Aug 2014, 04:25 AM
Hello,

We experience random test failures while running Silverlight tests based on Telerik Test Studio. While the tests pass, just after a test finishes it receives an error saying 'The agent process was stopped while the test was running'. Most of the time tests pass, but about 5% of them fail with this error.

We are running tests via MSTest 2012 from a TeamCity build step. The test studio version is 2012.2, the machine is running Windows 8.1 x64

The following error occurs immediately in the Event Log:​

Log Name:      Application
Source:        .NET Runtime
Date:          8/22/2014 12:58:53 PM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      X
Description:
Application: QTAgent32_40.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Threading.ThreadAbortException
Stack:
   at MS.Internal.Automation.WinEventWrap.WinEventReentrancyFilter(Int32, Int32, IntPtr, Int32, Int32, Int32, UInt32)
   at MS.Win32.UnsafeNativeMethods.PeekMessage(MSG ByRef, HWND, Int32, Int32, Int32)
   at MS.Internal.Automation.QueueProcessor.WaitForWork()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

I tried debugging remotely and attaching VS to QTAgent32_40 process. When the exception occurs, the thread it occurs on is named 'MS UI Automation event queue processor.' Besides, there is always another thread named like 'Agent: adapter run thread for test 'X'...' with the following call stack:
  mscorlib.dll!System.AppDomain.Unload(System.AppDomain domain)
  ArtOfTest.WebAii.Design.dll!ArtOfTest.WebAii.Design.Execution.TestAppLoader.Dispose()
  ArtOfTest.WebAii.Design.dll!ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteTest(ArtOfTest.WebAii.Design.Execution.ExecuteTestCommand command)
  ArtOfTest.WebAiiVSIP.dll!ArtOfTest.WebAiiVSIP.WebAiiTestAdapter.Run(Microsoft.VisualStudio.TestTools.Common.ITestElement testElement, Microsoft.VisualStudio.TestTools.Execution.ITestContext testContext)
  Microsoft.VisualStudio.QualityTools.AgentObject.dll!Microsoft.VisualStudio.TestTools.Agent.AgentExecution.CallAdapterRunMethod(object obj)
  mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)
  mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
  mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj)

So it looks like if a test finishes in a bad moment, its attempt to unload app domain leads to async thread abort on UI Automation Client thread. It is not handled, so it causes process termination. (See for example http://stackoverflow.com/questions/9416078/how-to-handle-appdomain-unload-and-the-related-threadabortexception)

Is there anything that can be done to mitigate the issue? Or do I need to file a bug via our license holder? This error makes our automated UI tests unstable and unusable.

3 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 28 Aug 2014, 06:48 AM
Hello Pavel,

I can see here the failing application is QTAgent32.exe and we are not in control of the application in question. You can check over the Internet on how to handle this issue.

I have did some checks and here is a good article you can use as a starting point.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Pavel
Top achievements
Rank 1
answered on 28 Aug 2014, 10:09 AM
Hello Ivaylo,

Are you saying you do not support running your tests from MSTest as explained in the product documentation? Because QTAgent is the process that MSTest runs tests in. If you do support this feature, you cannot deny your responsibility because the process runs only the MSTest shell and the test code that is completely generated by your product. And it fails.

Thank you for your links, but I am already well aware of why such events occur. Moreover, I gave you the details of what happens in our case, where the unhandled exception occurs, and the call that most likely causes the error. The latter one is inside your code, ArtOfTest.WebAii.Design.Execution.TestAppLoader.Dispose() method.

Will Telerik provide support on this issue? What can I do to assist?
0
Ivaylo
Telerik team
answered on 01 Sep 2014, 12:46 PM
Hello Pavel,

We integrate with MSTest so our tests can be executed with MSTest but since the crashing application is QTAgent.exe which is a part of the MSTest we do not have control over. MSTest is a command line utility that Microsoft provides, that is why it is beyond our scope of expertise. 

The only way we can proceed will be if we can replicate the crash on our end and investigate whether or not this is Test Studio related issue.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Pavel
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Pavel
Top achievements
Rank 1
Share this question
or