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

问题描述

我正在研究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入门中,有一个很好的示例加特林测试脚本: https://vaadin.com/start/latest/full-stack-spring 参见项目的路径:\ src \ test \ scala \ BaristaFlow.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: \src\test\scala\BaristaFlow.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(例如用于"New"按钮的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.

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

07-17 12:09