【问题标题】:JMeter JSR233 result to dashboardJMeter JSR233 结果到仪表板
【发布时间】:2019-11-25 14:21:59
【问题描述】:

我有一个 JMeter 测试,它通过 HTTP 调用向异步 java 服务插入输入,然后通过 groovy 脚本收集另一个 java 服务上的公开指标。

脚本然后将收集的指标保存为 JMeter 变量,以作为性能指标进行审查。

我想在 JMeter 生成的仪表板中发布这个值,但我找不到将这个变量保存为 JMeter 输出的方法。

有办法吗?似乎 JMeter 的主要目的是测试 HTTP 同步服务,但它能够进行这样的数据收集。

【问题讨论】:

    标签: java testing groovy jmeter


    【解决方案1】:

    您可以在custom graph 定义中使用变量:

    您可以随时间在 CSV 中绘制任何 sample_variable 图表,您可以通过在 user.properties 文件中设置它们的属性来自定义图表。 他们必须使用 id 前缀 custom_:

    jmeter.reportgenerator.graph.custom_<your_graph_name_id>.property.<your_option_name>
    

    要指定此图是自定义的:

    jmeter.reportgenerator.graph.custom_<your_graph_name_id>.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
    

    这是一个自定义图形配置的示例,它绘制变量 ts-hit:

    jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
    jmeter.reportgenerator.graph.custom_testGraph.title=Chunk Hit
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Number of Hits
    jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
    jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=ts-hit
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Number of Hits :
    

    【讨论】:

      【解决方案2】:

      将您保存在 JSR223 脚本中的 JMeter Variable 声明为 Sample Variable,为此将下一行添加到 user.properties 文件:

      sample_variables=foo
      

      然后你可以配置你的custom chart 像:

      jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
      jmeter.reportgenerator.graph.custom_testGraph.title=Your custom chart title
      jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Your Y axis name
      jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
      jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
      jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=foo
      jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Your custom content message
      

      用您选择的实际 JMeter 变量名称替换 foo,下次生成 HTML 报告仪表板时,您应该会看到随时间绘制的变量值

      更多信息:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多