`ActiveSessionException` in TestNG integration suggests conflict with parallel execution

未关闭
#305 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
testing-qa

调研方向

从 com.appland.appmap.process.hooks.test.TestNG.testng 和堆栈跟踪中显示的 Recorder.start 路径开始,然后检查 RecordingSupport.startRecording 和 TestSupport.startRecording。使用 TestNG parallel="methods" 或 parallel="tests" 重现故障,并确定是否可以按线程隔离会话,或者必须禁用并行。完成的标准是并行执行不再导致 ActiveSessionException,并且记录仍能完成。

由索引模型根据 Issue 内容生成。

描述

A user running TestNG tests with the appmap-java agent is encountering an ActiveSessionException, which causes the recording to fail. We suspect this is due to TestNG's parallel execution feature, which the AppMap agent's Recorder may not currently support.

When multiple tests run concurrently, each test thread appears to trigger the AppMap TestNG hook (com.appland.appmap.process.hooks.test.TestNG.testng) and attempts to call startRecording. The first test succeeds, but subsequent concurrent tests fail when the Recorder detects that a session is already active, throwing the exception.

Error Log & Stack Trace

The key error message from the user's log is:

AppMap agent version 1.28.0 starting
[TestNG] Running:
  <path-to-project>\src\test\resources\testsuite\testing.xml
...
17:08:07.398 [main] WARN RecordingSupport.startRecording: com.appland.appmap.record.ActiveSessionException: an active recording session already exists
    at com.appland.appmap.record.Recorder$ActiveSession.set(Recorder.java:162)
    at com.appland.appmap.record.Recorder.start(Recorder.java:241)
    at com.appland.appmap.process.hooks.RecordingSupport.startRecording(RecordingSupport.java:59)
    at com.appland.appmap.process.hooks.test.TestSupport.startRecording(TestSupport.java:63)
    at com.appland.appmap.process.hooks.test.TestSupport.startRecording(TestSupport.java:25)
    at com.appland.appmap.process.hooks.test.TestNG.testng(TestNG.java:45)
Requested Action
  1. Investigate: Please confirm if appmap-java's TestNG support is compatible with parallel test execution (e.g., parallel="methods" or parallel="tests" in the testng.xml suite).
  2. Remediate:
    • Ideally: If possible, update the agent to properly support parallel TestNG execution, perhaps by managing recording sessions on a per-thread basis.
    • Alternatively: If parallel support is not feasible or as an interim solution, please add logic to detect when TestNG parallelism is enabled and automatically disable it (force serial execution) when the AppMap agent is attached. This would prevent the crash and allow users to generate AppMaps, albeit with a slower test run.
Full Terminal Output (for context)
"<path-to-java>\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 -Dappmap.config.file=<path-to-project>\appmap.yml -javaagent:<user-home>\.appmap\lib\java\appmap.jar "-javaagent:<path-to-ide>\lib\idea_rt.jar=56911" -javaagent:<user-home>\AppData\Local\JetBrains\IdeaIC\captureAgent\debugger-agent.jar -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Ddebugger.agent.enable.coroutines=true
 -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -Dfile.encoding=UTF-8 @<temp-path>\idea_arg_file1573352798 com.intellij.rt.testng.RemoteTestNGStarter -usedefaultlisteners
 false -socket56910 @w@<temp-path>\idea_working_dirs_testng2.tmp -temp <temp-path>\idea_testng2.tmp

AppMap agent version 1.28.0 starting

[TestNG] Running:

  <path-to-project>\src\test\resources\testsuite\testing.xml
Java HotSpot(TM) 64-Bit Server VM warning: Sharing 
is only supported for boot loader classes because bootstrap classpath 
has been appended

SLF4J(W): No SLF4J providers were found.
.. 
17:08:07.398 [main] WARN RecordingSupport.startRecording: com.appland.appmap.record.ActiveSessionException: an active recording session already exists

    at com.appland.appmap.record.Recorder$ActiveSession.set(Recorder.java:162)

    at com.appland.appmap.record.Recorder.start(Recorder.java:241)

    at com.appland.appmap.process.hooks.RecordingSupport.startRecording(RecordingSupport.java:59)

    at com.appland.appmap.process.hooks.test.TestSupport.startRecording(TestSupport.java:63)

    at com.appland.appmap.process.hooks.test.TestSupport.startRecording(TestSupport.java:25)

    at com.appland.appmap.process.hooks.test.TestNG.testng(TestNG.java:45)
主要语言
Java
星标
88
派生
17
平均合并
2 天 2 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getappmap/appmap-java 的其他 Issue

查看 getappmap/appmap-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。