我想知道是否有某種方式來指定每次通話而不是每個方案的負載(多少個虛擬用戶)?加特林每次通話的加載
比方說,我想壓力測試一款遊戲,而我只需要一次打電話來打開或關閉一款遊戲,但我希望有大量用戶在玩它......我可以通過加特林來實現這一目標嗎?
非常感謝!
我想知道是否有某種方式來指定每次通話而不是每個方案的負載(多少個虛擬用戶)?加特林每次通話的加載
比方說,我想壓力測試一款遊戲,而我只需要一次打電話來打開或關閉一款遊戲,但我希望有大量用戶在玩它......我可以通過加特林來實現這一目標嗎?
非常感謝!
你總是可以有一個小場景做你想做的。如果您不想爲每個用戶重複某些步驟,您可能會使用before/after hooks來打開或關閉遊戲。
這是相當聰明的,但不能夠使用Gatling DSL之前/之後的鉤子是一個可怕的限制,雖然。當你說「你總是可以有一個小場景做你想做的事情」時,你能給我更多的細節嗎?我已經看到了你可以執行多個方案,但他們同時執行,所以我就沒有保證,「開放式遊戲」的場景將在「玩遊戲」的場景前執行。 – Foobar
我的意思是你可以將更大的場景分割成更小的可重用片段。不要以爲你可以的方式,將允許您雖然之前替換/掛機後撰寫的情景。雖然我可能仍然不是100%正確的,但似乎並不符合像加特林這樣的工具的理念。 –
一種方式做到這一點:
步驟:
包裝你模擬的特質。
在特質中定義方法。
定義方案。
的閉合括號的性狀之後,定義了一個模擬類。
在最後你應該有這樣的事情:
package [name]
import [all the stuff]
trait Scenario2 extends Simulation {
//
// Here you should put all the VALs, baseURL, headers etc.
//
def openGame() =
http("Opens the game")
.get("IP to open the game")
.headers(headers)
.check(status.is(200)) (optional)
def usersPlaying() =
http("Users playing the game")
.get("IP to play the game")
.headers(headers)
.check(status.is(200)) (optional)
def scen(name: String) = {
scenario(name)
.exec(openGame())
}
def scen2(name: String) = {
scenario(name)
.exec(usersPlaying())
.pause(5) // the pause needs to be **here** for some reason, rather than in *scen*
}
}
// Here lies the simulation class
class Testing_The_Game extends Scenario2 {
setUp(
(scen("This opens the game")
.inject(
atOnceUsers(1))
.protocols(httpConf)),
(scen2("This simulates users playing")
.inject(
atOnceUsers(1000))
.protocols(httpConf))
)
}
剛剛發現this答案。它看起來比我的好多了。
當你說'call'時,你的意思是HTTP請求嗎? – childofsoong
是的,我的意思是HTTP請求 – Foobar