【发布时间】:2018-06-04 09:29:06
【问题描述】:
我想写一个加特林负载测试模拟类。我有三个请求 req1、req2 和 req3。我希望能够在 5 秒内增加 300 个用户的情况下执行负载测试。我还需要测试完全运行 20 分钟。
现在我需要三个请求同时运行,但 req1 的吞吐量为 90%,req2 为 5%,req3 为 5%。 例如:如果有 100 个请求,则必须有 90 个属于 req1,5 个属于 req2,5 个属于 req3。
到目前为止,这是我的模拟课程:
package simulations;
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LoadSimulation extends Simulation{
val httpConfig = http
.baseURL("http://url.com")
.acceptHeader("text/html,application/xhtml+xml,application/xml")
val update = scenario("Update").exec(Api.update)
val read= scenario("Read").exec(Api.read)
val age= scenario("Age").exec(Api.age)
setUp(
postToChannel.inject(rampUsers(300) over (5 seconds))
).protocols(httpConf)
.maxDuration(20 minutes)
}
object Api{
val channelFeeder = csv(test.csv).random
val update = feed(channelFeeder)
.exec(http("Update")
.get("/update?key=${key}&${url}")
val read= feed(channelFeeder)
.exec(http("Read")
.get("/app/${id}/data/1/1.json?key=${key}")
val age= feed(channelFeeder)
.exec(http("Age")
.get(/app/${id}/data/1/age?key=${key})
}
我不确定如何将这三个 api 放在一个场景中并分别以 update(90)、read(5) 和 age(5) 吞吐量运行它们。
这方面的任何线索都会有所帮助。
谢谢
【问题讨论】:
标签: maven load-testing gatling