1
我正在嘗試創建一個Gatling場景,該場景需要在測試期間將協議切換到不同的主機。用戶旅途是場景期間的Gatling切換協議
https://example.com/page1
https://example.com/page2
https://accounts.example.com/signin
https://example.com/page3
以便作爲單個場景的一部分,我需要醚切換中建立場景定義的,或切換的協議所定義的baseUrl
但我不能找出如何去做。
基本方案可能看起來像
package protocolexample
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class Example extends Simulation {
val exampleHttp = http.baseURL("https://example.com/")
val exampleAccountsHttp = http.baseURL("https://accounts.example.com/")
val scn = scenario("Signin")
.exec(
http("Page 1").get("/page1")
)
.exec(
http("Page 2").get("/page2")
)
.exec(
// This needs to be done against accounts.example.com
http("Signin").get("/signin")
)
.exec(
// Back to example.com
http("Page 3").get("/page3")
)
setUp(
scn.inject(
atOnceUsers(3)
).protocols(exampleHttp)
)
}
我只需要弄清楚如何醚切換爲第三步主機或協議。我知道我可以創建多個場景,但這需要跨越多個主機成爲單個用戶流。
我試圖直接使用其他協議
exec(
// This needs to be done against accounts.example.com
exampleAccountsHttp("Signin").get("/signin")
)
這導致
protocolexample/example.scala:19: type mismatch;
found : String("Signin")
required: io.gatling.core.session.Session
exampleAccountsHttp("Signin").get("/signin")
,也將有關該請求
exec(
// This needs to be done against accounts.example.com
http("Signin").baseUrl("https://accounts.example.com/").get("/signin")
)
這導致
基URLprotocolexample/example.scala:19: value baseUrl is not a member of io.gatling.http.request.builder.Http
@Meiko嗨,對不起,因爲延誤。標記爲已接受 – Smudge