如何(如果可能的话)在参数改变的情况下使用REST请求运行Gatling测试?
我正在用Gatling为restweb服务编写一个负载测试。服务的端点接收路径中的参数,如下所示:如何(如果可能的话)在参数改变的情况下使用REST请求运行Gatling测试?,rest,random,gatling,Rest,Random,Gatling,我正在用Gatling为restweb服务编写一个负载测试。服务的端点接收路径中的参数,如下所示: http://localhost:8080/api/v1/palindrom/revert/{word} import scala.concurrent.duration._ import io.gatling.core.Predef._ import io.gatling.http.Predef._ class MultiRequest extends Simulation { pr
http://localhost:8080/api/v1/palindrom/revert/{word}
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class MultiRequest extends Simulation {
private val baseUrl = "http://localhost:8080"
private val endpoint = "/api/v1/palindrom"
val httpProtocol = http
.baseUrl(baseUrl)
.inferHtmlResources()
.acceptHeader("*/*")
.contentTypeHeader("application/json")
.userAgentHeader("gatling/3.3.1")
val fullUrl = baseUrl + endpoint + "/word"
val scn = scenario("Revert_1")
.exec(http("Request_1")
.get(fullUrl)
.check(status.is(200)))
setUp(
scn.inject(
nothingFor(2),
atOnceUsers(100),
rampUsers(100) during (60)
)
).protocols(httpProtocol)
}
我不熟悉加特林,但必须尽快进行测试。我尝试了不同的解决方案,但不明白如何提供从列表或文件中获取的{word}
参数
目前,我的代码如下:
http://localhost:8080/api/v1/palindrom/revert/{word}
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class MultiRequest extends Simulation {
private val baseUrl = "http://localhost:8080"
private val endpoint = "/api/v1/palindrom"
val httpProtocol = http
.baseUrl(baseUrl)
.inferHtmlResources()
.acceptHeader("*/*")
.contentTypeHeader("application/json")
.userAgentHeader("gatling/3.3.1")
val fullUrl = baseUrl + endpoint + "/word"
val scn = scenario("Revert_1")
.exec(http("Request_1")
.get(fullUrl)
.check(status.is(200)))
setUp(
scn.inject(
nothingFor(2),
atOnceUsers(100),
rampUsers(100) during (60)
)
).protocols(httpProtocol)
}
使用上面的代码,测试运行200个请求,但始终使用相同的参数(word
)
我不明白如何提供一个50个单词的列表,随机抽取200次。你能帮忙吗
请理解,这里的服务端点只是问题的一个示例,而不是一个真实的示例。您应该查看教程,这里正是您想要的:feeders和Gatling EL: