0

根据文档,我正在为我的斜坡值使用一个参数,

val rampUpRate  = Integer.getInteger("ramp", 1)

setUp(
    scn.users(10).ramp(rampUpRate).protocolConfig(httpConf)
)

但是当我运行 gatling 时,我得到了一个错误:

09:57:35.695 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/clients/com/mydomain/www/stress/RecordedSimulation.scala:1088: overloaded method value ramp with alternatives:
  (duration: akka.util.Duration)com.excilys.ebi.gatling.core.scenario.configuration.ConfiguredScenarioBuilder <and>
  (duration: Long)com.excilys.ebi.gatling.core.scenario.configuration.Configured
ScenarioBuilder
 cannot be applied to (java.lang.Integer)

我以为我可以在使用参数之前简单地转换为 Long

val rampUpRate  = Integer.getInteger("ramp", 1)

setUp(
    scn.users(10).ramp((Long) rampUpRate).protocolConfig(httpConf)
)

但这仍然错误:

09:57:35.695 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/clients/com/mydomain/www/stress/RecordedSimulation.scala:1088: \sanctuarySpa\com\sanctuaryspa\www\stress\RecordedSimulation.scala:1088:
value rampUpRate is not a member of object Long
10:05:34.915 [ERROR] c.e.e.g.a.ZincCompiler$ - scn1.users(10).ramp((Long) rampUpRate).protocolConfig(httpConf),

有什么建议为什么遵循文档或显式转换为 long 不起作用?

4

2 回答 2

2

That's my fault: the wiki page is not up to date. What happens is that you have a java.lang.Integer while the method takes a scala Long. java.lang.Long can be implicitly converted into scala Long, but not java.lang.Integer.

The proper way would be val rampUpRate = java.lang.Long.getLong("ramp", 1L)

PS: I've fixed the doc.

于 2013-03-21T12:27:15.523 回答
2

尝试使用rampUpRate.toLongto 转换为 Long (或更一般的 cast rampUpRate.asInstanceOf[Long]

(Long) rampUpRate被编译器视为试图执行Long.rampUrRate()例如应用函数rampUpRateobject Long,因此错误消息

于 2013-03-21T11:34:52.280 回答