Karate-Gatling:报告中带有查询参数的请求未聚合
Karate-Gatling: Requests with query parameter in reports are not getting aggregated
我正在对 karate-gatling 进行 POC 以重用我的测试。我已经参考了文档并安装了这些版本。首先,像往常一样出色的工作,非常容易设置和开始。
我正在从 MySimualtion.scala 调用一个特征文件,它有如下三个其他抽象特征调用:
* def tranRef = TransactionReferenceUtils.generateTransactionReferenceStartWith('09')
* set payloadR /transaction_reference = tranRef
POST API >> /sending/v1/dm
* call read('classpath:../InitiateAbstract.feature')
* match responseStatus == 200
GET API By Reference >> /sending/v1/dm?ref={ref}
* call read('classpath:../RetrieveByRefAbstract.feature') {ref: #(tranRef)}
* match responseStatus == 200
GET API By Id>> /sending/v1/dm/{id}
* call read('classpath:../RetrieveByIdAbstract.feature') {id: #(pmId)}
* match responseStatus == 200
抽象特征使用 url 关键字来调用 API。
MySimulation.scala 看起来像这样
class MySimulation extends Simulation {
val protocol = karateProtocol(
"/sending/v1/dm?ref={ref}" -> Nil,
"/send/v1/dm/{id}" -> Nil,
"/sending/v1/dm" -> Nil
)
protocol.nameResolver = (req, ctx) => req.getUrlAndPath()
val create = scenario("create").exec(karateFeature("classpath:com/mastercard/send/xb/Testcases/Rem1Shot/Remit1ShotWithFrwdFeesRetrieve.feature"))
setUp(
create.inject(rampUsers(2) during (5 seconds)).protocols(protocol)
)
}
现在的问题是,在报告中,带有 {id} 的 GET 请求和 POST 请求正在聚合,但带有 ref 的 GET 请求是单独报告的。
我也尝试过将 nameResolver 与 getUrlAndPath 一起使用,但还是不行。
我不确定我是否遗漏了什么。
注意:
还有另一个问题,我无法通过使用以下协议将 GET 请求与 id 聚合,但现在当我包含完整的 uri 时它很好。
"/dm/{id}" -> Nil,
"/dm" -> Nil
对于该 get 请求,传递一个伪造的 header 并使用它来控制 nameResolver:https://github.com/intuit/karate/tree/master/karate-gatling#nameresolver
我原以为 /sending/v1/{dm}
或类似的东西会起作用。
请注意,理论上您可以编写一些自定义 Scala 代码来解析 URL 并进行名称解析。如果您觉得这应该变得更容易,请提交功能请求,或者更好的是,贡献代码!
我正在对 karate-gatling 进行 POC 以重用我的测试。我已经参考了文档并安装了这些版本。首先,像往常一样出色的工作,非常容易设置和开始。
我正在从 MySimualtion.scala 调用一个特征文件,它有如下三个其他抽象特征调用:
* def tranRef = TransactionReferenceUtils.generateTransactionReferenceStartWith('09')
* set payloadR /transaction_reference = tranRef
POST API >> /sending/v1/dm
* call read('classpath:../InitiateAbstract.feature')
* match responseStatus == 200
GET API By Reference >> /sending/v1/dm?ref={ref}
* call read('classpath:../RetrieveByRefAbstract.feature') {ref: #(tranRef)}
* match responseStatus == 200
GET API By Id>> /sending/v1/dm/{id}
* call read('classpath:../RetrieveByIdAbstract.feature') {id: #(pmId)}
* match responseStatus == 200
抽象特征使用 url 关键字来调用 API。
MySimulation.scala 看起来像这样
class MySimulation extends Simulation {
val protocol = karateProtocol(
"/sending/v1/dm?ref={ref}" -> Nil,
"/send/v1/dm/{id}" -> Nil,
"/sending/v1/dm" -> Nil
)
protocol.nameResolver = (req, ctx) => req.getUrlAndPath()
val create = scenario("create").exec(karateFeature("classpath:com/mastercard/send/xb/Testcases/Rem1Shot/Remit1ShotWithFrwdFeesRetrieve.feature"))
setUp(
create.inject(rampUsers(2) during (5 seconds)).protocols(protocol)
)
}
现在的问题是,在报告中,带有 {id} 的 GET 请求和 POST 请求正在聚合,但带有 ref 的 GET 请求是单独报告的。
我也尝试过将 nameResolver 与 getUrlAndPath 一起使用,但还是不行。
我不确定我是否遗漏了什么。
注意: 还有另一个问题,我无法通过使用以下协议将 GET 请求与 id 聚合,但现在当我包含完整的 uri 时它很好。
"/dm/{id}" -> Nil,
"/dm" -> Nil
对于该 get 请求,传递一个伪造的 header 并使用它来控制 nameResolver:https://github.com/intuit/karate/tree/master/karate-gatling#nameresolver
我原以为 /sending/v1/{dm}
或类似的东西会起作用。
请注意,理论上您可以编写一些自定义 Scala 代码来解析 URL 并进行名称解析。如果您觉得这应该变得更容易,请提交功能请求,或者更好的是,贡献代码!