You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

构建服务器上单元测试突发无变更失败问题求助

CI持续集成单元测试突发失败排查方案

错误信息

未处理的异常: System.AggregateException: 发生一个或多个错误。 ---> Microsoft.VisualStudio.TestPlatform.Common.TestRunner.ProcessExitedException: 执行器进程已退出。 ---> System.ServiceModel.CommunicationException: 读取管道时出错: 无法识别的错误 109 (0x6d)。 ---> System.IO.PipeException: 读取管道时出错: 无法识别的错误 109 (0x6d)。
   在 System.ServiceModel.Channels.PipeConnection.FinishSyncRead(Boolean traceExceptionsAsErrors)
   在 System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
--- 内部异常堆栈跟踪结束 ---

服务器堆栈跟踪:
   在 System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   在 System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   在 System.ServiceModel.Channels.ConnectionUpgradeHelper.InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, IConnection& connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, TimeoutHelper& timeoutHelper)
   在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   在 System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   在 System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

异常在[0]处重新抛出:
   在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   在 Microsoft.VisualStudio.TestPlatform.Core.ITestExecutorService.InitializeConnection(IEnumerable`1 pathToAdditionalExtensions, Boolean loadOnlyWellKnownExtensions)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceProxy.InitializeConnection(IEnumerable`1 pathToAdditionalExtensions, Boolean loadOnlyWellKnownExtensions)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.TestConnection(Binding binding, EndpointAddress address, ITestExecutorServiceProxy& proxy)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.InitializeProxy(String namedPipeIdentifierToken)
--- 内部异常堆栈跟踪结束 ---
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.CheckExecutorProcessExited(Exception ex)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.InitializeProxy(String namedPipeIdentifierToken)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.Initialize_NoLock(Architecture targetPlatform, FrameworkVersion targetFramework)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.EnsureInitialized(IDictionary`2 environmentVariables, TestExecutionContext context)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.<>c__DisplayClass18_0.<StartTestRun>b__0()
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.InvokeTestExecutorServiceAction(Action action)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestExecutorServiceClient.StartTestRun(IEnumerable`1 sources, TestExecutionContext executionContext, String runSettings, IDictionary`2 environmentVariables, String dataCollectionServiceUri, ITestCaseLog testCaseLog, ITestRunLog testRunLog, IFrameworkHandleInternal frameworkHandle)
   在 Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.ParallelTestExecutorServiceClient.TriggerExecutionForNextSource(ITestExecutorServiceClient executorServiceClient)
   在 Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.ParallelTestExecutorServiceClient.<StartTestRunPrivate>b__23_0()
   在 System.Threading.Tasks.Task`1.InnerInvoke()
   在 System.Threading.Tasks.Task.Execute()
--- 内部异常堆栈跟踪结束 ---
   在 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   在 System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   在 Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.ParallelTestExecutorServiceClient.StartTestRunPrivate(TestExecutionContext executionContext, String runSettings, IDictionary`2 environmentVariables, String dataCollectionServiceUri, ITestCaseLog testCaseLog, ITestRunLog testRunLog, IFrameworkHandleInternal frameworkHandle)
   在 Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.ParallelTestExecutorServiceClient.StartTestRun(IEnumerable`1 sources, TestExecutionContext executionContext, String runSettings, IDictionary`2 environmentVariables, String dataCollectionServiceUri, ITestCaseLog testCaseLog, ITestRunLog testRunLog, IFrameworkHandleInternal frameworkHandle)
   在 Microsoft.VisualStudio.TestPlatform.Client.Rocksteady.RocksteadyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, Boolean inIsolation, DataCollectionParameters dataCollectionParameters, ITestRunEventsHandler runEventsHandler)
   在 Microsoft.VisualStudio.TestPlatform.Client.TestRunRequest.ExecuteAsync()
   在 Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor.RunTests(IEnumerable`1 sources, String packageFullName, String deviceInfo, Boolean isPhoneAppx, Boolean isUniversalTestAppx)
   在 Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentProcessor.Execute()
   在 Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args)
   在 RockSteady.Program.Main(String[] args)

排查与解决步骤

  • 重启构建服务器代理/服务:错误109(0x6d)对应管道连接重置,大概率是测试平台服务进程异常挂起,重启CI代理或服务器上的测试相关服务,释放占用的管道资源。
  • 禁用测试并行执行:从堆栈可见异常来自并行测试执行器,可通过以下方式禁用并行:
    • 命令行添加参数:vstest.console.exe /Parallelize:false
    • 修改runsettings配置文件:
      <RunSettings>
        <RunConfiguration>
          <MaxCpuCount>1</MaxCpuCount>
        </RunConfiguration>
      </RunSettings>
      
  • 清理构建工作区:构建服务器的测试工作目录可能残留锁定文件或旧二进制文件,每次构建前强制清理工作区,删除临时文件和测试输出目录。
  • 检查服务器资源状态:查看构建服务器的CPU、内存、磁盘空间,资源耗尽会导致测试执行器进程意外退出,需释放资源或扩容服务器。
  • 更新Visual Studio Test Platform版本:旧版本测试平台存在管道通信已知bug,更新到最新稳定版可修复该类问题。
  • 禁用测试隔离模式:尝试添加命令行参数/InIsolation:false,避免隔离进程间的管道通信异常。

内容的提问来源于stack exchange,提问作者Laxminarayan Ratti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 04:51:12