本文介绍了如何使用 Vaadin 10 和 JMeter 执行负载测试/性能测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从事 Vaadin 10 项目,我们想在我们的网站上执行负载测试.在我们使用 Vaadin 10 之前,我们可以使用 Jmeter 做到这一点,但使用 Vaadin 10 似乎 JMeter 不起作用.

I work on a Vaadin 10 project and we want to perform a load test on our website. Before we used Vaadin 10, we could do that with Jmeter but with Vaadin 10 it seems that JMeter doesn't work.

我们尝试使用 JMeter 5.1.1 并记录了测试用例.第一个问题是 CSRF 令牌和推送 id.两者都可以使用正则表达式提取器提取,然后我们将它们放入正文数据中:

We tried using JMeter 5.1.1 and recorded the test case. The first problem was the CSRF token and the push id. Both could get extracted with a regular expression extractor and we put them in the body data:

{"csrfToken":"${csrf}","rpc":  [{"type":"mSync","node":5,"feature":1,"property":"invalid","value":true}],"  syncId":0,"clientId":0}

据我所知,至少这奏效了,但我们返回的唯一结果是一个 HTML 页面,其中包含您必须在浏览器中启用 javascript 才能使用此网站."

As far as I can see, at least that worked, but the only result we get back is a HTML page with "You have to enable javascript in your browser to use this web site."

有谁知道是否有更好的方法来对 Vaadin 10 应用程序执行负载测试,或者如何让它与 JMeter 一起工作?

Does anyone know if there are better ways to perform a load test on a Vaadin 10 application or how to get it working with JMeter?

到目前为止,我找到的大多数答案都适用于 Vaadin 8 或 7,但没有适用于 Vaadin 10+.

Most answers I found until now are for Vaadin 8 or 7, but none for Vaadin 10+.

推荐答案

是的,可以使用 JMeter 进行负载测试 Vaadin 10+ 应用程序.您应该能够使用以下正则表达式来提取 csrf 令牌:

Yes, it is possible to use JMeter for load test Vaadin 10+ applications. You should be able to use following regex for extracting the csrf token:

Vaadin-Security-Key":"(.+?)"

针对 Vaadin 13 Bakery 应用启动器测试时我的 JMeter 的屏幕截图:

A screenshot of my JMeter when testing against Vaadin 13 Bakery app starter:

除了 JMeter 之外,在对 Vaadin(任何版本)应用程序进行可扩展性测试时,Gatling 也是一个不错的选择.Vaadin 13 的 Bakery App starter 中有一个非常好的示例 Gatling 测试脚本:https://vaadin.com/start/latest/full-stack-spring 查看项目路径:srcestscalaBaristaFlow.scala.

In addition to JMeter, Gatling is also a good option when scalability testing Vaadin (any version) applications. There is a quite good example Gatling test script in Bakery App starter for Vaadin 13: https://vaadin.com/start/latest/full-stack-spring See the path: srcestscalaBaristaFlow.scala of the project.

我在此处上传了一个针对 V13 应用程序(相同的 Bakery Flow 启动器)的小型但功能齐全的 JMeter 测试:https://gist.github.com/johannest/593309e31e35789f8e5b03bed074f13c

I uploaded a small but fully functioning JMeter test against V13 application (the same Bakery Flow starter) here: https://gist.github.com/johannest/593309e31e35789f8e5b03bed074f13c

示例脚本显示了 csrf 令牌提取,以及如何提取组件 ID(例如用于新建"按钮的 ID)以及客户端和同步 ID.提取这些 id 并将它们用作以下请求中的变量(而不是使用记录的 id)使您的测试更加稳定.

The example script shows the csrf token extract, but also how to extract component ids (such as an id used for the "New" button) and client and sync ids. Extracting these ids and using them as variables in the following requests (instead of using recorded ids) makes your test more stable.

这篇关于如何使用 Vaadin 10 和 JMeter 执行负载测试/性能测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 08:47