0
votes

I am calling the ${__UUID()} function in my script to generate UUID, using User Parameter pre processor. UserParameter

This ${__UUID()} works fine, and generates UUID when I execute the jmx script from Jmeter gui or Jmeter non gui/cmd.

Jmeter Log: 2020-04-14 15:24:44,173 INFO o.a.j.u.BeanShellTestElement: UUID=======>3c8114da-1657-4e99-85bd-49081be0172b

But, whenever I am trying to execute this same jmx script from my JMeter-Maven framework, it only fails in the request using this function ${__UUID()}.

Jmeter Log: 2020-04-14 15:03:05,695 INFO o.a.j.u.BeanShellTestElement: UUID=======>${__UUID()}

According to my understanding, based on the logs, its not able to generated the UUID using the function ${__UUID()}, while executing the script from JMeter-Maven framework.

Error Generated in HTML Report for the request using function ${__UUID()}: Non HTTP response code: java.net.URISyntaxException/Non HTTP response message: Illegal character in query at index 43

Here is my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>JMeterMavenImpletation</groupId>
<artifactId>JMeterMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>JMeterMaven</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_core -->
    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_core</artifactId>
        <version>5.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_http -->
    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_http</artifactId>
        <version>5.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components -->
    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_components</artifactId>
        <version>5.1.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_functions -->
    <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_functions</artifactId>
        <version>5.1.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.lazerycode.jmeter/jmeter-maven-plugin -->
    <dependency>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>2.9.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>2.9.0</version>
            <executions>
                <!-- This goal will run the load test and generate the HTML report -->
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
                <!-- This goal runs some verification on error rate and fails the build -->
                <!-- <execution> <id>check-results</id> <phase>verify</phase> <goals> 
                    <goal>results</goal> </goals> </execution> -->
            </executions>
            <configuration>
                <!-- JVM Metrics -->
                <jMeterProcessJVMSettings>
                    <arguments>
                        <argument>-XX:MaxMetaspaceSize=256m</argument>
                        <argument>-Xmx1024m</argument>
                        <argument>-Xms1024m</argument>
                        <argument>-Xprof</argument>
                        <argument>-Xfuture</argument>
                    </arguments>
                </jMeterProcessJVMSettings>
                <!-- Test Script Properties -->
                <propertiesUser>
                    <users>${users}</users>
                    <rampup>${rampup}</rampup>
                    <loop>${loop}</loop>
                </propertiesUser>
                <!-- Fetching Test Script -->
                <testFilesIncluded>
                    <jMeterTestFile>${jMeterScriptFile}</jMeterTestFile>
                </testFilesIncluded>
                <!-- Time stamp -->
                <testResultsTimestamp>true</testResultsTimestamp>
                <!-- HTML Reports -->
                <generateReports>true</generateReports>
            </configuration>
        </plugin>
        <plugin>
            <!-- https://mvnrepository.com/artifact/de.codecentric/jmeter-graph-maven-plugin -->
            <groupId>de.codecentric</groupId>
            <artifactId>jmeter-graph-maven-plugin</artifactId>
            <version>0.1.0</version>
            <configuration>
                <inputFile>${project.build.directory}/jmeter/results/20190808-Scripts_SampleScript.jtl</inputFile>
                <!-- Custom Graphs -->
                <graphs>
                    <graph>
                        <pluginType>ResponseTimesOverTime</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ActiveThreadsOverTime.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>HitsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/BytesThroughputOverTime.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ResponseCodesPerSecond.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ResponseTimesDistribution.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ResponseTimesOverTime.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ResponseTimesPercentiles.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ThroughputVsThreads.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/ResponseTimesVSThreads.png</outputFile>
                    </graph>
                    <graph>
                        <pluginType>TransactionsPerSecond</pluginType>
                        <width>800</width>
                        <height>600</height>
                        <outputFile>${project.build.directory}/jmeter/results/TransactionsPerSecond.png</outputFile>
                    </graph>
                </graphs>
            </configuration>
        </plugin>
    </plugins>
</build>

I would really appreciate if someone may aid me to resolve it !

1

1 Answers

0
votes

I cannot reproduce your issue however I can see several other problems with your test:

  1. The correct syntax for __UUID() function would be:

    ${__UUID}
    

    It's better to use Functions Helper Dialog if you're uncertain regarding the proper syntax, check out Apache JMeter Functions - An Introduction article for more details.

  2. This <dependencies> block is not necessary, JMeter Maven plugin will download the relevant version of JMeter itself
  3. According to JMeter Best Practices you should always be using the latest version of JMeter so consider changing the JMeter plugins version to 3.0.0
  4. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting. Moreover, you should not be inlining JMeter functions or variables into the script, you should be using vars.get("sample_id") instead where vars stands for JMeterVariables class instance