3
votes

After running my load test Jmeter generate result onto "summary.csv".
Some urls in this file looks like:

1482255989405,3359,POST ...users/G0356GM7QOITIMGA/...
1482255989479,3310,POST ...users/HRC50JG3T524N9RN/...
1482255989488,3354,POST ...users/54QEGZB54BEWOCJJ/...

Where "...users/G0356GM7QOITIMGA/..." - its URL column.
After that I try to generate jmeter-report using this command:

jmeter -g summary.csv -o report

Howewer this action throw Out of memory exception (because of many different URLs).
So I decide to edit summary.csv in tearDown Thread Group and replace all ID to "someID" string, using BeanShell Sampler:

import java.io.*;
import org.apache.jmeter.services.FileServer;
 try {
        String sep = System.getProperty("line.separator");
        String summaryFileDirPath = FileServer.getFileServer().getBaseDir() + File.separator;
        String summaryFilePath = summaryFileDirPath + "summary.csv";
        log.info("read " + summaryFilePath);
        File file = new File(summaryFilePath);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String line;
        String text = "";
        while ((line = reader.readLine()) != null) {
            text += line + sep;
        }
        reader.close();
        log.info(summaryFilePath);
        file.delete();

        FileWriter writer = new FileWriter(summaryFileDirPath + "summary.csv", false);
        writer.write(text.replaceAll("users/[A-Z0-9]*/", "users/EUCI/"));
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

Result:
summary.csv screen

Seems like Jmeter append some rows after tearDown Thread Group ends his work.
How can I edit summary.csv file after test run using only jmeter script?
PS: I need collect result only in summary.csv

1
Hint: formatting matters. Please spend the 1 minute it takes to properly indent your source code. You want us to spend our time to help you ... so you please make that as easy and straight forward as possible.GhostCat
thank for your comment. I have formatted the script.Misha Mikus

1 Answers

1
votes

There is a JMeter Property - jmeter.save.saveservice.autoflush, most probably you are suffering from its default value of false

# AutoFlush on each line written in XML or CSV output
# Setting this to true will result in less test results data loss in case of Crash
# but with impact on performances, particularly for intensive tests (low or no pauses)
# Since JMeter 2.10, this is false by default
#jmeter.save.saveservice.autoflush=false

You can override the value in at least 2 ways:

  1. Add the next line to user.properties file:

    jmeter.save.saveservice.autoflush=true
    
  2. Pass it to JMeter via -J command-line argument like:

    jmeter -Jjmeter.save.saveservice.autoflush=true -n -t ....
    

See Apache JMeter Properties Customization Guide article for comprehensive information on JMeter Properties and ways of working with them