问题
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.
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.feature I have following queries -
- If possible, how can I completely ignore the auth.feature requests from the generated report.
- If above option is not possible to completely ignore these requests, how can I apply response time assertion only on user-detail.
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 %
)
)
}
回答1:
Currently there is no way to ignore any request.
One option is to separate the auth step out and use Feeders: https://github.com/intuit/karate/tree/develop/karate-gatling#feeders
If you refer the Gatling docs: https://gatling.io/docs/current/general/assertions/#scope - it may be possible to "scope" the percentile assertions to a group or name.
Here is someone who seems to have had success with a custom Group name: https://github.com/intuit/karate/issues/858#issuecomment-546410352
To be honest, I don't think there are many Karate users using percentile assertions. Can you confirm if any solution works for you, it will help others. Also do consider contributing, I've added your ask to the roadmap: https://github.com/intuit/karate/projects/3#card-22529251
回答2:
Sample Code -
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
来源:https://stackoverflow.com/questions/59354367/karate-gatling-exclude-specific-request-or-feature-from-report