1

i`m having this scheme in Jmeter:

> DataBase Extraction (query that gets some files - note that the extract has a variable bound to it). > ForEach Controller (runs through the files from DBExt. and stores them in a variable one at a time). > What i want to do now is to get each file name and concatenate them in a single string so i can further work with it (count lines with a SSH command).

I`m stuck here. I tried all sorts of BeanShell processors and loggers with no success. I would appreciate any hints or ideas that might help. Thank you!

Later edit:

this is my DB Query:enter image description here

this is the query result:

enter image description here

I need a variable with contents like: file1.dat file2.dat file3.dat ... lastfile.dat so i can put it in a SSH Command and perform a line count (wc -l).

VanG
  • 55
  • 1
  • 9

1 Answers1

0

I don't think you even need the ForEach Controller here, you can concatenate multiple variables into one using the following Groovy code in JSR223 Sampler (put it instead of the ForEach Controller)

def concat = new StringBuilder()
vars.entrySet().each {var ->
    if (var.getKey().startsWith('foo')){
        concat.append(var.getValue())
    }
}
vars.put('concat',concat.toString())
  1. Replace foo with your JDBC variable prefix
  2. Contatenated values will be available as ${concat}

Just in case it is not something you're looking for you can combine 2 variables into one using __V() function like ${__V(foo_${bar})} where:

  • foo_ is a prefix
  • and bar is a postfix
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank you very much man, i`m getting somewhere now but it`s still not giving me what i want although i understand what you gave me. Problem is that: 1. somehow println 'concat' doesnt work after your code so i can see its contents. 2. i`ve put a debug postprocessor and it shows me concat = my global variables but not the variable values from the db query. – VanG Feb 05 '18 at 13:33