Search code examples
jmeterjmeter-pluginsjmeter-5.0jmeter-4.0jmeter-3.2

Jmeter checkpoint for a specific transaction


Is there something wrong with this code? I am trying to identify a failed user in JMeter when running a test. The script is absolutely working fine in my local and with a limited number of users. How can I print the failing users in the log while using distributed testing? I am running 100 users per machine(5 slaves with the master)

My first transaction has 10 requests and in the request post processor i am using the below code to print in the log. But where exactly it will be shown in distributed load test and i am using Apdex report finally but it doesn't show up even there.

if(prev.getResponseCode()=='500') { log.info('Failed User: ' + '${__threadNum}-${Username}-${MachineIp}-${__machineName}'); }


Solution

  • It will appear in jmeter.log file (or jmeter-server.log file, depending on the way how do you start the slave) on the machine where it failed

    If you want to see this in the HTML Reporting Dashboard - you need to use prev.setResponseMessage() function

    Also don't inline JMeter Functions or Variables into Groovy scripts as it conflicts with GString templates and only first occurrence will be cached and used on subsequent iterations

    More information: Apache Groovy - Why and How You Should Use It

    Suggested code change:

    import org.apache.jmeter.util.JMeterUtils
    
    if (prev.getResponseCode() == '500') {
        prev.setResponseMessage('Failed User: ' + ctx.getThreadNum() + '-' + vars.get('Username') + '-' + JMeterUtils.getLocalHostIP() + '-' + JMeterUtils.getLocalHostName());
    }