Merge pull request #9980 from slandelle/master
Fix Gatling test used for https://www.baeldung.com/gatling-jmeter-grinder-comparison
This commit is contained in:
commit
e663f89592
|
@ -7,7 +7,7 @@ import scala.concurrent.duration._
|
|||
|
||||
class RewardsScenario extends Simulation {
|
||||
|
||||
def randCustId() = Random.nextInt(99)
|
||||
def randCustId() = java.util.concurrent.ThreadLocalRandom.current().nextInt(1, 10000)
|
||||
|
||||
val httpProtocol = http.baseUrl("http://localhost:8080")
|
||||
.acceptHeader("text/html,application/json;q=0.9,*/*;q=0.8")
|
||||
|
@ -20,16 +20,14 @@ class RewardsScenario extends Simulation {
|
|||
.repeat(10){
|
||||
exec(http("transactions_add")
|
||||
.post("/transactions/add/")
|
||||
.body(StringBody("""{ "customerRewardsId":null,"customerId":""""+ randCustId() + """","transactionDate":null }""")).asJson
|
||||
.body(StringBody(_ => s"""{ "customerRewardsId":null,"customerId":"${randCustId()}","transactionDate":null }""")).asJson
|
||||
.check(jsonPath("$.id").saveAs("txnId"))
|
||||
.check(jsonPath("$.transactionDate").saveAs("txtDate"))
|
||||
.check(jsonPath("$.customerId").saveAs("custId")))
|
||||
.pause(1)
|
||||
|
||||
.exec(http("get_reward")
|
||||
.get("/rewards/find/${custId}")
|
||||
.check(jsonPath("$.id").saveAs("rwdId")))
|
||||
.pause(1)
|
||||
.check(jsonPath("$.id").optional.saveAs("rwdId")))
|
||||
|
||||
.doIf("${rwdId.isUndefined()}"){
|
||||
exec(http("rewards_add")
|
||||
|
@ -41,7 +39,6 @@ class RewardsScenario extends Simulation {
|
|||
.exec(http("transactions_add")
|
||||
.post("/transactions/add/")
|
||||
.body(StringBody("""{ "customerRewardsId":"${rwdId}","customerId":"${custId}","transactionDate":"${txtDate}" }""")).asJson)
|
||||
.pause(1)
|
||||
|
||||
.exec(http("get_reward")
|
||||
.get("/transactions/findAll/${rwdId}"))
|
||||
|
|
Loading…
Reference in New Issue