Apache JMeter:在请求体中添加随机数据 [英] Apache JMeter : Add random data in body for request

查看:23
本文介绍了Apache JMeter:在请求体中添加随机数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Apache JMeter 中对我们的应用程序进行压力测试.

I'm working on stress testing our application in Apache JMeter.

我想到了调用 register user 方法将用户添加到数据库中.但是如果电子邮件已经存在,那么数据库操作不会发生.

I thought of calling register user method which will add users in the database. But if the email already exists, then the database action does not take place.

如何在正文数据中添加随机数?或者有没有其他方法可以对与数据库连接的应用程序进行压力测试?

How can I add a random number in body data? Or is there some other way I can stress test my application connected with database?

以下是一些截图:

控制器代码:

@RequestMapping(value = "/person/add", method = RequestMethod.POST)
public String addPerson(@ModelAttribute("person") Person person, BindingResult bindingResult) {
    System.out.println("Person add called"+person.getUsername());
    person.setUsername(this.stripHTML(person.getUsername()));
    int personId = this.personService.addPerson(person);
    if (!(personId == 0)) {
        Person person1 = this.personService.getPersonById(personId);
        Collection<GrantedAuthority> authorities = new ArrayList<>();
        authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
        Authentication authentication = new UsernamePasswordAuthenticationToken(person1, null, authorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);
        return "redirect:/canvaslisting";
    } else {
        return "redirect:/";
    }
}

推荐答案

  1. 使用 随机变量和变量名 emailValue 并发送 ${请求中的 emailValue}

  1. Use Random Variable with variable name emailValue and send ${emailValue} in request

使用JDBC请求到您的数据库来创建随机数或序列并保存在变量名 emailValue

Use JDBC request to your database to create random number or sequence and save in variable name emailValue

使用 UUID 函数创建 uniqueId 并发送电子邮件 ${uniqueId}@gmail.com 例如

Use UUID function to create uniqueId and send in email ${uniqueId}@gmail.com for example

这篇关于Apache JMeter:在请求体中添加随机数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆