本文介绍了空手道加特林-从报告中排除特定要求或功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在karate-config.js中,我最初仅通过使用callSingle(auth.feature)获得一次身份验证令牌,并且此身份验证令牌已在其他功能文件中重复使用.
In karate-config.js I am initially taking the authentication token only once by using callSingle(auth.feature) and this authentication token is being re-used in other feature files.
我有要使用Karate-Gatling进行性能测试的用户/详细信息api.为此,我创建了一个UserSimulation类.该UserSimulation正在执行user-detail.feature我有以下查询-
I have users/detail api which I want to performance test using Karate-Gatling. For this I have created a UserSimulation class. This UserSimulation is executing user-detail.featureI have following queries -
- 如果可能的话,我如何才能完全忽略生成的报告中的auth.feature请求.
- 如果上述选项无法完全忽略这些请求,那么如何仅对用户详细信息应用响应时间断言.
class UserSimulation extends Simulation {
def successThreshold = 99
def secondMillis = 1000
def percentiles: (Int, Int, Int, Int) = { ( ( 1.2* secondMillis).toInt, 1 * secondMillis, 1 * secondMillis, 1 * secondMillis) }
val (p1, p2, p3, p4) = percentiles
val protocol = karateProtocol(
"/users/{id}/detail" -> Nil
)
val trav = scenario("myuser").exec(karateFeature("classpath:features/users/user-detail.feature"))
setUp(
trav.inject(rampUsers(15) during (50 seconds)).protocols(protocol)
).assertions().assertions( // These assertions are getting applied on auth.feature as well, how to avoid this ?
List(
global.successfulRequests.percent.gte(successThreshold)
, global.responseTime.mean.lte(p1)
, global.responseTime.percentile1.lte(p1) //50th %
, global.responseTime.percentile2.lte(p2) //75th %
, global.responseTime.percentile3.lte(p3) //95th %
, global.responseTime.percentile4.lte(p4) //99th %
)
)
}
推荐答案
示例代码-
val protocol = karateProtocol(
"/users/{id}/detail" -> Nil
)
val trav = scenario("myuser").group("myUserGP"){exec(karateFeature("classpath:features/users/user-detail.feature"))}
setUp(
trav.inject(rampUsers(10) during (100 seconds)).protocols(protocol),
trav2.inject(rampUsers(1) during (100 seconds)).protocols(protocol)
).assertions(details("myUserGP" / "GET /myuser-service/users/{id}/detail").responseTime.mean.lte(p1),
details( "myUserGP" / "GET /myuser-service/users/{id}/detail").responseTime.percentile2.lte(p2),
details( "myUserGP" / "GET /myuser-service/users/{id}/detail").responseTime.percentile3.lte(p3)
) // You can check the complete request path to be passed in details("groupName","completePath") from Simulation.log file
这篇关于空手道加特林-从报告中排除特定要求或功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!