JMeter在不同的线程上检查不同的断言 [英] JMeter check different assertion on different threads

查看:153
本文介绍了JMeter在不同的线程上检查不同的断言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JMeter,我要检查仅允许1次更新的锁定部分

Using JMeter, I want to check locking section that allow only 1 update

我正在运行具有10个线程的线程组,并且期望只有1个(并非总是第一个)线程返回0,而其他9个线程返回1 我该怎么断言?

I'm running Thread group with 10 Threads and expect only 1 (not always the first) thread to return 0 and 9 others to return 1 How can I assert it?

线程组(10) -HTTP采样器 --?断言

Thread group (10) - HTTP Sampler - - ? Assertion

修改

10实际上是一个动态属性.因此,我需要任何线程计数都期望只有1个断言才能返回成功.

10 is actually a dynamic property. So I need for any thread count to expect only 1 assertion to return success.

该测试用于检查记录锁定是否正常工作,即使在压力/负载测试中也只能更新一次记录.

The test is to check that locking of record is working and can only update record once, even on stress/load test.

编辑2

使用关键部分控制器没有给我确切的失败结果

Using Critical Section Controller didn't give me exact result of failures

推荐答案

最后,我成功了,我将每个线程保存到失败计数的唯一ID中,最后使用tearDown Thread Group来计算失败

Finally I succeeded, I save each thread in a unique id the failure count and I use tearDown Thread Group at the end to calculate the failures

在请求后,在Thread Group中使用If Controller

并在其下的 JSR223采样器,该标记通过每个线程:

and under it JSR223 Sampler which mark failures flag by unique id per thread:

String threadNumber = String.valueOf(ctx.getThreadNum());
props.put("failures" + threadNumber, 1);

JSR223采样器将失败,除非仅精确 strong>存在成功请求

JSR223 Sampler will failed unless only exactly one successful request exists

int numberOfFailures = 0;
for (i=0; i < 10; i++) {
    String id = "failures"+ String.valueOf(i);
    failureFlag = props.get(id);
    log.info("failureFlag=" + failureFlag);
    if (failureFlag == 1){
        numberOfFailures ++;
    }
}
if (numberOfFailures != 9) {
    SampleResult.setSuccessful(false);
}

这篇关于JMeter在不同的线程上检查不同的断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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