【问题标题】:Maven/Spring not running jmeter tests correctlyMaven/Spring 没有正确运行 jmeter 测试
【发布时间】:2016-12-20 14:47:07
【问题描述】:

我正在尝试为 spring 应用程序自动执行 jmeter 性能测试。

如果我运行应用程序,然后在一切正常后执行 jmeter 测试。

但如果我运行mvn -e -X verify 而不单独启动应用程序,则会发生这种情况:

2016-12-20 14:01:17.303  INFO 2024 --- [lication.main()] com.nttdata.iam.Application              : Started Application in 12.102 seconds (JVM running for 31.259)
[DEBUG] Spring application is not ready yet, waiting 500ms (attempt 26)
[DEBUG] Spring application is not ready yet, waiting 500ms (attempt 27)

导致

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:start (start-app-before-jmeter) on project iam-demo-microservice: Spring application did not start before the configured timeout (30000ms -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:start (start-app-before-jmeter) on project iam-demo-microservice: Spring application did not start before the configured timeout (30000ms
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Spring application did not start before the configured timeout (30000ms
    at org.springframework.boot.maven.StartMojo.waitForSpringApplication(StartMojo.java:176)
    at org.springframework.boot.maven.StartMojo.runWithMavenJvm(StartMojo.java:150)
    at org.springframework.boot.maven.AbstractRunMojo.run(AbstractRunMojo.java:234)
    at org.springframework.boot.maven.AbstractRunMojo.execute(AbstractRunMojo.java:170)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
2016-12-20 15:17:38.820  INFO 1284 --- [       Thread-5] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5fa74304: startup date [Tue Dec 20 15:17:08 CET 2016]; root of context hierarchy
2016-12-20 15:17:38.820  INFO 1284 --- [       Thread-5] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2016-12-20 15:17:38.820  INFO 1284 --- [       Thread-5] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

我一直在谷歌上搜索并试图弄清楚一段时间,但我很困惑为什么它不起作用。

我的 pom.xml 的构建部分:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>start-app-before-jmeter</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <phase>pre-integration-test</phase>
                    <configuration>
                        <fork>false</fork>
                    </configuration>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                    <phase>post-integration-test</phase>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>2.0.3</version>
            <executions>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <testResultsTimestamp>false</testResultsTimestamp>
                <testFilesIncluded>
                    <jMeterTestFile>SimpleCustomerTestPlan.jmx</jMeterTestFile>
                </testFilesIncluded>
            </configuration>
        </plugin>
    </plugins>
</build>

【问题讨论】:

    标签: spring maven spring-boot jmeter spring-boot-maven-plugin


    【解决方案1】:

    您缺少集成测试元素,这是我的:

    <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.0.3</version>
                    <executions>
                        <execution>
                            <id>execute-jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                            <phase>integration-test</phase>
                        </execution>
                    </executions>
                </plugin>
    

    【讨论】:

    • 不,我不这么认为。它只是写在 上面而不是下面。
    • 对于spring-boot-maven-plugin,你有没有试过使用false。或者似乎有一个“等待计时器”配置让您的 jmeter 在等待计时器之后开始测试,如以下行所示: Caused by: org.apache.maven.plugin.MojoExecutionException: Spring application did not start在配置的超时之前(30000ms
    • 我的意思是 true
    猜你喜欢
    • 2015-10-19
    • 2021-12-16
    • 1970-01-01
    • 2020-12-19
    • 2014-10-25
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 2019-04-25
    相关资源
    最近更新 更多