使用 Gatling 参数对基本身份验证进行负载测试 - Scala
Load testing basic authentication with parameters with Gatling - Scala
我在尝试使用带有从 csv 文件检索的参数的 basicAuth 方法时遇到问题。
这是我的代码:
class spiSimulation 扩展模拟 {
val httpProtocol = http
.baseURL("http://spi.test.com")
.inferHtmlResources()
val headers_0 = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Cache-Control" -> "no-cache",
"Pragma" -> "no-cache",
"Proxy-Connection" -> "keep-alive")
val users = csv("users.csv")
val scn = scenario("LosspiSimulation_request")
.feed(users)
.exec(
http("request")
.get("/SPI/Basic").headers(headers_0)
.basicAuth("${login}", "${password}")
.headers(headers_0).check(
header("Set-Cookie").saveAs("Cookie")))
.exec(
http("validate")
.get("/SPI-back/Validation?cookie=${Cookie}")
.headers(headers_0))
setUp(scn.inject(rampUsers(10) over (2 seconds))).protocols(httpProtocol)
}
当我只使用一个用户并对我的登录名和密码进行硬编码时,它就可以工作了。但是使用参数登录名和密码,当 运行 Gatling 脚本时我有两个错误,一个是定义了 "No attribute named Cookie" 和 "No attribute named login is defined"。
这是我的 csv 文件的示例:
login, password
test01, password01
test02, password02
如果您能找到解决方案,我将很高兴。
非常感谢您的帮助!
我在尝试使用带有从 csv 文件检索的参数的 basicAuth 方法时遇到问题。
这是我的代码:
class spiSimulation 扩展模拟 {
val httpProtocol = http
.baseURL("http://spi.test.com")
.inferHtmlResources()
val headers_0 = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Cache-Control" -> "no-cache",
"Pragma" -> "no-cache",
"Proxy-Connection" -> "keep-alive")
val users = csv("users.csv")
val scn = scenario("LosspiSimulation_request")
.feed(users)
.exec(
http("request")
.get("/SPI/Basic").headers(headers_0)
.basicAuth("${login}", "${password}")
.headers(headers_0).check(
header("Set-Cookie").saveAs("Cookie")))
.exec(
http("validate")
.get("/SPI-back/Validation?cookie=${Cookie}")
.headers(headers_0))
setUp(scn.inject(rampUsers(10) over (2 seconds))).protocols(httpProtocol)
}
当我只使用一个用户并对我的登录名和密码进行硬编码时,它就可以工作了。但是使用参数登录名和密码,当 运行 Gatling 脚本时我有两个错误,一个是定义了 "No attribute named Cookie" 和 "No attribute named login is defined"。
这是我的 csv 文件的示例:
login, password
test01, password01
test02, password02
如果您能找到解决方案,我将很高兴。
非常感谢您的帮助!