1

如果 JMeter 测试失败,如何停止 Jetty?我的 Gradle 脚本:

apply plugin: 'jetty'
apply plugin: 'jmeter'

jmeterRun {
    doFirst() {
        jettyRunWar.httpPort = 8080    // Port for test
        println "Starting Jetty on port:" + jettyRunWar.httpPort

        jettyRunWar.daemon = true
        jettyRunWar.execute()
    }
    doLast() {
        println "Stopping Jetty"

        jettyStopWar.stopPort = 8091   // Port for stop signal
        jettyStopWar.stopKey = 'stopKey'
        jettyStopWar.execute()
    }

    jmeterTestFiles = [
        file("src/test/jmeter/Tests.jmx")
    ]
}
4

2 回答 2

0

You can use the method finalizedBy to ensure that Jetty is stopped no matter whether JMeter runs successfully or fails.

jmeterRun {
    dependsOn jettyRunWar
    finalizedBy jettyStopWar
}
于 2013-11-14T16:04:13.313 回答
0

尝试以下设置:

在 doFirst()

jettyRunWar.stopPort = 8090
jettyRunWar.stopKey = 'stopKey'

在 doLast()

jettyStop.stopPort = 8090
jettyStop.stopKey = 'stopKey'

不确定这是否是与此链接相关的错误,或者您只需要指定一个 stopPort 即可让码头监听。

在 intelliJ 中运行 jettyRunWar 任务后,我在停止码头时遇到了问题,但是在我的 build.gradle 中有这 4 个设置允许我通过运行 jettyStop 任务来停止码头。

于 2014-05-20T16:30:27.197 回答