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

Azure Pipelines测试故障求助:Hosted Agent失联+Surefire报告未同步

Azure Pipelines测试执行问题排查方案

问题1:Agent失联提示 "We stopped hearing from agent Hosted Agent. Verify the agent machine is running and has a healthy network connection"

  • 检查Azure VM状态:确认VM处于运行状态,查看监控指标(CPU、内存、磁盘占用),排查是否因资源耗尽导致Agent进程崩溃。
  • 验证网络连通性:在VM内测试与Azure DevOps服务的连接,执行Invoke-WebRequest https://dev.azure.com(Windows)或curl https://dev.azure.com(Linux),确认无防火墙/NSG规则阻断443端口流量。
  • 重启Agent服务:远程登录VM后,找到Azure Pipelines Agent安装目录,执行./run.sh restart(Linux)或通过服务管理器重启vstsagent相关服务(Windows)。
  • 更新Agent版本:如果Agent版本过旧,下载最新稳定版Agent重新部署,确保与Azure DevOps平台版本兼容。

问题2:Surefire报告未同步到Dropbox,AcceptanceSuite1执行报错

1. 确认报告是否生成

  • 登录Azure VM,检查项目根目录下的target/surefire-reports文件夹,确认是否存在报告文件。若为空,执行mvn clean test -P acceptanceSuitePartA手动触发测试,查看控制台输出的错误信息。
  • 检查AcceptanceSuite1.xml的TestNG配置,确保未添加禁用报告生成的参数(如disableReport="true")。

2. 排查Dropbox同步问题

  • 确认VM上的Dropbox客户端正常运行,同步文件夹路径是否正确指向报告生成目录。查看Dropbox同步日志,排查是否存在权限不足、文件锁定或同步队列阻塞的情况。
  • 检查测试脚本中复制报告到Dropbox的逻辑,确认最新代码提交后未修改同步路径或删除该逻辑。

3. 修复Maven配置问题

  • 统一Surefire插件版本:pom.xml中Surefire插件版本混用3.0.0-M5和3.0.0-M2,建议统一升级至稳定版(如3.2.5),避免版本兼容问题:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.2.5</version>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>AcceptanceSuite1.xml</suiteXmlFile>
            </suiteXmlFiles>
        </configuration>
    </plugin>
    
  • 升级TestNG依赖:当前TestNG 6.14.3与新版Surefire可能存在适配问题,建议升级到7.x稳定版(如7.8.0):
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.8.0</version>
        <scope>compile</scope>
    </dependency>
    
  • 移除不必要依赖:AppleJavaExtensions仅适用于MacOS环境,Windows VM上可移除该依赖,避免加载异常:
    <!-- 移除以下依赖 -->
    <dependency>
        <groupId>com.apple</groupId>
        <artifactId>AppleJavaExtensions</artifactId>
        <version>1.4</version>
    </dependency>
    
  • 执行mvn clean test -P acceptanceSuitePartA -X开启DEBUG日志,详细排查测试执行过程中的依赖加载或代码异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 19:10:48