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