karate - 空手道加特林 - 从报告中排除特定请求或功能
问题描述
在 karate-config.js 中,我最初仅使用 callSingle(auth.feature) 获取身份验证令牌一次,并且此身份验证令牌正在其他功能文件中重复使用。
我有用户/详细信息 api,我想使用 Karate-Gatling 进行性能测试。为此,我创建了一个 UserSimulation 类。此 UserSimulation 正在执行 user-detail.feature 我有以下查询 -
- 如果可能的话,我怎样才能完全忽略生成报告中的 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
推荐阅读
- magento - 在结帐时以编程方式选择地址 - Magento 2
- ubuntu - Ubuntu 上 Remmina 的错误消息在哪里
- python - 如何在 Python 中对马尔可夫链进行可视化动画处理?
- java - 在 Java 应用程序中使用 .sql 脚本创建 PostgreSQL 数据库
- html - 如何加载基于单选按钮选择的Angular组件
- c - 无法在 Linux 上的 Node.js 域套接字服务器和 C 域套接字客户端之间进行通信
- r - 如何比较R中的两个列表
- uwp - 将弹出限制到当前 AppWindow 的边界
- python - 我无法将 Python 输出导出到 Excel 文件
- python - Using aggregate and join on all columns except a few