You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jmeter.apache.org by bu...@apache.org on 2021/11/18 09:22:21 UTC

[Bug 65688] New: The Jmeter function is unavailable via spring-boot

https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

            Bug ID: 65688
           Summary: The Jmeter function is unavailable via spring-boot
           Product: JMeter
           Version: 5.1.1
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HTTP
          Assignee: issues@jmeter.apache.org
          Reporter: 124106107@qq.com
  Target Milestone: JMETER_5.5

Steps to Reproduce:
1. In Jmeter GUI, I create a test.jmx
2. In the script, use CSVRead function in the http request, e.g.  servername:
${__CSVRead(../data/config.csv,4)}
3. Use GUI mode, the test.jmx work fine.
4. But I need to run this jmx file by java spring-boot, below is my primary
code:

        String mysqlJars = jmxWorkDir +
"\\lib\\ext\\mysql-connector-java-5.1.18.jar";
        String pathToJmeterJDBCJars = jmxWorkDir +
"\\lib\\ext\\ApacheJMeter_jdbc.jar";
        String pathToJmeterComponentsJars = jmxWorkDir +
"\\lib\\ext\\ApacheJMeter_components.jar";
        String pathToJmeterHttpJars = jmxWorkDir +
"\\lib\\ext\\ApacheJMeter_http.jar";
        String pathToJmeterPlugManagerJars = jmxWorkDir +
"\\lib\\ext\\jmeter-plugins-manager-1.6.jar";
        String pathToJmeterFunctionsJars = jmxWorkDir +
"\\lib\\ext\\ApacheJMeter_functions.jar";

        String pathCoreJars = jmxWorkDir + "\\lib\\ext\\ApacheJMeter_core.jar";
        String pathJavaJars = jmxWorkDir + "\\lib\\ext\\ApacheJMeter_java.jar";

        //String pathToJmeterJars = pathToJmeterFunctionsJars;
        String pathToJmeterJars = pathToJmeterFunctionsJars + ";" +
pathToJmeterHttpJars
                + ";" + pathToJmeterJDBCJars + ";" + pathToJmeterComponentsJars
+ ";" + pathToJmeterPlugManagerJars +
                    ";" + mysqlJars;

        System.setProperty("java.class.path", pathToJmeterJars);
        //JMeterUtils.setProperty("search_paths", pathToJmeterJars);

        //JMeterUtils.set
        String logFile = jmxWorkDir + "\\result\\" +
jmxFileName.replace(".jmx","") + ".jtl";
        System.out.println("logFile===" + logFile);
        Utility.delFile(logFile);

        File jmxfile = null;

        // JMeter Engine
        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        // Initialize Properties, logging, locale, etc.
        JMeterUtils.loadJMeterProperties(jmxWorkDir +
"\\bin\\jmeter.properties");
        JMeterUtils.setJMeterHome(jmxWorkDir);
        //JMeterUtils.initLogging();// you can comment this line out to see
extra log messages of i.e. DEBUG level
        JMeterUtils.initLocale();

        // Initialize JMeter SaveService
        try {
            SaveService.loadProperties();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        // Load existing .jmx Test Plan
        //FileInputStream in = new FileInputStream(jmxfile);
        HashTree testPlanTree = null;

        try {
            //testPlanTree = (ScriptWrapper) SaveService.loadloadElement(in);
            jmxfile = new File(jmxWorkDir + "\\script\\" + jmxFileName);
            //System.out.println("jmx===" + Utility.readFileContent(jmxWorkDir
+ "\\script\\" + jmxFileName));
            testPlanTree = SaveService.loadTree(jmxfile);

            // Remove disabled test elements
            testPlanTree = FJmeter.convertSubTree(testPlanTree, true);
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            //in.close();
        }

        //report
        Summariser summer = null;
        String summariserName = JMeterUtils.getPropDefault("summariser.name",
"summary");//$NON-NLS-1$
        if (summariserName.length() > 0) {
            summer = new Summariser(summariserName);
        }

        ResultCollector logger = new ResultCollector(summer);
        logger.setFilename(logFile);
        testPlanTree.add(testPlanTree.getArray()[0], logger);

        // Run JMeter Test
        jmeter.configure(testPlanTree);

        jmeter.run();

        List<Integer> durationList = new ArrayList<Integer>();
        durationList.add(10);

        String result = new JtlResolver().resloveJtl(logFile, durationList);
        System.out.println("result===" + result);

5.  The jtl report file content is:
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
2021-11-18 16:44:14,0,"1.0Test1-${__CSVRead(../data/config-Tag.csv,4)}",Non
HTTP response code: java.net.URISyntaxException,"Non HTTP response message:
Illegal character in authority at index 7:
http://${__CSVRead(../data/config.csv,4)}/tag/tag/add",thread
1-1,text,false,"Test failed: text expected to contain
/""code"":1/",1145,0,1,1,"http://${__CSVRead(../data/config.csv,4)}/add",0,0,0

These JMeter functions should also be available via Java code.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p.mouawad@ubik-ingenierie.c
                   |                            |om
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
This is a question for user mailing list.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

--- Comment #6 from WL <12...@qq.com> ---
Thank you very much for helping to solve this problem,
But I'm rather confused about the state of the problem being
'RESOLVED-INVALID',
I will be appreciate your help. @p.mouawad@ubik-ingenierie.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

--- Comment #1 from WL <12...@qq.com> ---
Created attachment 38093
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38093&action=edit
spring-boot-pomfile

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

--- Comment #3 from WL <12...@qq.com> ---
The Step 5 should be 

5.  The jtl report file content is:
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
2021-11-18 16:44:14,0,"1.0Test1-${__CSVRead(../data/config.csv,4)}",Non HTTP
response code: java.net.URISyntaxException,"Non HTTP response message: Illegal
character in authority at index 7:
http://${__CSVRead(../data/config.csv,4)}/tag/tag/add",thread
1-1,text,false,"Test failed: text expected to contain
/""code"":1/",1145,0,1,1,"http://${__CSVRead(../data/config.csv,4)}/add",0,0,0

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

--- Comment #5 from WL <12...@qq.com> ---
The problem described is not a bug???    @Philippe Mouawad

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65688] The Jmeter function is unavailable via spring-boot

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65688

WL <12...@qq.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #2 from WL <12...@qq.com> ---
(In reply to WL from comment #1)
> Created attachment 38093 [details]
> spring-boot-pomfile

-- 
You are receiving this mail because:
You are the assignee for the bug.