我正在尝试模块化 Gatling 中的一系列性能测试。
有几个测试通过页面执行相同的初始路径,所以我认为我可以将它们分解为一系列场景,每个场景都是在自己的文件中定义的一系列共享操作,然后是最终的模拟定义一个接一个地执行指定的场景。
然后我需要让我的模拟按顺序运行这些场景;但我只能找到如何同时运行它们,或者每个之间有指定的延迟。是否有任何模拟设置选项可以在不指定任意延迟的情况下一个接一个地运行定义的场景?
编辑
目前,我有以下一组文件:
主页Headers.scala
package advanced
object homepageHeaders {
val homepage_headers_1 = Map(
"Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""",
"If-Modified-Since" -> """Wed, 20 Mar 2013 15:36:31 +0000""",
"If-None-Match" -> """"1363793791""""
)
}
主页Chain.scala
package advanced
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import akka.util.duration._
import homepageHeaders._
object homepageChain {
val homepageChain =
//Homepage
exec(http("homepage")
.get("/")
.headers(homepageHeaders.homepage_headers_1)
)
}
pageHeaders.scala
package advanced
object pageHeaders {
val page_headers_1 = Map(
"Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"""
)
}
pageChain.scala
package advanced
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import akka.util.duration._
import pageHeaders._
object pageChain {
val pageChain =
//Page Menu
exec(http("page request")
.get("/page1")
.headers(pageHeaders.page_headers_1)
)
}
pageSimulation.scala
package advanced
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import homepageChain._
import pageChain._
class pageSimulation extends Simulation {
val urlBase = "http://www.mytestsite.com"
val httpConf = httpConfig
.baseURL(urlBase)
.acceptHeader("image/png,image/*;q=0.8,*/*;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-gb,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0")
val pageScenario = scenario("Bodycare Scenario")
.exec(homepageChain.homepageChain)
.exec(pageChain.pageChain)
setUp(
homepageScenario.users(1).protocolConfig(httpConf)
)
}
我得到的错误是:
14:40:50.800 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/pageChain.scala:13: not found: value exec
14:40:50.807 [ERROR] c.e.e.g.a.ZincCompiler$ - exec(http("page request")
14:40:50.808 [ERROR] c.e.e.g.a.ZincCompiler$ - ^
14:40:53.988 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/homepageChain.scala:13: not found: value exec
14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ - exec(http("homepage")
14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ - ^
14:41:17.274 [ERROR] c.e.e.g.a.ZincCompiler$ - two errors found
Exception in thread "main" Compilation failed
显然我在我的定义中遗漏了一些东西,但我只是不明白它是什么