0
我想要設置Gatling,以便在一次設置中,我可以發送3000個請求,其中95%將使用一個測試文件,另外5%則是另一個測試文件。這些文件恢復成JSON文件(在下面的代碼稱爲「userFeeder」。加特林能支持上述情景?設置Gatling根據百分比/比率發送請求?
代碼當前如下,這適用於每秒辦法的要求,但需要修正。
class AddUserSimulation extends Simulation {
private val conf = ConfigFactory.load() //loads a setup file of parameters
private val TOKEN_VALUE = "tokenvalue"
private val userFeeder = jsonFile("/" + conf.getString("environment") + "/testaddUser.json")
val httpConf = http
.baseURL(conf.getString("api.gateway.url")) // Here is the root for all relative URLs
.header("Referer", conf.getString("referer"))
.header("Cache-Control", "no-cache")
.contentTypeHeader("application/json")
val Login = new ADFSAuthentication Login
val scnAPI = scenario("test add User") // A scenario is a chain of requests and pauses
.feed(userFeeder.circular)
.exec(Login.process)
.repeat(conf.getInt("repeat.count")) {
exec(http("test add User")
.post("/" + conf.getString("environment") + "https://stackoverflow.com/users/")
.body(StringBody("${payload}")).asJSON
.header("Authorization", "Bearer ${"+TOKEN_VALUE+"}")
.check(status.is(200)))
.pause(conf.getInt("execution.pause"))
}
setUp(scnAPI.inject(constantUsersPerSec(11) during(30 minutes)).protocols(httpConf))
}
任何幫助是極大的讚賞。
這正是我們最終使用的。感謝這個輸入,使用兩個饋線是解決方案。 – user3190153