1
votes

I have JMeter plan that starts with a single JDBC sampler query that captures session ID from the Teradata database (SELECT SESSION;). Same plan also has large number of JDBC samplers with complicated queries producing large output that I don't want to include in the report.

If I configure summary report and tick Save Response Data (XML) then the output from all sampler queries will be saved

How do I add only first query result (it's a single integer) into the test summary report and ignore results from all other queries? For example is there a way to set responseData = false after the first query output is captured?

3

3 Answers

2
votes

Maybe sample_variables property can help?

  1. Define something in "Variable Names" section of the JDBC Request, i.e. put session reference name there like:

    enter image description here

  2. Add the next line to user.properties file (lives in Jmeter's "bin" folder)

    sample_variables=session_1
    

    or alternatively pass it via -J command-line argument like:

    jmeter -Jsample_variables=session_1 -n -t /path/to/testplan.jmx -l /path/to/results.csv
    

    You need to use session_1 not session. As per JDBC Request Sampler documentation:

    If the Variable Names list is provided, then for each row returned by a Select statement, the variables are set up with the value of the corresponding column (if a variable name is provided), and the count of rows is also set up. For example, if the Select statement returns 2 rows of 3 columns, and the variable list is A,,C, then the following variables will be set up:

    A_#=2 (number of rows)

    A_1=column 1, row 1

    A_2=column 1, row 2

    C_#=2 (number of rows)

    C_1=column 3, row 1

    C_2=column 3, row 2

    So given your query returns only 1 row containing 1 integer - it will live in session_1 JMeter Variable. See Debugging JDBC Sampler Results in JMeter article for comprehensive information on working with database query results in JMeter.

  3. When test completes you'll see an extra column in .jtl results file holding your "session" value:

    Sample Variables value

1
votes

Although not exactly solving your question as posted, I will suggest a workaround, using a "scope" of a listener (i.e. listener will only record items on the same or lower level than a listener itself). Specifically: have two Summary Reports: one on the level of test, the other (together with the sampler whose response you want to record) under a controller. For example:

enter image description here

here I have samplers 1, 2, 3, 4. I only want to save response data from sampler 2. So

  • Summary Report - Doesn't save responses is on global level, and it's configured to not save any response data. It only saves what I want to save for all samplers.

  • Summary Report - Saves '2' only is configured to save response data in XML format. But because this instance of Summary Report is under the same controller as sampler 2, but other samplers (1, 3, 4) are on higher level, it will only record responses of sampler 2.

So it doesn't exactly allow you to save response data from one sampler into the same file as all other Summary Report data. But at least you can filter which responses you are saving.

0
votes

May be you can try assertion for ${__threadNum}

i.e. set condition for assertion as "${__threadNum}=1" and set your listner's "Log/display only" option as "successes"

This way it should log only the first response from samplers.