【问题标题】:How to synchronize two thread groups in Jmeter如何在 Jmeter 中同步两个线程组
【发布时间】:2014-03-25 13:40:58
【问题描述】:

使用 Jmeter,我想实现这样的目标:

Thread Group 1
 - Http Request 1
 - Set P1 to "true"
 - Wait synchronization with Thread Group 2 (parameters P1 and P2 are both "true")
 - Http Request 2

Thread Group 2
 - Http Request 1
 - Set P2 to "true"
 - Wait synchronization with Thread Group 1 (parameters P1 and P2 are both "true")
 - Http Request 2

这与herehere 描述的基本相同:我将 P1 和 P2 设置为“true”,如下所示(HTTP 请求/BeanShell 都有效):

${__setProperty(P1,"true",)}

我的问题是如何实现等待条件。我已经为 while 控制器的退出条件尝试了所有可能的组合,但无法实现我想要的。奇怪的是,放置在循环中的 Debug 采样器(或带有 log.info 的 beanshell)显示属性 P1 和 P2 已正确设置(并且退出条件满足我的期望),但它无论如何都不会退出。例如我试过:

${__property("P1")}!="true"||${__property("P2")}!="true"
${__property(P1)}!="true"||${__property(P2)}!="true"
${__property(P1)}=="true"&&${__property(P2)}=="true"
${__property("P1")}=="true"&&${__property("P2")}=="true"

有人可以帮助我吗?提前致谢!

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    查看这个处理线程间通信的组件:

    【讨论】:

      【解决方案2】:

      诀窍是对 while 条件使用 __BeanShell 函数:

      ${__BeanShell((${__property(P1)}!="true"||${__property(P2)}!="true"}
      

      此外,While 控制器不能为空(您必须添加采样器或类似的东西,否则将被跳过)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-09
        相关资源
        最近更新 更多