-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2440 from ciandt-crodrigues/add-silent-option-for…
…-gatling-karate-builder Add silent option for gatling karate builder
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
karate-gatling/src/test/scala/mock/CatsSimulationWithSilentWarmUp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mock | ||
|
||
import com.intuit.karate.Runner | ||
import com.intuit.karate.gatling.KarateProtocol | ||
import com.intuit.karate.gatling.PreDef._ | ||
import io.gatling.core.Predef._ | ||
import io.gatling.core.structure.ScenarioBuilder | ||
|
||
import scala.concurrent.duration._ | ||
|
||
class CatsSimulationWithSilentWarmUp extends Simulation { | ||
|
||
MockUtils.startServer(0) | ||
|
||
val protocol: KarateProtocol = karateProtocol( | ||
"/cats/{id}" -> Nil, | ||
"/cats" -> pauseFor("get" -> 15, "post" -> 25) | ||
) | ||
|
||
protocol.nameResolver = (req, ctx) => req.getHeader("karate-name") | ||
protocol.runner.karateEnv("perf") | ||
|
||
val createWarmup: ScenarioBuilder = scenario("create warm-up").exec(karateFeature("classpath:mock/cats-create.feature").silent()) | ||
val create: ScenarioBuilder = scenario("create").exec(karateFeature("classpath:mock/cats-create.feature")).exec(session => { | ||
println("*** id in gatling: " + session("id").as[String]) | ||
println("*** session status in gatling: " + session.status) | ||
session | ||
}) | ||
|
||
val deleteWarmup: ScenarioBuilder = scenario("delete warm-up").exec(karateFeature("classpath:mock/cats-delete.feature").silent()) | ||
val delete: ScenarioBuilder = scenario("delete").group("delete cats") { | ||
exec(karateFeature("classpath:mock/cats-delete.feature@name=delete")) | ||
} | ||
|
||
val customWarmup: ScenarioBuilder = scenario("custom warm-up").exec(karateFeature("classpath:mock/cats-rpc.feature").silent()) | ||
val custom: ScenarioBuilder = scenario("custom").exec(karateFeature("classpath:mock/custom-rpc.feature")) | ||
|
||
setUp( | ||
createWarmup.inject(rampUsers(1) during (5 seconds)).andThen( | ||
create.inject(rampUsers(10) during (5 seconds)) | ||
), | ||
deleteWarmup.inject(rampUsers(1) during (5 seconds)).andThen( | ||
delete.inject(rampUsers(5) during (5 seconds)) | ||
), | ||
customWarmup.inject(rampUsers(1) during (5 seconds)).andThen( | ||
custom.inject(rampUsers(10) during (5 seconds)) | ||
) | ||
).protocols(protocol) | ||
|
||
} |