简体   繁体   English

使用斜坡参数时,加特林给出错误

[英]Gatling gives error when using parameter for ramp

I'm using a parameter for my ramp value as per the docs, 我正在根据文档使用参数作为斜率值,

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

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

But when I run gatling, I'm getting an error: 但是,当我运行加特林时,出现了一个错误:

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)

I thought I could simply cast to Long before using the parameter 我以为我可以在使用参数之前简单地转换为Long

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

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

but this still errors: 但这仍然错误:

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),

Any suggestions why following the documentation, or the explicit cast to long don't work? 有什么建议为什么遵循文档或将表述强制转换为长期无效?

Try using rampUpRate.toLong to cast to a Long (or the more general cast rampUpRate.asInstanceOf[Long] ) 尝试使用rampUpRate.toLong转换为Long(或更一般的rampUpRate.asInstanceOf[Long]

(Long) rampUpRate is seen by the compiler as trying to perform Long.rampUrRate() eg applying function rampUpRate to object Long , hence the error message (Long) rampUpRate被编译器视为试图执行Long.rampUrRate()例如,将函数rampUpRate应用于object Long ,因此出现错误消息

That's my fault: the wiki page is not up to date. 那是我的错:Wiki页面不是最新的。 What happens is that you have a java.lang.Integer while the method takes a scala Long. 发生的是,您有一个java.lang.Integer,而该方法采用了scala Long。 java.lang.Long can be implicitly converted into scala Long, but not java.lang.Integer. 可以将java.lang.Long隐式转换为scala Long,但不能将其转换为java.lang.Integer。

The proper way would be val rampUpRate = java.lang.Long.getLong("ramp", 1L) 正确的方法是val rampUpRate = java.lang.Long.getLong("ramp", 1L)

PS: I've fixed the doc. PS:我已经修复了文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM