1

I am having issues with my jmeter test.

I am using Blazemeter Taurus (bzt command) to run it, and I run it as a Jenkins job. My issue is: I created user defined values, which I set as Jmeter properties so I can pass them params from the command line: example for a property I set

The issue occurs when I pass a number: bzt -o modules.jmeter.properties.profileId=413 -o modules.jmeter.properties.lab=8050

these are parsed as 8050.0 and 413.0 Because the "lab" param is embeded in a url, it breaks the url.

When running this via command line with the jmeter command, this works fine.

I tried working around this with a bean shell sampler that does the following:

int a = Integer.parseInt(vars.get(${lab}));
String raw = String.ValueOf(a);
String processed = raw.substring(0,5);    


vars.putObject("lab" ,new String(processed));
props.put("lab", lab);
log.info("this is the new " + ${lab});

but this fails. any help would be appreciated.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233

1 Answers1

1
  1. In regards to Taurus issue - report it via Taurus support forum
  2. In regards to Beanshell workaround - your code is not very correct, you need to amend it as follows:

    int lab = (int)Double.parseDouble(props.get("lab"));
    int profileId = (int)Double.parseDouble(props.get("profileId"));
    
    props.put("lab", String.valueOf(lab));
    props.put("profileId", String.valueOf("profileId"));
    
    log.info("lab=" + lab);
    log.info("profileId=" + profileId);
    

as stuff passed via -o modules.jmeter.properties should be accessed via props shorthand, not vars

Demo:

Beanshell props manipulation Demo

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using JMeter and Java API from Beanshell test elements in your JMeter test.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133