在Meter框架中执行jmx脚本时,在Jmeter中使用$ {__ UUID()}函数的用户参数预处理程序不起作用

问题描述 投票:0回答:1

我正在使用用户参数预处理器在脚本中调用$ {__ UUID()}函数以生成UUID。UserParameter

此$ {__ UUID()}工作正常,当我从Jmeter gui或Jmeter non gui / cmd执行jmx脚本时,会生成UUID。

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

但是,每当我尝试从我的JMeter-Maven框架执行相同的jmx脚本时,它只会在使用此函数$ {__ UUID()}的请求中失败。

Jmeter日志:2020-04-14 15:03:05,695信息o.a.j.u.BeanShellTestElement:UUID ========> $ {__ UUID()}

根据我的理解,根据日志,在从JMeter-Maven框架执行脚本时,它无法使用功能$ {__ UUID()}生成UUID。

使用功能$ {__ UUID()}为请求生成的HTML报告中的错误:非HTTP响应代码:java.net.URISyntaxException /非HTTP响应消息:索引43处查询中的非法字符

这是我的pom.xml文件:

<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>

如果有人可以帮助我解决问题,我将不胜感激!

maven jmeter performance-testing jmeter-plugins
1个回答
0
投票

我无法重现您的问题,但是我可以在您的测试中看到其他几个问题:

  1. __UUID() function的正确语法为:

    ${__UUID}
    

    如果不确定正确的语法,最好使用Functions Helper Dialog,有关更多详细信息,请查看Apache JMeter Functions - An Introduction文章。

  2. <dependencies>块不是必需的,JMeter Maven plugin将下载JMeter本身的相关版本
  3. 根据JMeter最佳实践you should always be using the latest version of JMeter,因此请考虑将JMeter插件版本更改为3.0.0
  4. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting。此外,您不应将JMeter函数或变量内联到脚本中,而应使用vars.get("sample_id")代替,其中vars代表JMeterVariables类实例
© www.soinside.com 2019 - 2024. All rights reserved.