第四篇
http://gatling.io/docs/2.2.1/migration_guides/2.0.0-M3a-to-2.0.html
Migrating from 2.0.0-M3a to 2.0
Global changes
Gatling requires at least JDK7u6
As targeting newer JDKs provides bug fixes, speed improvements and opens opportunities for optimization, Gatling now requires at least a JDK7u6 (released almost two years ago already).
Gatling is now available on Maven Central
Gatling releases are now available on Maven Central, and snapshots are deployed on each successful build by Travis CI to Sonatype’s snapshots repository. If you were using Gatling with its Maven plugin, you no longer need to add the Excilys repository in your pom.xml.
Simulation
Necessary imports
import bootstrap. and import assertions. are now unnecessary and have to be removed.
import io.gatling.http.Headers.Names. is now unnecessary, headers names are now directly available from HeaderNames.
import io.gatling.http.Headers.Values. is now unnecessary, headers values are now directly available from HeaderValues.
Injection DSL
ramp(10 users) becomes rampUsers(10)
heaviside(10 users) becomes heavideUsers(10)
atOnce(10 users) becomes atOnceUsers(10)
constantRate(10 usersPerSec) becomes constantUsersPerSec(10)
rampRate(10 usersPerSec) becomes rampUsersPerSec(10)
split(10 users) becomes splitUsers(10)
Core
Structure Elements
In asLongAs, exitASAP now defaults to true. For more information on the change of behaviour it introduces, see asLongAs documentation.
Checks
whatever has been renamed to optional.
transform now no longer takes and returns an Option[T] and takes and returns plain types, but transformOption provides the same functionality as transform did.
HTTP
Form parameters (for POST requests)
Renamed
Methods for adding form parameters to the request have been renamed:
param => formParam
multiValuedParam => multiValuedFormParam
Misc
requestInfoExtractor and responseInfoExtractor have been merged into a single extraInfoExtractor, which takes a ExtraInfo => List[Any] function.
gatling.http.ahc.useRawUrl configuration parameter was removed, please use disableUrlEncoding instead, as described here.
For more information on extraInfoExtractor, please refer to its documentation.
Logs
simulation.log has been redesigned.
If you wrote your own specific simulation.log parser, you’ll need to migrate it to the new structure.
Recorder
Until now, when setting up the Recorder, you had to setup two ports for the Recorder’s local proxy: one for HTTP, one for HTTPS. This is not needed anymore, as the Recorder handles itself the switch to an HTTPS connection if necessary, and only a single port needs to be specified.
Maven Plugin
The
For more information, see the Maven plugin documentation.
Migrating from 2.0.0-M3a to 2.0
从2.0.0-M3a 合并到2.0
全局改变
Gatling 需要至少JDK7u6版本
因为心得JDKs修复一些问题,速度得到改善,优化了处理,gatling 现在需要至少JDK7u6(2年前已经发布)
gatling 现在同样在maven cetral 适用
gatling 现在同样在maven cetral 适用,并且快照都会部署到 Sonatype’s snapshots repository 当每次 Travis ci 构建成功后。如果你使用maven插件版gatling,你不需要添加the Excilys repository 在你的pom.xml中。
模拟器
Necessary imports
import bootstrap. and import assertions. 现在已经不需要并且被移除
import io.gatling.http.Headers.Names. 已经不需要, headers names被 HeaderNames代替.
import io.gatling.http.Headers.Values. 已经不需要, headers values 被 HeaderValues代替.
Injection DSL
ramp(10 users) 变为 rampUsers(10)
heaviside(10 users) 变为 heavideUsers(10)
atOnce(10 users)变为 atOnceUsers(10)
constantRate(10 usersPerSec) 变为 constantUsersPerSec(10)
rampRate(10 usersPerSec)变为 rampUsersPerSec(10)
split(10 users) 变为 splitUsers(10)
Core
Structure Elements
结构化组件
在 asLongAs, exitASAP 默认为trule。
有关的行为改变的更多信息介绍,请看asLongAs文档。
Checks
whatever 已经被重新命名为 optional.
transform now no longer takes and returns an Option[T] and takes and returns plain types, but transformOption provides the same functionality as transform did.
transform现在不再需要现在返回一个Option[T],并返回plain类型,但transformOption和transform提供了相同的功能。
HTTP
Form parameters (关于 POST 请求)
重命名
adding form parameters 方法请求已经被重命名:
param => formParam
multiValuedParam => multiValuedFormParam
Misc
requestInfoExtractor 和 responseInfoExtractor 已经合并为 extraInfoExtractor, which takes a ExtraInfo => List[Any] function.
gatling.http.ahc.useRawUrl 配置参数已经被移除, 请用 disableUrlEncoding 代替, 描述如下.
更多关于 extraInfoExtractor信息, 请参照这个文档.
Logs
simulation.log 已经被重新设计.
如果你写自己的simulation.log解析器,您需要它迁移到新结构
Recorder
Until now, 当你设置 Recorder时, 你必须设置两个端口记录器的当地代理:一个用于HTTP,HTTPS。 这再也不需要了, 因为record处理本身转向一个HTTPS连接如果必要,并且只需要指定一个单独的端口。
Maven Plugin
The <includes>...</includes>
和 <excludes>...</excludes>
配置项 已经被移除. 如果你需要选择一个特殊的模拟运行, 你可以使用 <simulationClass>...</simulationClass>
去配置.
更多的信息, 查阅 Maven plugin 文档.