繁体   English   中英

当Gatling负载测试表现不佳时,如何让jenkins工作失败

[英]How to bring jenkins job to fail when Gatling load tests underperform

当没有遇到Gatling声明或者请求失败时,有没有人试图让正在运行的Jenkins作业失败?

例如:

  • 当第95百分位数的全局平均值低于特定值时,将Jenkins构建标记为不稳定,例如响应时间为1.2秒
  • 如果没有应答某个百分比的请求,则将Jenkins构建标记为失败

有没有人知道如何使用现有的Gatling Maven / Jenkins插件实现这一目标。

我的maven插件设置是:

                <plugin>
                    <groupId>io.gatling</groupId>
                    <artifactId>gatling-maven-plugin</artifactId>
                    <version>${gatling.version}</version>
                    <configuration>
                        <failOnError>true</failOnError>
                        <simulationsFolder>src/test/scala</simulationsFolder>
                        <runMultipleSimulations>true</runMultipleSimulations>
                        <configFolder>src/main/resources</configFolder>
                    </configuration>
                    <executions>
                        <execution>
                            <id>GoOrBust</id>
                            <phase>test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <simulationClass>mine.OnePunch</simulationClass>
                                <failOnError>true</failOnError>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

<failOnError>true</failOnError>只会影响报告生成,但不会影响Jenkins Job(显然)。

我宁愿不通过自定义异常监视/处理显式地从测试内部抛出异常。

  1. 特定于Gatling的解决方案:您需要在Gatling脚本中定义全局断言 ,如:

     setUp(scn.inject( ... )) .protocols(httpProtocol) .assertions( global.successfulRequests.percent.greaterThan(99) ) 
  2. 另类。 您可以考虑使用Taurus工具作为包装来运行Gatling脚本。 它可以使用现有的Gatling测试并对它们应用灵活的通过/失败标准 如果失败,触发Taurus将返回非零退出代码,因此Jenkins作业将失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM